You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Alan Halley <al...@yahoo.com> on 2002/03/19 12:29:54 UTC

Re: struts testcase... NullPointerException...

 Hi,
In my case the problem was caused by the default validation routine in ActionForm. If this method is not overidden in your code then the default method returns a null and this seems to be th root of the null pointer problem.
I overrode this method as follows:-
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request)
{
 return new ActionErrors();
}
This appeared to cure the problem.
Alan
 
  vishal kumar singh <vi...@cisco.com> wrote: Bala,
This error might be becaue in ur struts-config.xml u have not specified the
form bean.
In ur 
u have the logical name for Form bean for that Action class

Check inside the tag

whether the form bean for the request is there or not.

Form Bean bein g accessed and given null pointer can be because it is not
populated when the form is submitted. This can occur because u might not have
associated the form bean with the request in struts config file and only
associate the request with action class or Maybe u have not given the complete
name inclufin gpackage name /relative name whatever u are using.

regards
Vishal


Vincent Massol wrote:

> Bala,
>
> Apparently you're not the only one having this problem. I have seen the
> same issue being raised. I don't know the answer as I've not used
> StrutsTestCase. Maybe you could also post the question on the
> StrutsTestCase forum/mailing-list on SourceForge (I don't know if
> there's any but there might be).
>
> Also, you might have some luck on the Struts users mailing list.
>
> Alternatively, if you don't get any answer, you can also debug the
> problem and submit a patch ;-)
>
> Good luck,
> -Vincent
>
> > -----Original Message-----
> > From: BALA KRISHNA [mailto:ebalki2002@yahoo.com]
> > Sent: 27 February 2002 23:17
> > To: cactus-user@jakarta.apache.org
> > Subject: struts testcase... NullPointerException...
> >
> > Hi,
> >
> > I am not sure if this is the place to post this...
> >
> > I am testing struts action classes using
> > strutstestcase1.5 (servlet2.2) with cactus 1.2.
> >
> > The test class extends CactusStrutsTestCase. I get the
> > following error. Can anyone explain me what is that I
> > am not doing right.
> >
> > =========================
> >
> > Testcase: testSuccessfulLogin took 4.306 sec
> > Caused an ERROR
> > null
> > java.lang.NullPointerException
> > at
> >
> servletunit.struts.CactusStrutsTestCase.actionPerform(CactusStrutsTestCa
> se
> > .java:213)
> > ...
> >
> > ==========================
> >
> > The login action class that I am testing has a
> > associated loginform bean. This error is occuring only
> > when I test this action class that has a associated
> > actionform bean. My other action classes tests work
> > fine.
> >
> >
> > Thanks,
> > balki
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Greetings - Send FREE e-cards for every occasion!
> > http://greetings.yahoo.com
> >
> > --
> > To unsubscribe, e-mail: > > unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: > > help@jakarta.apache.org>
> >
>
> --
> To unsubscribe, e-mail: 
> For additional commands, e-mail: 


--
To unsubscribe, e-mail: 
For additional commands, e-mail: 



---------------------------------
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage

Re: struts testcase... NullPointerException...

Posted by Alan Halley <al...@yahoo.com>.
 Hi Deryl,
It's not causing me any great issue at the moment (on 1.5) so no panic for the patch.
Alan
 
  Deryl Seale <de...@acm.org> wrote: You should not have to change the code to test it,
it's true. And this should be fixed in the 1.6
version of StrutsTestCase -- specifically, addressing
the perfectly valid case when validate() returns
a null value.

If it is not fixed, or if you guys are using v1.5,
let me know, and I'll post a patch. I'm sorry to
be so absent, but my job is kicking my ass right
now.

-d.

On Tue, 19 Mar 2002 11:45:00 -0800 (PST), BALA KRISHNA wrote:
>
>Hi Alan,
>
>Thanks for the solution. My problem too got solved
>when I override the validate function in the action
>form. But I have a question:
>
>1. Why should one change the actual code for the sole
>reason of being able to test it? The application works
>fine even if "validate" method is not there.
>
>Thanks,
>balki
>
>
>--- Alan Halley wrote:
>>
>>Hi,
>>In my case the problem was caused by the default
>>validation routine in ActionForm. If this method is
>>not overidden in your code then the default method
>>returns a null and this seems to be th root of the
>>null pointer problem.
>>I overrode this method as follows:-
>>public ActionErrors validate(ActionMapping
>>mapping,HttpServletRequest request)
>>{
>>return new ActionErrors();
>>}
>>This appeared to cure the problem.
>>Alan
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Sports - live college hoops coverage
>http://sports.yahoo.com/
>
>--
>To unsubscribe, e-mail: >unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: >help@jakarta.apache.org>
>




--
To unsubscribe, e-mail: 
For additional commands, e-mail: 



---------------------------------
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage

Re: struts testcase... NullPointerException...

Posted by Deryl Seale <de...@acm.org>.
You should not have to change the code to test it,
it's true.  And this should be fixed in the 1.6
version of StrutsTestCase -- specifically, addressing
the perfectly valid case when validate() returns
a null value.

If it is not fixed, or if you guys are using v1.5,
let me know, and I'll post a patch.  I'm sorry to
be so absent, but my job is kicking my ass right
now.

-d.

On Tue, 19 Mar 2002 11:45:00 -0800 (PST), BALA KRISHNA wrote:
>
>Hi Alan,
>
>Thanks for the solution. My problem too got solved
>when I override the validate function in the action
>form. But I have a question:
>
>1. Why should one change the actual code for the sole
>reason of being able to test it? The application works
>fine even if "validate" method is not there.
>
>Thanks,
>balki
>
>
>--- Alan Halley <al...@yahoo.com> wrote:
>>
>>Hi,
>>In my case the problem was caused by the default
>>validation routine in ActionForm. If this method is
>>not overidden in your code then the default method
>>returns a null and this seems to be th root of the
>>null pointer problem.
>>I overrode this method as follows:-
>>public ActionErrors validate(ActionMapping
>>mapping,HttpServletRequest request)
>>{
>>return new ActionErrors();
>>}
>>This appeared to cure the problem.
>>Alan
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Sports - live college hoops coverage
>http://sports.yahoo.com/
>
>--
>To unsubscribe, e-mail:   <mailto:cactus-user-
>unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:cactus-user-
>help@jakarta.apache.org>
>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: struts testcase... NullPointerException...

Posted by BALA KRISHNA <eb...@yahoo.com>.
Hi Alan,

Thanks for the solution. My problem too got solved
when I override the validate function in the action
form. But I have a question:

1. Why should one change the actual code for the sole
reason of being able to test it? The application works
fine even if "validate" method is not there.

Thanks,
balki


--- Alan Halley <al...@yahoo.com> wrote:
> 
>  Hi,
> In my case the problem was caused by the default
> validation routine in ActionForm. If this method is
> not overidden in your code then the default method
> returns a null and this seems to be th root of the
> null pointer problem.
> I overrode this method as follows:-
> public ActionErrors validate(ActionMapping
> mapping,HttpServletRequest request)
> {
>  return new ActionErrors();
> }
> This appeared to cure the problem.
> Alan
>  


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>