Announcement Announcement Module
Collapse
No announcement yet.
NPE inside of RequestContext.getBindStatus Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NPE inside of RequestContext.getBindStatus

    I'm very new to Spring, trying to figure out how all the different kinds of controllers work. I think I've got my head wrapped around the SimpleFormController, and everything works fine in a simple test example that I have. However, I'm having problems integrating it with "real" code.

    I have a URL that's mapped to my class which extends SimpleFormController, and as long as I POST to the SimpleFormController, everything is fine--I'm using Velocity and #SpringFormInput() calls, and all the fields are getting populated perfectly and coming across to the FormController as a Command object with no problems.

    However, if I don't POST any data to the page, but I either pass data as GET or don't pass any data at all, then Spring chokes on the #springBind() call:

    Code:
    - Method getBindStatus threw exception for reference $springMacroRequestContext in template CreateRelationship.vm at  [4,33]
    - Could not complete request
    org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getBindStatus' in  class org.springframework.web.servlet.support.RequestContext threw exception class java.lang.NullPointerException : null
    	at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:246)
    	at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:175)
    	at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:327)
    	at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:51)
    	at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:95)
    	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:55)
    	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230)
    	at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:89)
    	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230)
    	at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:172)
    	at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:114)
    	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230)
    	at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:172)
    	at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:114)
    	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230)
    	at org.apache.velocity.Template.merge(Template.java:256)
    	at org.springframework.web.servlet.view.velocity.VelocityView.mergeTemplate(VelocityView.java:553)
    	at org.springframework.web.servlet.view.velocity.VelocityView.doRender(VelocityView.java:500)
    	at org.springframework.web.servlet.view.velocity.VelocityView.renderMergedTemplateModel(VelocityView.java:321)
    	at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:160)
    	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:928)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:705)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625)
    	at org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:386)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:346)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
    	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
    	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
    	at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
    	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
    	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:184)
    	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
    	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
    	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
    	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
    	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
    	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
    	at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:732)
    	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619)
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:688)
    	at java.lang.Thread.run(Thread.java:595)
    Any ideas what could be going on? I've hunted around in the Spring source code, but without a stacktrace for the actual NullPointerException, I don't really have any way of knowing what's going on.

    (This doesn't happen in my "test" code, where I also have a class extending SimpleFormController, but there everything works fine, even without POSTing to the page first.)

    Thanks in advance!

  • #2
    Figured it out ... solution for future Googlers

    Turns out I was registering a CustomEditor to turn my input into objects, and they weren't checking to see if getValue() was null before dereferencing it. Hope this helps somebody else down the line!

    Comment

    Working...
    X