Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.5
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      Operating System: other
      Platform: Other

      Description

      VelocityEngine throws a strange NPE if it's not initialized. It'd be better
      if it threw an Exception with a meaningful error message.

      From jeichels@optonline.net <jeichels@optonline.net>

      I had another problem that I think can help others in the future. In looking
      through the archives I noticed other people having the same null pointer
      exception I was having. I went through the code and noticed that if a person
      did not "init()" a velocity engine, the resourceManager never gets
      initialized. When they call the function below in RuntimeInstance.java, they
      get the null pointer exception.

      public Template getTemplate(String name, String encoding)
      throws ResourceNotFoundException, ParseErrorException, Exception

      { return (Template) resourceManager.getResource(name, ResourceManager.RESOURCE_TEMPLATE, encoding); }

      ERROR [http8080-Processor2] TemplateToStringManagerBD.getContentAsString() -
      VelocityEngine failed to merge the template.
      java.lang.NullPointerException
      at org.apache.velocity.runtime.RuntimeInstance.getTemplate
      (RuntimeInstance.java:835)
      at org.apache.velocity.runtime.RuntimeInstance.getTemplate
      (RuntimeInstance.java:817)
      at org.apache.velocity.runtime.RuntimeSingleton.getTemplate
      (RuntimeSingleton.java:285)
      at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:469)
      at
      com.jb.commonmvc.view.template.velocity.TemplateToStringManagerBD.getContentAsS
      tring(TemplateToStringManagerBD.java:120)
      at com.jb.commonmvc.transport.email.EmailTemplate.emailTemplate
      (EmailTemplate.java:37)

        Activity

        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12551746 ] jira [ 12552281 ]
        Mark Thomas made changes -
        Workflow jira [ 12325249 ] Default workflow, editable Closed status [ 12551746 ]
        Henning Schmiedehausen made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Will Glass-Husain made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Will Glass-Husain made changes -
        Bugzilla Id 34478
        Fix Version/s 1.5 [ 12310253 ]
        Assignee Velocity-Dev List [ velocity-dev@jakarta.apache.org ]
        Environment Operating System: other
        Platform: Other
        Operating System: other
        Platform: Other
        Description VelocityEngine throws a strange NPE if it's not initialized. It'd be better
        if it threw an Exception with a meaningful error message.

        From jeichels@optonline.net <jeichels@optonline.net>

        I had another problem that I think can help others in the future. In looking
        through the archives I noticed other people having the same null pointer
        exception I was having. I went through the code and noticed that if a person
        did not "init()" a velocity engine, the resourceManager never gets
        initialized. When they call the function below in RuntimeInstance.java, they
        get the null pointer exception.

            public Template getTemplate(String name, String encoding)
                throws ResourceNotFoundException, ParseErrorException, Exception
            {
                return (Template)
                        resourceManager.getResource(name,
                            ResourceManager.RESOURCE_TEMPLATE, encoding);
            }

        ERROR [http8080-Processor2] TemplateToStringManagerBD.getContentAsString() -
        VelocityEngine failed to merge the template.
        java.lang.NullPointerException
                at org.apache.velocity.runtime.RuntimeInstance.getTemplate
        (RuntimeInstance.java:835)
                at org.apache.velocity.runtime.RuntimeInstance.getTemplate
        (RuntimeInstance.java:817)
                at org.apache.velocity.runtime.RuntimeSingleton.getTemplate
        (RuntimeSingleton.java:285)
                at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:469)
                at
        com.jb.commonmvc.view.template.velocity.TemplateToStringManagerBD.getContentAsS
        tring(TemplateToStringManagerBD.java:120)
                at com.jb.commonmvc.transport.email.EmailTemplate.emailTemplate
        (EmailTemplate.java:37)
        VelocityEngine throws a strange NPE if it's not initialized. It'd be better
        if it threw an Exception with a meaningful error message.

        From jeichels@optonline.net <jeichels@optonline.net>

        I had another problem that I think can help others in the future. In looking
        through the archives I noticed other people having the same null pointer
        exception I was having. I went through the code and noticed that if a person
        did not "init()" a velocity engine, the resourceManager never gets
        initialized. When they call the function below in RuntimeInstance.java, they
        get the null pointer exception.

            public Template getTemplate(String name, String encoding)
                throws ResourceNotFoundException, ParseErrorException, Exception
            {
                return (Template)
                        resourceManager.getResource(name,
                            ResourceManager.RESOURCE_TEMPLATE, encoding);
            }

        ERROR [http8080-Processor2] TemplateToStringManagerBD.getContentAsString() -
        VelocityEngine failed to merge the template.
        java.lang.NullPointerException
                at org.apache.velocity.runtime.RuntimeInstance.getTemplate
        (RuntimeInstance.java:835)
                at org.apache.velocity.runtime.RuntimeInstance.getTemplate
        (RuntimeInstance.java:817)
                at org.apache.velocity.runtime.RuntimeSingleton.getTemplate
        (RuntimeSingleton.java:285)
                at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:469)
                at
        com.jb.commonmvc.view.template.velocity.TemplateToStringManagerBD.getContentAsS
        tring(TemplateToStringManagerBD.java:120)
                at com.jb.commonmvc.transport.email.EmailTemplate.emailTemplate
        (EmailTemplate.java:37)
        Jeff Turner made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 34478 12315244
        Will Glass-Husain created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Will Glass-Husain
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development