Return-Path: Delivered-To: apmail-jakarta-cactus-user-archive@apache.org Received: (qmail 87523 invoked from network); 17 Apr 2002 23:20:42 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 17 Apr 2002 23:20:42 -0000 Received: (qmail 26779 invoked by uid 97); 17 Apr 2002 23:20:48 -0000 Delivered-To: qmlist-jakarta-archive-cactus-user@jakarta.apache.org Received: (qmail 26715 invoked by uid 97); 17 Apr 2002 23:20:47 -0000 Mailing-List: contact cactus-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Cactus Users List" Reply-To: "Cactus Users List" Delivered-To: mailing list cactus-user@jakarta.apache.org Received: (qmail 26704 invoked from network); 17 Apr 2002 23:20:47 -0000 X-MimeOLE: Produced By Microsoft Exchange V6.0.4712.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: NullPointerException from actionPerform method Date: Wed, 17 Apr 2002 16:20:40 -0700 Message-ID: <632632EC1CD3F248B630A527BC3D6B3D076FB4@sf-corp-exch-01.h5technologies.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: NullPointerException from actionPerform method Thread-Index: AcHmZJ9IDsD+L6E5QU6qE8DPMzmryQAAAtwg From: "Pavan Aripirala Venkata" To: "Cactus Users List" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Gopal,=09 I encountered the same problem. I sent an e-mail to Deryl. But no reply from him. Probably he is busy.=20 You get this problem if the action element, you are testing, in struts-config.xml does not contain the attribute "name". This is because in CactusStrutsTestCase.java, the code doesn't check for null value of 'mapping.getAttribute()' (which returns the value of the attribute : "name" (name is the attribute specifying the form name)).=20 I am attaching the entire e-mail that I sent Deryl (see at the end). The work around for this is I modified the CactusStrutsTestCase.java at the place where mapping.getAttribute() is supposed to be checked for null value i.e. I added if (mapping.getAttribute() !=3D null) { // This condition I added. if ("request".equals(scope)) { retForm =3D (ActionForm)getRequest().getAttribute(mapping.getAttribute()); } else if ("session".equals(scope)) { retForm =3D (ActionForm)getSession().getAttribute(mapping.getAttribute()); } setActionForm(retForm); } And it works! I suppose this is a bug. Please let me know if there is any mailing list for Cactus Struts tests in SourceForge. Pavan. Here is the e-mail ------------------------------------------------------------------------ ------------------ Hi Deryl, I am sending you this query because I don't know if there is any mailing list for Cactus Struts testing using the SourceForge's "strutstest.jar" (version 1.6). Please let me know if there is any mailing list and I'll post this there. Here is the problem, I am using CactusStrutsTestCase for testing our struts. We have in our struts-config.xml, one of the action elements without "name" attribute and without "scope" attribute. Example: When I test this action class, the actionPerform method in CactusStrutsTestCase.java is being executed and I receive a NullPointerException (approximate line number 384) at=20 String scope =3D mapping.getScope(); if ("request".equals(scope)) { retForm =3D (ActionForm)getRequest().getAttribute(mapping.getAttribute()); } else if ("session".equals(scope)) { -------> retForm =3D (ActionForm)getSession().getAttribute(mapping.getAttribute()); } setActionForm(retForm); because mapping.getAttribute() is null and value of the variable scope is "session", even though I don't have the "scope" attribute set. Question 1) Will the scope attribute defaults to session? (I don't know much about struts) Question 2) In the CactusStrutsTestCase.java the code does not check for null value of mapping.getAttribute(). However at around line 340, you check for null value of mapping.getAttribute() to get the ActionForm. So should there have been a if condition in CactusStrutsTestCase.java ? Thanks Deryl Pavan. ------------------------------------------------------------------------ ------------------ -----Original Message----- From: Gopal Ram [mailto:gramanuj2001@yahoo.com] Sent: Wednesday, April 17, 2002 4:07 PM To: cactus-user@jakarta.apache.org Subject: NullPointerException from actionPerform method Hi, My test case extends from CactusStrutsTestCase. When I run the test case , it redirects to the server and calls the actionPerform method. But before returning back to the Client it gives me a NullPointerException on the client side where I execute my test case. public void testXXX() { addRequestParameter("Action","init"); setRequestPathInfo("/s001.do"); actionPerform(); verifyForwardPath("success"); } java.lang.NullPointerException at java.util.Hashtable.get(Hashtable.java:320) at org.apache.tomcat.session.StandardSession.getAttribute(StandardSession.j ava:506) at servletunit.struts.CactusStrutsTestCase.actionPerform(CactusStrutsTestCa se.java:384) Can somebody tell me why is this happening ? I guess I have set up the cactus.properties file properly otherwise the server will not get the request itself? Thanks Gopal __________________________________________________ Do You Yahoo!? Yahoo! Tax Center - online filing with TurboTax http://taxes.yahoo.com/ -- To unsubscribe, e-mail: For additional commands, e-mail: -- To unsubscribe, e-mail: For additional commands, e-mail: