jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Massey <CMas...@corp.classmates.com>
Subject RE: IllegalStateException when testing Servlets which dispatch to JSP s.
Date Fri, 13 Sep 2002 20:08:09 GMT
Shriniwas,

My guess is that your TestControllerServlet is at fault.  Maybe it's
dispatching at the wrong time -- throwing the Cactus TestController off?
You say that you are successful in testing your TestSampleServlet, but this
uses a method that does not do any special dispatching to the JSP.  Can you
send me the source code for your TestControllerServlet class, and I'll try
to see what's happening.

Thanks,
Charley

-----Original Message-----
From: Wagle, Shriniwas [mailto:swagle@verisign.com]
Sent: Friday, September 13, 2002 11:56 AM
To: 'cactus-user@jakarta.apache.org'
Cc: 'Charles Massey'
Subject: IllegalStateException when testing Servlets which dispatch to
JSP s.


Charles,

Have been successful with using the TestSampleServlet and further testing of
my servlets with Dynamo 5.1.  I think I've been able to go past the dynamo
specific dependencies.  Thanks for your help.

These servlets that I've tested so far don't further dispatch to a JSP.

When I tried to test a servlet that dispatches to a JSP, I got an
java.lang.IllegalStateException.

I'm attaching the cactus_client.log.

Would very much appreciate any help.  Having spent substantial time on this,
this would probably be the last show-stopper issue.

Thanks
Shriniwas Wagle


> -----Original Message-----
> From: Charles Massey [mailto:CMassey@corp.classmates.com]
> Sent: Thursday, September 05, 2002 7:29 PM
> To: 'Wagle, Shriniwas'
> Subject: RE: NullPointerException at
> org.apache.cactus.server.AbstractWebT estC
> aller.doGetResults(AbstractWebTestCaller.java:196)
> 
> 
> Shriniwas,
> 
> We are using Nucleus components for our business logic, but 
> we are not using
> Nucleus components for our unit tests.  Since our business 
> logic is in our
> Nucleus components, we access these components in our unit tests.  Our
> Cactus unit test classes are created through the standard 
> methodology in the
> Cactus framework.
> 
> The web.xml file is deployed under our war-path, which is 
> where we put web
> application files such as JSPs.  In our Dynamo module path, 
> it's located in
> a system path that looks like this:
> 
> <module-name>/j2ee-apps/<module-name>/mymodule.war/WEB-INF
> 
> The section of xml that we put in our web.xml comes directly 
> from the Cactus
> Configuration guide.  Here it is:
> 
>   <servlet>
>     <servlet-name>
>       ServletRedirector
>     </servlet-name>
>     <servlet-class>
>       org.apache.cactus.server.ServletTestRedirector
>     </servlet-class>
>   </servlet>
>   <servlet>
>     <servlet-name>
>       JspRedirector
>     </servlet-name>
>     <jsp-file>
>       /jspRedirector.jsp
>     </jsp-file>
>   </servlet>
>   <servlet-mapping>
>     <servlet-name>
>       ServletRedirector
>     </servlet-name>
>     <url-pattern>
>       /ServletRedirector
>     </url-pattern>
>   </servlet-mapping>
>   <servlet-mapping>
>     <servlet-name>
>       JspRedirector
>     </servlet-name>
>     <url-pattern>
>       /JspRedirector
>     </url-pattern>
>   </servlet-mapping>
> 
> 
> Keep in mind that it has to be placed in the right area for 
> it to work.
> That is, it needs to be pasted between the correct xml 
> elements ... but
> Dynamo will complain when it starts up if it's not setup 
> right, so need to
> worry about this.  To verify where to paste this section in 
> your web.xml,
> consult the web-app_2_2.dtd file.
> 
> Let me know how this works for you.
> Charley
> 
> 
> -----Original Message-----
> From: Wagle, Shriniwas [mailto:swagle@verisign.com]
> Sent: Thursday, September 05, 2002 1:17 PM
> To: 'CMassey@corp.classmates.com'
> Subject: RE: NullPointerException at
> org.apache.cactus.server.AbstractWebT estC
> aller.doGetResults(AbstractWebTestCaller.java:196)
> 
> 
> 
> Charles,
> 
> Seems like you are using both Nucleus components as well as a 
> web.xml to
> deploy the same application.  Can you briefly describe how 
> you do that?  We
> are not currently using web.xml, though I've used web.xml to deploy
> applications on application servers other than Dynamo.  I'm 
> not familiar
> with the steps required for deploying applications using 
> web.xml on Dynamo.
> 
> Ofcourse I'm reading the manual also but some quick tips from 
> you would
> certainly help me speed up the process.
> 
> Thanks
> Shriniwas Wagle
> 
> > -----Original Message-----
> > From: Charles Massey [mailto:CMassey@corp.classmates.com]
> > Sent: Wednesday, September 04, 2002 12:48 PM
> > To: 'Cactus Users List'
> > Subject: RE: NullPointerException at
> > org.apache.cactus.server.AbstractWebT estC
> > aller.doGetResults(AbstractWebTestCaller.java:196)
> > 
> > 
> > Shriniwas,
> > 
> > Here's a little background for our implementation.  We use 
> > Dynamo Nucleus
> > components also, which means that a component will be tested in our
> > ServletTestCase class.  For our test class, we extend 
> > ServletTestCase and to
> > be able to test our component, we do a lookup for the 
> component we are
> > accessing.  Here is an example:
> > 
> >     public void setUp()
> >     {
> >         this.myComponentToTest = (ComponentToTest) 
> > getNucleusComponent(
> >            "/my_module_name/my_path/componentToTest");
> >     }
> > 
> >     public Object getNucleusComponent(String componentName)
> >     {
> >         return
> > atg.nucleus.Nucleus.getGlobalNucleus().resolveName(componentName);
> >     }
> > 
> > We don't, however, make our test classes Nucleus Components.  
> > That means
> > that we do not create configuration files for our test 
> > classes to make them
> > into components.  The reason is that we don't want the extra 
> > overhead and
> > maintanence that would occur by maintaining not only source 
> code, but
> > configuration files for all the tests too.  The other reason 
> > is that Cactus
> > uses the context class loader when the object is created on 
> > the server, so
> > it's most likely not going to use your test class component.
> > 
> > 
> > > in 5.1 we are using Dynamo Nucleus and the
> > > CONFIGPATH framework to integrate our applications into the Dynamo
> > > application server.  This is quite proprietary to Dynamo.  
> > This does not
> > > require the use of web.xml files, but has the concept of 
> > config files in
> > the
> > > CONFIGPATH (this is similar to the unix PATH variable)  
> > which look like
> > java
> > > properties files which map a servlet to a name.  But I've 
> > been able to set
> > > up it such that appropriate Servlets are being invoked.  Also, 5.1
> > supports
> > > Servlet spec 2.2.  So my feeling is that the basic 
> > requirements are being
> > > met.
> > 
> > > 2. I've gone through the Cactus Configuration guide and 
> semantically
> > mapped
> > > the web.xml to Dynamo proprietary setup.
> > 
> > We investigated at one time whether using Dynamo's 
> proprietary servlet
> > configuration would work for us, and found that it would 
> not work.  We
> > pretty much settled on using the instructions followed in the Cactus
> > Configuration document and set up our web.xml to map the 
> > ServletRedirector.
> > Since Dynamo 5.1 supports Servlet 2.2 I would suggest you try 
> > the setup as
> > described in the Cactus configuration guide.  You will also 
> > want to put the
> > cactus.jar, junit.jar and aspectjrt.jar in your MANIFEST.MF file.
> > 
> > 
> > > 3. Now coming to the use of the jsp, Dynamo 5.1 has a bug 
> > due to which if
> > a
> > > Servlet is directly invoked, any RequestDispatch.forward(.) 
> > calls from
> > > within the Servlet cause it to go into an infinite loop.  
> > But if a JSP is
> > > the primary recipient of the request which further hands 
> > over the request
> > > processing to the Servlet, that works fine.  Hence the JSP 
> > shows up in the
> > > middle.  The JSP code is very simple and is shown below.  
> > This code also
> > > shows how the Nucleus is used to get the servlet and hand over the
> > > processing to the servlet :
> > 
> > Try setting up the Cactus Redirectors in only your web.xml, 
> > and make sure
> > that Dynamo can pick up the cactus.jar, junit.jar, 
> > aspectjrt.jar and your
> > test classes path by adding them to your MANIFEST.MF file.  
> > See if this
> > works - if you continue to have servlet redirector problems, 
> > perhaps ATG can
> > provide you a patch to fix their bug.
> > 
> > Good luck and let us know how this works out.
> > 
> > Charley
> > 
> > 
> > -----Original Message-----
> > From: Wagle, Shriniwas [mailto:swagle@verisign.com]
> > Sent: Wednesday, September 04, 2002 7:40 AM
> > To: 'Cactus Users List'
> > Subject: RE: NullPointerException at
> > org.apache.cactus.server.AbstractWebT estC
> > aller.doGetResults(AbstractWebTestCaller.java:196)
> > 
> > 
> > Hi Charles,
> > 
> > Thanks for your response.
> > 
> > 1. We are still at Dynamo 5.1, as per the company policy.  
> > I'm not sure how
> > things work with 5.6.1, but in 5.1 we are using Dynamo 
> Nucleus and the
> > CONFIGPATH framework to integrate our applications into the Dynamo
> > application server.  This is quite proprietary to Dynamo.  
> > This does not
> > require the use of web.xml files, but has the concept of 
> > config files in the
> > CONFIGPATH (this is similar to the unix PATH variable)  which 
> > look like java
> > properties files which map a servlet to a name.  But I've 
> > been able to set
> > up it such that appropriate Servlets are being invoked.  
> > Also, 5.1 supports
> > Servlet spec 2.2.  So my feeling is that the basic 
> > requirements are being
> > met.
> > 
> > 2. I've gone through the Cactus Configuration guide and 
> > semantically mapped
> > the web.xml to Dynamo proprietary setup.
> > 
> > 3. Now coming to the use of the jsp, Dynamo 5.1 has a bug due 
> > to which if a
> > Servlet is directly invoked, any RequestDispatch.forward(.) 
> calls from
> > within the Servlet cause it to go into an infinite loop.  But 
> > if a JSP is
> > the primary recipient of the request which further hands over 
> > the request
> > processing to the Servlet, that works fine.  Hence the JSP 
> > shows up in the
> > middle.  The JSP code is very simple and is shown below.  
> > This code also
> > shows how the Nucleus is used to get the servlet and hand over the
> > processing to the servlet :
> > 
> > <%@ page import="org.apache.cactus.server.ServletTestRedirector" %>
> > 
> > <%!
> >    public static final String sccsID = "%TC-INFO%";
> >    final static String servletPath = 
> > "/craa/servlet/ServletRedirector" ;
> >    final static ServletTestRedirector servlet =
> > (ServletTestRedirector)Nucleus.getGlobalNucleus().resolveName(
> > servletPath);
> > // --- end of Declarations ---
> > %>
> > 
> > <% // --- main control begins here ---
> >    // Request dispatcher's forward method wasn't working if 
> > the servlet is
> > directly called with the current Dynamo version
> >    // So using the JSP Controller and calling the sevlet's 
> > service method
> > from JSP
> >    servlet.doGet(request,response);
> > %>
> > 
> > 4. The NullPointerException is occuring in the file
> > framework/src/java/share/org/apache/cactus/server/AbstractWebT
> > estCaller.java
> > at line number 196, so either the "writer" or the "result" or 
> > both are null.
> > :
> > 
> > 176      public void doGetResults() throws ServletException
> > 177      {
> > 178          // One could think there is a potential risk 
> > that the client
> > side of
> > 179          // Cactus will request the result before it has 
> > been written to
> > the
> > 180          // context scope as the HTTP request will not 
> > block in some
> > containers.
> > 181          // However this will not happend because on the 
> > client side,
> > once the
> > 182          // first request is done to execute the test, 
> > all the result is
> > read
> > 183          // by the AutoReadHttpURLConnection class, thus 
> > ensuring that
> > the
> > 184          // request is fully finished and the resukt has 
> > been committed
> > ...
> > 185
> > 186          WebTestResult result =
> > 187              (WebTestResult)
> > (this.webImplicitObjects.getServletContext().
> > 188              getAttribute(TEST_RESULTS));
> > 189
> > 190          LOGGER.debug("Test Result = [" + result + "]");
> > 191
> > 192          // Write back the results to the outgoing stream 
> > as an XML
> > string.
> > 193          try {
> > 194
> > 195              Writer writer = getResponseWriter();
> > 196              writer.write(result.toXml());
> > 197              writer.close();
> > 198
> > 199          } catch (IOException e) {
> > 200              String message = "Error writing 
> > WebTestResult instance to
> > output "
> > 201                  + "stream";
> > 202              LOGGER.error(message, e);
> > 203              throw new ServletException(message, e);
> > 204          }
> > 205      }
> > 
> > The final option for me would be to add some debug statements 
> > to the above
> > file around line 196 and do a build.  I'm not exactly sure 
> > how to do that
> > but I can't think of anything else now.
> > 
> > Thanks
> > Shriniwas Wagle
> > 
> > 
> > > -----Original Message-----
> > > From: Charles Massey [mailto:CMassey@corp.classmates.com]
> > > Sent: Tuesday, September 03, 2002 6:29 PM
> > > To: 'Cactus Users List'
> > > Subject: RE: NullPointerException at
> > > org.apache.cactus.server.AbstractWebT estC
> > > aller.doGetResults(AbstractWebTestCaller.java:196)
> > > 
> > > 
> > > Hi Shriniwas,
> > > 
> > > I'm using Dynamo - so I can probably help you here.  We're 
> > still using
> > > Cactus 1.3, and I haven't tried running Cactus 1.4 on Dynamo yet.
> > > 
> > > To start, you mention below that you are not following the 
> > > web.xml and .war
> > > format.  Does this mean that you are not declaring your <servlet>
> > > definitions in the web.xml file?  I have found that using 
> > the "Cactus
> > > Configuration" guide has helped a lot (
> > > http://jakarta.apache.org/cactus/howto_config.html ).  It 
> > is true that
> > > Dynamo uses .dar files to package files, but you may still 
> > > need to declare
> > > the ServletRedirector and/or JspRedirector in your web.xml if 
> > > you intend to
> > > use them.
> > > 
> > > Looking at the following section in your stack trace, what does
> > > servlet_redirector.jsp do?  It looks like it is throwing a
> > > NullPointerException in this code also (or from the servlet) ?
> > > 
> > > [/atg/dynamo/server/HttpServer-0:ipaddr=10.136.42.72;path=/en_
> > > US/servlet_tes
> > > t_runner.jsp;sessionid=4QWWRQKZKB12UCULHTOCFEQ] INFO  
> > httpclient.wire
> > > - << "<HEAD><TITLE>500 Internal Server Error</TITLE></HEAD>
> > > <H1>500 Internal Server Error</H1><BODY>
> > > The servlet invoked by the requested URL 
> > > //en_US/servlet_redirector.jsp
> > > raised the exception:<br><br>java.lang.NullPointerException<P>
> > > </BODY>
> > > " 
> > > 14:50:29,946
> > > [/atg/dynamo/server/HttpServer-0:ipaddr=10.136.42.72;path=/en_
> > > US/servlet_tes
> > > t_runner.jsp;sessionid=4QWWRQKZKB12UCULHTOCFEQ] DEBUG 
> > > httpclient.HttpMethod
> > > - HttpMethodBase.execute(): closing connection since we're 
> > > using HTTP/1.0 
> > > 14:50:29,947
> > > 
> > > 
> > > To help you further I need more information.  I have been 
> > > able to integrate
> > > Cactus 1.3 into Dynamo 5.6.1 by using the ServletRedirector 
> > > redirector and
> > > subclassing ServletTestCase for my tests.
> > > 
> > > Charley
> > > 
> > > 
> > > 
> > > -----Original Message-----
> > > From: Wagle, Shriniwas [mailto:swagle@verisign.com]
> > > Sent: Tuesday, September 03, 2002 12:36 PM
> > > To: 'cactus-user@jakarta.apache.org'
> > > Subject: NullPointerException at
> > > org.apache.cactus.server.AbstractWebTestC
> > > aller.doGetResults(AbstractWebTestCaller.java:196)
> > > 
> > > 
> > > I've recently started working with Cactus and after trying to 
> > > make it work
> > > over the last couple of days, I'm feeling rather stuck.  So 
> > > any help would
> > > be appreciated.  I apologize for the rather long traces.  I 
> > > hope they are of
> > > some help.
> > > 
> > > Environment :
> > > 	jakarta-cactus-12-1.4
> > > 	Dynamo Application Server 5.1 on SunOS 5.8
> > > 	jdk 1.2
> > > 
> > 
> > --
> > 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:   
> > <mailto:cactus-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: 
> > <mailto:cactus-user-help@jakarta.apache.org>
> > 
> 


--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message