You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sheldon Hearn <sh...@starjuice.net> on 2003/12/15 13:34:47 UTC

NullPointerException from RequestUtils.createActionForm()

Hi folks,

I'm getting a NullPointerException from RequestUtils.createActionForm()
(full stack trace below).  I was originally trying to use a
DynaValidatorForm with several properties, but have now reduced the
problem to the simplest possible terms for reporting.

Here are the important bits of my struts-config.xml:

    <!-- Same problem with and without dynamic="true" -->
    <form-bean
	name="domainForm"
	dynamic="true"
	type="org.apache.struts.action.DynaActionForm">
	<form-property
	    name="domainName"
	    type="java.lang.String"/>
    </form-bean>
    ...
    <action
	path="/createDomain"
	input="/manageDomains.do"
	parameter="method"
	type="bz.clue.cluex4.action.DomainActions"
	validate="false"
	name="domainForm">
	<forward name="Success" path="/manageDomains.do" redirect="true"/>
    </action>

My DomainActions class follows..  I'm printing out the request in
createDomain() to prove that I'm not even getting that far.  I also
return a HashMap proxy called LookupDispatchMap from getKeyMethodMap(),
which prints a debugging message when its get() method is called; that
also produces no output, so I'm pretty sure I'm not even getting here:

    public class DomainActions extends LookupDispatchAction
    {

	protected Map getKeyMethodMap()
	{
	    Map lookupMap = new LookupDispatchMap();
	    lookupMap.put("button.createDomain", "createDomain");
	    ...

	    return lookupMap;
	}

	public ActionForward createDomain(ActionMapping mapping,
					  ActionForm form,
					  HttpServletRequest request,
					  HttpServletResponse response)
		throws Exception
	{

	    StringBuffer dump = new StringBuffer("createDomain");
	    dump.append(": request: ");
	    Enumeration parameters = request.getParameterNames();
	    while (parameters.hasMoreElements()) {
		String name = (String) parameters.nextElement();
		String value = request.getParameter(name);
		dump.append(name);
		dump.append("=[");
		dump.append(value);
		dump.append("] ");
	    }

	    System.out.println(dump);
	    ...
	    return mapping.findForward(Constant.SUCCESS_KEY);
	}
	
	...
    }

Here's the button name I have in my resource bundle:

    button.createDomain=Add

Now my manageDomains.jsp page constructs a simple form:

    ...
    <html:form action="createDomain">
	<html:text property="domainName" value="" size="30"/>
	<html:submit styleClass="button" property="method">
	    <bean:message key="button.createDomain"/>
	</html:submit>
    </html:form>
    ...

The page renders fine:

    ...
    <form name="domainForm" method="post" action="/cluex4/createDomain.do">
	<input type="text" name="domainName" size="30" value="">
	<input type="submit" name="method" value="Add" class="button">
    </form>
    ...

However, when I click on Add, I get this exception:

java.lang.NullPointerException
	at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:783)
	at org.apache.struts.action.RequestProcessor.processActionForm(RequestProcessor.java:364)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:253)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	...

Please, someone point out the stupid mistake I'm making.  It _must_ be
a stupid mistake, because I had this working over the week-end, with a
DynaValidatorForm and working validation too! :-(

Unfortunately, I don't seem to have committed a working version to CVS.
I've spent two hours rolling forward and back, and am losing my mind.

Thanks,
Sheldon.

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


Re: NullPointerException from RequestUtils.createActionForm()

Posted by Sheldon Hearn <sh...@starjuice.net>.
On (2003/12/15 16:56), Sheldon Hearn wrote:

> So it _definitely_ was a stupid mistake on my part.  It'd be nice to
> know what I was doing wrong, but if your time is short, don't worry
> about trying to figure out what I did wrong.

*deep.breath*

After doing some development that got me in a hole, I rolled back to the
CVS tag I dropped on the known working code.  And now it doesn't work
again:

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.BeanUtils.getNestedProperty(BeanUtils.java:695)
    at org.apache.commons.beanutils.BeanUtils.getProperty(BeanUtils.java:720)
    at org.apache.struts.taglib.html.BaseHandlerTag.lookupProperty(BaseHandlerTag.java:902)
    at org.apache.struts.taglib.html.RadioTag.currentValue(RadioTag.java:244)
    at org.apache.struts.taglib.html.RadioTag.doStartTag(RadioTag.java:212)
    at org.apache.jsp.manageDomains_jsp._jspx_meth_html_radio_0(manageDomains_jsp.java:580)
    at org.apache.jsp.manageDomains_jsp._jspx_meth_html_form_1(manageDomains_jsp.java:523)
    at org.apache.jsp.manageDomains_jsp._jspService(manageDomains_jsp.java:281)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
    ....

This time, though, it seems the problem is simpler.  Here's my form
declaration:

    <form-bean
	name="domainForm"
	dynamic="true"
	type="org.apache.struts.validator.DynaValidatorForm">
	<form-property
	    name="domainName"
	    type="java.lang.String"/>
	<form-property
	    name="domainId"
	    type="java.lang.Long"/>
	<form-property
	    name="domainIsLocal"
	    type="java.lang.Boolean"
	    initial="true"/>
    </form-bean>
    <!-- I've also tried initial="java.lang.Boolean.TRUE" as suggested
	in a message I found on Google.  I didn't expect it to work,
	and it didn't. -->

And here's how I use it:

    <html:form action="createDomain"
	    onsubmit="return validateDomainForm(this);">
	<html:text property="domainName" value="" size="30"/>
	<html:radio property="domainIsLocal" value="true"/>
	    Local Domain
	<html:radio property="domainIsLocal" value="false"/>
	    Non-Local Domain
	<html:submit styleClass="button" property="method">
	    <bean:message key="button.createDomain"/>
	</html:submit>
    </html:form>

I'm going to get away from my keyboard and try to cool off this evening.
Any helpful pointers in my inbox tomorrow morning will be greeted with
much appreciation.

Thanks,
Sheldon.

PS: Sorry to post so much as a newbie, but I'm doing my best to educate
    myself.  I've got the O'Reilly book and have spent quite a bit of
    time in the online Struts docs and FAQs, as well as Googling.  Other
    people seem to have asked about this exact problem in the mailing
    list, but I can't find replies in the archive.

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


Re: NullPointerException from RequestUtils.createActionForm()

Posted by Martin Gainty <mg...@hotmail.com>.
Sheldon-
Let us know the solution 
Please reply offline
Regards,
Martin
----- Original Message ----- 
From: "Sheldon Hearn" <sh...@starjuice.net>
To: <st...@jakarta.apache.org>
Sent: Monday, December 15, 2003 9:56 AM
Subject: Re: NullPointerException from RequestUtils.createActionForm()


> On (2003/12/15 14:34), Sheldon Hearn wrote:
> 
> > I'm getting a NullPointerException from RequestUtils.createActionForm()
> > (full stack trace below).  I was originally trying to use a
> > DynaValidatorForm with several properties, but have now reduced the
> > problem to the simplest possible terms for reporting.
> 
> Well, I ripped my fledgeling application apart and started from scratch.
> And now it works.
> 
> So it _definitely_ was a stupid mistake on my part.  It'd be nice to
> know what I was doing wrong, but if your time is short, don't worry
> about trying to figure out what I did wrong.
> 
> Thanks,
> Sheldon.
> using 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 

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


Re: NullPointerException from RequestUtils.createActionForm()

Posted by Sheldon Hearn <sh...@starjuice.net>.
On (2003/12/15 14:34), Sheldon Hearn wrote:

> I'm getting a NullPointerException from RequestUtils.createActionForm()
> (full stack trace below).  I was originally trying to use a
> DynaValidatorForm with several properties, but have now reduced the
> problem to the simplest possible terms for reporting.

Well, I ripped my fledgeling application apart and started from scratch.
And now it works.

So it _definitely_ was a stupid mistake on my part.  It'd be nice to
know what I was doing wrong, but if your time is short, don't worry
about trying to figure out what I did wrong.

Thanks,
Sheldon.
using 

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