velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "B. Scott Smith" <sc...@smithdomain.com>
Subject NullPointerException in init() during redeploy
Date Thu, 01 Jul 2010 16:33:08 GMT
Hi,

I have finally finished moving my application from Velocity 1.4/Tools 
1.4 to Velocity 1.6.4/Tools 2.0 (thanks for your help Nathan).
Unfortunately, I am hitting a serious snag during the re-deploy. My 
Servlet is extending VelocityViewServlet, and the NullPointerException 
is being thrown in my init() method, when calling super.init(). The 
problem is occurring in 
org.apache.velocity.runtime.RuntimeInstance#setDefaultProperties():

     inputStream = getClass()
         .getResourceAsStream('/' + DEFAULT_RUNTIME_PROPERTIES);

The input stream it is returning is NULL. This only seems to happen when 
I re-deploy into my Servlet Container (I am using Jetty). If I then shut 
down the entire JVM and restart, the application runs fine. 
Unfortunately, restarting the JVM to deploy my app everywhere is not an 
option. If I catch and ignore the Exception, the rest of my application 
runs fine (but any access to the Velocity Engine generates errors).

Here is the stack trace I am receiving. Any help or guidance would be 
greatly appreciated.

  java.lang.NullPointerException
        at java.io.Reader.<init>(Unknown Source)
        at java.io.InputStreamReader.<init>(Unknown Source)
        at 
org.apache.commons.collections.ExtendedProperties.load(ExtendedProperties.java:543)
        at 
org.apache.commons.collections.ExtendedProperties.load(ExtendedProperties.java:519)
        at 
org.apache.velocity.runtime.RuntimeInstance.setDefaultProperties(RuntimeInstance.java:397)
        at 
org.apache.velocity.runtime.RuntimeInstance.initializeProperties(RuntimeInstance.java:570)
        at 
org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:249)
        at 
org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:107)
        at 
org.apache.velocity.tools.view.VelocityView.init(VelocityView.java:347)
        at 
org.apache.velocity.tools.view.VelocityView.init(VelocityView.java:310)
        at 
org.apache.velocity.tools.view.VelocityView.<init>(VelocityView.java:213)
        at 
org.apache.velocity.tools.view.ServletUtils.createView(ServletUtils.java:156)
        at 
org.apache.velocity.tools.view.ServletUtils.getVelocityView(ServletUtils.java:142)
        at 
org.apache.velocity.tools.view.ServletUtils.getVelocityView(ServletUtils.java:104)
        at 
org.apache.velocity.tools.view.VelocityViewServlet.getVelocityView(VelocityViewServlet.java:155)
        at 
org.apache.velocity.tools.view.VelocityViewServlet.init(VelocityViewServlet.java:122)
        at rss.starter.MyTestServlet.init(MyTestServlet.java:147)
        at 
org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
        at 
org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263)
        at 
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at 
org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
        at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
        at 
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
        at 
org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
        at 
org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
        at 
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at 
org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
        at org.mortbay.jetty.Server.doStart(Server.java:224)
        at 
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at rss.jettywrapper.JettyWrapper.startServer(JettyWrapper.java:142)
        at rss.jettywrapper.JettyWrapper.upgradeCheck(JettyWrapper.java:204)
        at rss.jettywrapper.JettyWrapper.access$100(JettyWrapper.java:24)
        at rss.jettywrapper.JettyWrapper$1.run(JettyWrapper.java:80)
        at java.lang.Thread.run(Unknown Source)
  java.lang.RuntimeException: Could not initialize VelocityEngine: 
java.lang.NullPointerException
        at 
org.apache.velocity.tools.view.VelocityView.init(VelocityView.java:354)
        at 
org.apache.velocity.tools.view.VelocityView.init(VelocityView.java:310)
        at 
org.apache.velocity.tools.view.VelocityView.<init>(VelocityView.java:213)
<same stack as above>
  Caused by: java.lang.NullPointerException
        at java.io.Reader.<init>(Unknown Source)
        at java.io.InputStreamReader.<init>(Unknown Source)
        at 
org.apache.commons.collections.ExtendedProperties.load(ExtendedProperties.java:543)
        at 
org.apache.commons.collections.ExtendedProperties.load(ExtendedProperties.java:519)
        at 
org.apache.velocity.runtime.RuntimeInstance.setDefaultProperties(RuntimeInstance.java:397)
        at 
org.apache.velocity.runtime.RuntimeInstance.initializeProperties(RuntimeInstance.java:570)
        at 
org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:249)
        at 
org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:107)
        at 
org.apache.velocity.tools.view.VelocityView.init(VelocityView.java:347)
        ... 25 more

Thank you.
  - Scott


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message