Velocity
  1. Velocity
  2. VELOCITY-786

NullPointerException while evaluating template

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.4
    • Fix Version/s: 1.7, 2.x
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      FreeBSD 8.0, Java(TM) SE Runtime Environment (build 1.6.0_03-p4-root_19_oct_2010_22_21-b00), Apache Tomcat/6.0.29, Spring 2.5

      Description

      While evaluating template with Velocity I am affecting:

      java.lang.NullPointerException
      org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1103)
      org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1086)
      org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1199)
      org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1165)
      org.apache.velocity.app.Velocity.evaluate(Velocity.java:191)
      pl.pollub.cafe.zeusx.modules.report.ReportController.generateWorkersSchedule(ReportController.java:300)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:597)
      org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:421)
      org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:136)
      org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:326)
      org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:313)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
      org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      pl.pollub.cafe.zeusx.commons.spring.FlashScopeFilter.doFilterInternal(FlashScopeFilter.java:33)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
      org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

      exception.

      Code which is being executed:
      try

      { Velocity.init(); }

      catch (Exception e1)

      { e1.printStackTrace(); }

      then

      try

      { Velocity.evaluate( context, writer, "string", template.getSzablon()); }

      catch (ParseErrorException e)

      { e.printStackTrace(); } catch (MethodInvocationException e) { e.printStackTrace(); }

      catch (ResourceNotFoundException e)

      { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }

      This code does not on production server, but works on development machines. I have tried using VelocityEngine instetad of Velocity Signleton but no luck.

      I also tried initializing Velocity during servlet startup but nothing changed. Any help appreciated

        Issue Links

          Activity

          Pawel Urban created issue -
          Hide
          Jarkko Viinamäki added a comment -

          This looks like a duplicate of VELOCITY-750. I thought the bug fixed in 1.6.4? Apparently not.

          Show
          Jarkko Viinamäki added a comment - This looks like a duplicate of VELOCITY-750 . I thought the bug fixed in 1.6.4? Apparently not.
          Jarkko Viinamäki made changes -
          Field Original Value New Value
          Link This issue duplicates VELOCITY-750 [ VELOCITY-750 ]
          Hide
          Pawel Urban added a comment -

          The problem had very simple cause - Log.

          I temporarily fixed the problem by

          Velocity.setProperty("runtime.log"logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");

          just before init.

          Show
          Pawel Urban added a comment - The problem had very simple cause - Log. I temporarily fixed the problem by Velocity.setProperty("runtime.log"logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem"); just before init.
          Pawel Urban made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 1.6.4 [ 12314977 ]
          Resolution Fixed [ 1 ]
          Hide
          Antonio Petrelli added a comment -

          I reopen this issue, since it is not really resolved.
          Pawel, can you provide a test case, preferably in the form of a Maven project?
          Thank you.

          Show
          Antonio Petrelli added a comment - I reopen this issue, since it is not really resolved. Pawel, can you provide a test case, preferably in the form of a Maven project? Thank you.
          Antonio Petrelli made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Hide
          Nathan Bubna added a comment -

          In 1.6, LogManager wasn't catching UnsupportedOperationExceptions from trying to use ServletLogChute when servlet classes were available but the servletContext was not in the application attributes. This was fixed in 1.7 and following.

          Show
          Nathan Bubna added a comment - In 1.6, LogManager wasn't catching UnsupportedOperationExceptions from trying to use ServletLogChute when servlet classes were available but the servletContext was not in the application attributes. This was fixed in 1.7 and following.
          Nathan Bubna made changes -
          Fix Version/s 1.7 [ 12313453 ]
          Fix Version/s 2.0 [ 12310291 ]
          Fix Version/s 1.6.4 [ 12314977 ]
          Hide
          Nathan Bubna added a comment -

          Resolving since it was, indeed, fixed.

          Show
          Nathan Bubna added a comment - Resolving since it was, indeed, fixed.
          Nathan Bubna made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Mark Thomas made changes -
          Workflow jira [ 12525855 ] Default workflow, editable Closed status [ 12551715 ]
          Mark Thomas made changes -
          Workflow Default workflow, editable Closed status [ 12551715 ] jira [ 12552579 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          43d 9h 35m 1 Pawel Urban 16/Dec/10 19:33
          Resolved Resolved Reopened Reopened
          13h 49m 1 Antonio Petrelli 17/Dec/10 09:22
          Reopened Reopened Resolved Resolved
          6d 14h 26m 1 Nathan Bubna 23/Dec/10 23:49

            People

            • Assignee:
              Unassigned
              Reporter:
              Pawel Urban
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development