jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@octo.com>
Subject RE: Ant task bug (and fix)
Date Tue, 26 Feb 2002 20:21:08 GMT
Aslak,

Ok. I've had some similar issue today at work ... I'm still looking into
it (I'm still not completely sure the problem was with cactus or with my
scripts).

Here is my scenario : A webapp with no JSP pages (only servlets)

Thus, the only URL to use as testURL that makes sense is
http://localhost:port/testcontext/ServletRedirector?Cactus_Service=RUN_T
EST. Indeed all of our other servlets trigger some business logic ...

However, the URL I've given above does not return anything (no HTTP
response). Thus I guess that the readFully() in StartServerHelper fails
...

There are 2 solutions :
1/ Implement the solution I'm using in AutoReadHttpURLConnection to
verify if there is something returned before reading,

or

2/ Make sure that the RUN_TEST service returns some string ...

I'll try to implement solution 1/ tonight as it seems to be the most
generic solution. I guess that it will also solve your problem (which
looks the same to me).

Just wanted to let you know ahead.
Thanks
-Vincent


> -----Original Message-----
> From: Vincent Massol [mailto:vmassol@octo.com]
> Sent: 25 February 2002 20:39
> To: 'Cactus Users List'
> Subject: RE: Ant task bug (and fix)
> 
> Hi Aslak
> 
> > -----Original Message-----
> > From: aslak.hellesoy@netcom.no [mailto:aslak.hellesoy@netcom.no]
> > Sent: 20 February 2002 01:13
> > To: cactus-user@jakarta.apache.org
> > Subject: Ant task bug (and fix)
> >
> > Hi!
> >
> > First, thanks for a great product!
> >
> > I have discovered an issue related to the Cactus Ant task which
occurs
> > when
> > I'm using Cactus with a clean Container with nothing deployed.
> 
> Since there is nothing, how can you expect to test it ! ;-). The
normal
> sequence of events is :
> 1/ deploy the application to the container
> 2/ start the container (and check for existence for URL)
> 
> Or are you testing dynamic deployment ? :-)
> 
> > Since there
> > is nothing in the container I'm forced to set testURL to something
that
> > doesn't exist, and the HTTP result is a 404. As far as I understand,
the
> > purpose of the testURL is only to ping,
> 
> It is a little more than that. It is to actually verify the container
is
> ready to serve requests for your given webapp. To be perfectly correct
the
> testURL should actually point to one of the cactus redirector that
you're
> using (using the TEST service, i.e.
>
http://localhost:8080/mycontext/ServletRedirector?Cactus_Service=RUN_TES
T)
> .  Note that I haven't tested this though ... :-). I should and I will
> that I'm remembering this feature ...
> 
> BTW we'll need to improve the FAQ to include this (instead of asking
users
> to use http://localhost:8080/mycontext/ServletRedirector which returns
a
> 5xx error because it is missing the needed HTTP parameter and thus the
> code throws a ServletException).
> 
> > and IMO, a 404 is a good enough
> > result for a ping. If you get a 404, at least you know the server is
> > running.
> 
> Yes, but can we tell for sure it is able to service requests ? If that
> were true for all servers then we could certainly use
> testURL=http://localhost:8080 for all cases, couldn't we ?
> 
> >
> > The problem is in the
> > org.apache.cactus.ant.StartServerHelper.readFully(HttpURLConnection
> > connection) method. If the testURL returns a 404, here is what
happens:
> > java.lang.NullPointerException
> >    at
> >
>
sun.net.www.http.ChunkedInputStream.readChunkSize(ChunkedInputStream.jav
a:
> > 16
> > 2)
> >    at
> >
sun.net.www.http.ChunkedInputStream.prefill(ChunkedInputStream.java:187)
> >    at
> >
sun.net.www.http.ChunkedInputStream.<init>(ChunkedInputStream.java:94)
> >    at
sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:749)
> >    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:613)
> >    at
> >
>
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnec
ti
> > on
> > .java:506)
> >    at
> >
>
org.apache.cactus.ant.StartServerHelper.readFully(StartServerHelper.java
:1
> > 99
> > )
> >
> > I would consider this to be a bug in the sun libraries, but it can
be
> > worked
> > around in cactus:
> >
> > I have modified the readFully method, and now it works as a charm:
> >
> > static void readFully(HttpURLConnection connection) throws
IOException
> > {
> >    // finish reading it to prevent (harmless) server-side exceptions
> >    try {
> >       BufferedInputStream is =
> >          new BufferedInputStream(connection.getInputStream());
> >    byte[] buffer = new byte[256];
> >    while((is.read(buffer)) > 0) {}
> >    is.close();
> >    } catch( NullPointerException e ) {
> >       // Server responded, but there was nothing to read. At least
> server
> > is
> > running.
> >    }
> > }
> > Here is a sniplet of my Ant script:
> >
> >    <target
> >       name="cactus.junit-report"
> >       description="Generates test reports with Cactus"
> >       depends="cactus.client-properties"
> >       if="junit.on"
> >    >
> >       <taskdef name="cactus"
> > classname="org.apache.cactus.ant.RunServerTestsTask"/>
> >       <cactus
> >          testURL="${cactus.url}"
> >          startTarget="weblogic.start"
> >          testTarget="cactus.deploy-test-delete"
> >          stopTarget="weblogic.stop"
> >       />
> >    </target>
> >
> >    <target name="cactus.deploy-test-delete"
> > depends="weblogic.deploy,common.junit-report,weblogic.delete"/>
> >
> > I hope this patch makes sense to you, and that you can apply it.
> >
> 
> I am willing to apply the patch, although I don't fully understand
your
> reason to testing with an empty container (unless you're doing dynamic
> deployment).
> 
> 
> > Cheers,
> > Aslak
> 
> Thanks
> -Vincent
> 
> >
> >
> > --
> > 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