tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Goodenough <david.goodeno...@btconnect.com>
Subject Re: HttpUrlConnection.getInputStream() returns empty
Date Tue, 27 Jul 2004 12:59:41 GMT
I am hitting what looks like exactly the same problem.

I have a JSP application which uses the io tags to submit XMl requests to
a servlet running on the same machine.  The XML servlet carries on running
quite happily even once the errors start from the webUI which is the JSP bit.

Once the errors start first that user just locks up and can not continue until
Tomcat is restarted, then it spreads to all the other webUI users (but not the
direct XML users who are coming from outside Tomcat).

Moving from Tomcat4.1 to Tomcat5 made the problem a bit better, but did
not cure it.  With Tomcat4.1 the problem was never recoverable, but with 
Tomcat5 it does sometimes recover by itself.

Every now and then I get several responses back as one response, along with
a corresponding number of null responses.  The XML servlet logs all its 
transactions and always reports that it worked correctly by the way.

It occured to me that it might be because this is an https transaction, and
the logic that determines whether this is the same session might be getting
confused and multiple requests might be going though the same session at
once.  So I changes the servlet to accept an HTTP request if it came from 
localhost, hoping that the session would not be shared and that this would
cure the problem and I changed the JSP code to use http rather than https.
But it does not help, the problem still happens.

The next thing I am going to try is updating, to the latest 1.4.2 version,
the Sun SDK that I am using (I am currently using 1.4.1).  

Lets hope that between us we can get to the bottom of this.  This one is
driving me nuts.

David

On Monday 26 July 2004 19:15, Honey George wrote:
> Hi All,
>    I am facing a problem with HttpUrlConnection in
> Tomcat. I wanted to extract the contents of an https
> enabled URL,
> actually from the same site where my application is
> running(Will not try to access external URLs). My
> program will look
> like this.
>
> ===========================================================================
>======================================= import java.net.*;
> import java.util.*;
> import java.io.*;
>
> import javax.net.ssl.HostnameVerifier;
> import javax.net.ssl.HttpsURLConnection;
> import javax.net.ssl.SSLSession;
> import javax.net.ssl.*;
> .............
>
> System.getProperty("java.protocol.handler.pkgs","javax.net.ssl");
> java.security.Security.addProvider(new
> com.sun.net.ssl.internal.ssl.Provider());
> .................
>         HostnameVerifier hv = new HostnameVerifier()
>         {
>             public boolean verify(String urlHostName,
> SSLSession session)
>             {
>                 System.out.println("Warning: URL Host:
> "+urlHostName+" vs. "+session.getPeerHost());
>                 return true;
>             }
>         };
>
> HttpsURLConnection.setDefaultHostnameVerifier(hv);
>
>         // Create a trust manager that does not
> validate certificate chains
>         TrustManager[] trustAllCerts = new
> TrustManager[]{
>         new X509TrustManager() {
>             public
> java.security.cert.X509Certificate[]
> getAcceptedIssuers() {
>                 return null;
>             }
>             public void checkClientTrusted(
>                 java.security.cert.X509Certificate[]
> certs, String authType) {
>             }
>             public void checkServerTrusted(
>                 java.security.cert.X509Certificate[]
> certs, String authType) {
>             }
>         }
>         };
>
>         // Install the all-trusting trust manager
>         try
>         {
>             SSLContext sc =
> SSLContext.getInstance("SSL");
>             sc.init(null, trustAllCerts, new
> java.security.SecureRandom());
>
> HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
>         } catch (Exception e) {
>
>         }
>
> 	................................
>
>         HttpURLConnection httpCon =
>             (HttpURLConnection) new
> java.net.URL("https://www.abc.com/test.txt").openConnection();
>
> httpCon.setRequestProperty(USER_AGENT_HEADER_FIELD,
> "");
>
> httpCon.setRequestProperty(ACCEPT_HEADER_FIELD,
> "text/plain");
>         return httpCon;
>
> 	InputStream is = httpCon.getInputStream();
> ===========================================================================
>======================================= Here the problem is that the
> InputStream does not
> return any contents when executed from inside Tomcat.
> But I am able to
> extract the contents of the URL when I execute outside
> tomcat in a command line program. The Connection
> object returned
> by "new java.net.URL("https://www.abc.com/test.txt")"
> is sun.net.www.protocol.https.HttpsURLConnectionImpl.
>
> Can I get some help on this one?
>
> Thanks & Regards,
>    George
>
>
>
>
>
>
> ___________________________________________________________ALL-NEW Yahoo!
> Messenger - all new features - even more fun! 
> http://www.allnewmessenger.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message