Return-Path: Delivered-To: apmail-jakarta-cactus-user-archive@apache.org Received: (qmail 58669 invoked from network); 20 Feb 2002 12:38:44 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 20 Feb 2002 12:38:44 -0000 Received: (qmail 17414 invoked by uid 97); 20 Feb 2002 12:38:41 -0000 Delivered-To: qmlist-jakarta-archive-cactus-user@jakarta.apache.org Received: (qmail 17301 invoked by uid 97); 20 Feb 2002 12:38:40 -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 28619 invoked from network); 20 Feb 2002 01:13:05 -0000 From: aslak.hellesoy@netcom.no To: Subject: Ant task bug (and fix) Date: Wed, 20 Feb 2002 02:12:59 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 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, 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. 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.java:16 2) at sun.net.www.http.ChunkedInputStream.prefill(ChunkedInputStream.java:187) at sun.net.www.http.ChunkedInputStream.(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(HttpURLConnection .java:506) at org.apache.cactus.ant.StartServerHelper.readFully(StartServerHelper.java:199 ) 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: I hope this patch makes sense to you, and that you can apply it. Cheers, Aslak -- To unsubscribe, e-mail: For additional commands, e-mail: