Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-891

Upgrade to v2.0 causes parser failures

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Component/s: Engine
    • Labels:
      None

      Description

      We are upgrading from v1.7 to v2.0 but have come across a problem almost immediately.

      Our templates can contain a lot of Javascript with references to things that begin with the '#' character e.g. Kendo JS templates. These used to be ignored by 1.7 but now they are causing parser failures as follows;

      #set ($JQId = "#" + $Utils.getJQuerySelector($SparklineElementId))

      org.apache.velocity.exception.ParseErrorException: Failed to parse String literal

      It is complaining about the "#"

      I can't find any directive that switches this off or a way to circumvent it.

      A workaround is to replace the '#' with $HASH but we have thousands of these and no way of fixing the end-user commited templates.

      2018-05-30 15:07:30 ERROR context.ContextLoader - Context initialization failed
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'velocityConfig' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.apache.velocity.exception.VelocityException: Velocimacro: Error using VM library: ../macros/macros-forms.vm
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:638)
      	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:942)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
      	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
      	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
      	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
      	at com._4ng.web.servlet.Initialisation.contextInitialized(Initialisation.java:175)
      	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
      	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      30-May-2018 15:07:30.618 SEVERE [null Initialisation] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
      	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
      30-May-2018 15:07:30.621 SEVERE [null Initialisation] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
      	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
      	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
      	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1702)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
      	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
      	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
      	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:482)
      	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:431)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
      	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
      	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
      	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
      	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
      	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
      	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
      	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:361)
      	at sun.rmi.transport.Transport$1.run(Transport.java:200)
      	at sun.rmi.transport.Transport$1.run(Transport.java:197)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
      	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
      	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
      	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: org.apache.velocity.exception.VelocityException: Velocimacro: Error using VM library: ../macros/macros-forms.vm
      	at org.apache.velocity.runtime.VelocimacroFactory.initVelocimacro(VelocimacroFactory.java:213)
      	at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:251)
      	at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:87)
      	at org.springframework.ui.velocity.VelocityEngineFactory.createVelocityEngine(VelocityEngineFactory.java:251)
      	at org.springframework.web.servlet.view.velocity.VelocityConfigurer.afterPropertiesSet(VelocityConfigurer.java:119)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
      	... 58 more
      Caused by: org.apache.velocity.exception.ParseErrorException: Failed to parse String literal at ../macros/macros-forms.vm[line 3586, column 19]
      	at org.apache.velocity.Template.process(Template.java:160)
      	at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:426)
      	at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:343)
      	at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1554)
      	at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1534)
      	at org.apache.velocity.runtime.VelocimacroFactory.initVelocimacro(VelocimacroFactory.java:196)
      	... 64 more
      
      

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cbrisson Claude Brisson
                Reporter:
                sohara Steve O'Hara
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: