wood burning stoves 2.0*
The moose likes Struts and the fly likes NullPointerException in PropertyUtils .getSimpleProperty() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "NullPointerException in PropertyUtils .getSimpleProperty()" Watch "NullPointerException in PropertyUtils .getSimpleProperty()" New topic
Author

NullPointerException in PropertyUtils .getSimpleProperty()

Neil Richards
Greenhorn

Joined: Jan 22, 2002
Posts: 9
Hi,
What I am trying to do is so simple, but for the life of me I cannot see what I am doing wrong. Could someone please help?!
I have a simple form with 2 inputs which I have specified in struts-config as a DynaActionForm like this:
<CODE>
<form-bean name="agentForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="col" type="java.lang.String" initial=""/>
<form-property name="agent" type="java.lang.String" initial=""/>
</form-bean>
</CODE>
My form is equally simple ..
<CODE>
<html:form name="agentForm" type="org.apache.struts.action.DynaActionForm" action="/ops/selectAgent.do">
<html:hidden property="col"/>
<html:select name="agentForm" property="agent">
<html ptions collection="agents" property="key" labelProperty="value"/>
</html:select>
<html:submit value="submit">Choose Agent</html:submit>
</html:form>
</CODE>
This is the full stack trace ..
<CODE>
java.lang.NullPointerException
at org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUtils.java:1162)
at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:772)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:801)
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:952)
at org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:176)
at org.apache.struts.taglib.html.HiddenTag.doStartTag(HiddenTag.java:123)
at org.apache.jsp.select_0002dagent_jsp._jspx_meth_html_hidden_0(select_0002dagent_jsp.java:142)
at org.apache.jsp.select_0002dagent_jsp._jspx_meth_html_form_0(select_0002dagent_jsp.java:114)
at org.apache.jsp.select_0002dagent_jsp._jspService(select_0002dagent_jsp.java:83)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:466)
at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:585)
at java.lang.Thread.run(Thread.java:534)
</CODE>
TIA,
Neil
Srikanth Shenoy
author
Ranch Hand

Joined: Jan 24, 2004
Posts: 184
Hi Neil,
Try removing the name and type on the html:form.
It is figured out automatically by Struts.
Also check if the action mapping for /ops/selectAgent has the right ActionForm associated with it.


Srikanth Shenoy
Author of Struts Survival Guide : Basics to Best Practices
Neil Richards
Greenhorn

Joined: Jan 22, 2002
Posts: 9
Thanks for the tip Srikanth - I won't specify them in future. I had tried specifying a value proir to your reply, which didn't seem to have any effect.
When I took those properties out, it worked, but also now works if I put them back. Only if I remove the value property from the hidden tag does it stop working again.
How I love development
 
Consider Paul's rocket mass heater.
 
subject: NullPointerException in PropertyUtils .getSimpleProperty()
 
Similar Threads
Exception when uploading big files
New Exceptions can't create DynaActionForm
Mails not being sent without SMTP authentication
Mails not being sent without SMTP authentication
Bean not in any scope