You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Richard Suematsu <ri...@syncadd.com> on 2006/12/13 03:22:20 UTC
Java6
Hi,
Does anybody run HttpClient with Java 6? I'm running it with SSL and
with SocketFactoryWrapper. I'm running a WebStart application. I'm
getting the following error on the client.
Dec 12, 2006 4:16:21 PM org.apache.commons.httpclient.HttpMethodDirector
executeWithRetry
INFO: I/O exception (javax.net.ssl.SSLException) caught when processing
request: java.lang.NullPointerException
Dec 12, 2006 4:16:21 PM org.apache.commons.httpclient.HttpMethodDirector
executeWithRetry
javax.net.ssl.SSLException: java.lang.NullPointerException
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(Unknown Source)
at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(Unknown Source)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown Source)
at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
at java.io.BufferedOutputStream.flush(Unknown Source)
at
org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:827)
at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1975)
at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
at my.own.classes.i.probably.shouldnt.show
Caused by: java.lang.NullPointerException
at
com.sun.deploy.security.X509ExtendedDeployTrustManager.isSupportedAlgorithm(Unknown
Source)
at
com.sun.deploy.security.X509ExtendedDeployTrustManager.checkServerTrusted(Unknown
Source)
at
com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown
Source)
at
com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown
Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown
Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(Unknown
Source)
I'm getting this in the ssl.log on the server:
[Tue Dec 12 16:11:03 2006] [info] Connection to child 248 established
(server SERVER21:443, client 192.168.0.36)
[Tue Dec 12 16:11:03 2006] [info] Seeding PRNG with 136 bytes of entropy
[Tue Dec 12 16:11:03 2006] [info] SSL library error 1 in handshake
(server SERVER21:443, client 192.168.0.36)
[Tue Dec 12 16:11:03 2006] [info] SSL Library Error: 336151608
error:14094438:SSL routines:SSL3_READ_BYTES:tlsv1 alert internal error
[Tue Dec 12 16:11:03 2006] [info] Connection to child 248 closed with
abortive shutdown(server SERVER21:443, client 192.168.0.36)
I should also say that this works fine with a Java5 client. Any ideas?
--
Aloha,
Richard Suematsu
SynCaDD Systems, Inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: multipart post parameters?
Posted by da...@gmx.net.
That sounds good to me :)
Yes, HttpClient is and should be the only client.
Thanks a lot for your help.
Bastian
> Hello Bastian,
>
> > FilePart fPart = new FilePart(file.getName(), file);
> > StringPart sPart = new StringPart("MESSAGE", "UPLOAD");
> > Part[] parts = {sPart, fPart};
> >
> > postMethod.setRequestEntity(
> > new MultipartRequestEntity(parts, postMethod.getParams()));
> >
> > The servlet use org.apache.commons.fileupload to parse the files.
> > The usual way to get a message is not working with StringPart anymore
> >
> > request.getParameter("MESSAGE");
> >
> > I only found a solution like
> >
> > if(reqeust.getContenetType().equals( "multipart/form-data"))
> > // parse all form data from the upload and get the message
>
> That is correct. If you send multipart form data, you need
> to get the parameter values from the parsed multipart data.
> If the Servlet API would support multipart form data, the
> audience for commons-fileupload would be smaller, I guess :-)
>
> There is one trick which you can _only_ use if the HttpClient
> application is and will be the only client for your servlet.
> In that case, you can send the string parameter as a query
> string in the URL and use a FileRequestEntity instead of a
> multipart request entity. Then you don't need fileupload on
> the server, but the format is not compatible with browsers.
>
> > some logs without setting anything
>
> These look fine.
>
> > if I am add setContentChuck(true)it is a bit better
>
> These look fine, too. The only difference is that chunked
> encoding will buffer the data on the client side and send
> it out in bigger chunks. Hence you get fewer log messages.
>
> > maybe there is a better way to transfer a message to let the
> > server know an upload is comming? I am new in this stuff.
>
> What about encoding it in the URL?
> http://my.server.name/path/to/servlet/upload
>
> cheers,
> Roland
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
--
"Ein Herz für Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de
Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht!
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: multipart post parameters?
Posted by Roland Weber <ht...@dubioso.net>.
Hello Bastian,
> FilePart fPart = new FilePart(file.getName(), file);
> StringPart sPart = new StringPart("MESSAGE", "UPLOAD");
> Part[] parts = {sPart, fPart};
>
> postMethod.setRequestEntity(
> new MultipartRequestEntity(parts, postMethod.getParams()));
>
> The servlet use org.apache.commons.fileupload to parse the files.
> The usual way to get a message is not working with StringPart anymore
>
> request.getParameter("MESSAGE");
>
> I only found a solution like
>
> if(reqeust.getContenetType().equals( "multipart/form-data"))
> // parse all form data from the upload and get the message
That is correct. If you send multipart form data, you need
to get the parameter values from the parsed multipart data.
If the Servlet API would support multipart form data, the
audience for commons-fileupload would be smaller, I guess :-)
There is one trick which you can _only_ use if the HttpClient
application is and will be the only client for your servlet.
In that case, you can send the string parameter as a query
string in the URL and use a FileRequestEntity instead of a
multipart request entity. Then you don't need fileupload on
the server, but the format is not compatible with browsers.
> some logs without setting anything
These look fine.
> if I am add setContentChuck(true)it is a bit better
These look fine, too. The only difference is that chunked
encoding will buffer the data on the client side and send
it out in bigger chunks. Hence you get fewer log messages.
> maybe there is a better way to transfer a message to let the
> server know an upload is comming? I am new in this stuff.
What about encoding it in the URL?
http://my.server.name/path/to/servlet/upload
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
multipart post parameters?
Posted by da...@gmx.net.
hello,
I am using httpclient with a servlet and want to upload
a file.
I know that it is no good idea to mix "usual post" and "multipart/form-data".
The server has to get a message that let 'him' know an
upload is comming : e.g.
//client
FilePart fPart = new FilePart(file.getName(), file);
StringPart sPart = new StringPart("MESSAGE", "UPLOAD");
Part[] parts = {sPart, fPart};
postMethod.setRequestEntity(
new MultipartRequestEntity(parts, postMethod.getParams()));
The servlet use org.apache.commons.fileupload to parse the files.
The usual way to get a message is not working with StringPart anymore
request.getParameter("MESSAGE");
I only found a solution like
if(reqeust.getContenetType().equals( "multipart/form-data"))
// parse all form data from the upload and get the message
The wire logs from the httpClient looking a bit confuse
with "multipart/form-data".
I don't know if it has something to do that I forgot to
set something anywhere or if it is not possible to get
the message from a StringPart with request.getParameter.
------------------------------------------
some logs without setting anything
/2006-12-13 19:5?:??,??? DEBUG [AWT-EventQueue-0]// -- delete this
httpclient.wire.header: >> "Content-Type: multipart/form-data;
boundary=hT1l_nM1s2s3ba1eIkHmnKPtH2Q5Dyj8c[\r][\n]"
httpclient.wire.header: >> "[\r][\n]"
httpclient.wire.content: >> "--"
httpclient.wire.content: >> "hT1l_nM1s2s3ba1eIkHmnKPtH2Q5Dyj8c"
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "Content-Disposition: form-data; name="
httpclient.wire.content: >> """
httpclient.wire.content: >> "MESSAGE"
httpclient.wire.content: >> """
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "Content-Type: "
httpclient.wire.content: >> "text/plain"
httpclient.wire.content: >> "; charset="
httpclient.wire.content: >> "US-ASCII"
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "Content-Transfer-Encoding: "
httpclient.wire.content: >> "8bit"
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "UPLOAD"
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "--"
httpclient.wire.content: >> "hT1l_nM1s2s3ba1eIkHmnKPtH2Q5Dyj8c"
--------------------------
if I am add setContentChuck(true)it is a bit better
httpclient.wire.content: >> "Content-Disposition: form-data; name="MESSAGE"[\r][\n]"
httpclient.wire.content: >> "Content-Type: text/plain; charset=US-ASCII[\r][\n]"
httpclient.wire.content: >> "Content-Transfer-Encoding: 8bit[\r][\n]"
httpclient.wire.content: >> "[\r][\n]"
httpclient.wire.content: >> "UPLOAD[\r][\n]"
--------------------------
I also tried the following, but it wasn't working:
//client todo: delete
StringPart sPart = new StringPart("", "MESSAGE=UPLOAD");
logs :
httpclient.wire.content: >> "MESSAGE=UPLOAD[\r][\n]"
maybe there is a better way to transfer a message to let the
server know an upload is comming? I am new in this stuff.
thanks for help,
bastian
--
"Ein Herz für Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de
Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht!
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Java6
Posted by Julius Davies <ju...@gmail.com>.
Hi, Richard,
Maybe it's Java6 causing the problem? This looks suspicious:
Caused by: java.lang.NullPointerException
at
com.sun.deploy.security.X509ExtendedDeployTrustManager.isSupportedAlgorithm(Unknown
Source)
Can you recreate the problem outside of httpclient? (java.net.URL?) Try
some test code to exercise the HttpsURLConnection.getDefaultSSLSocketFactory
:
public static void main( String[] args ) throws Exception {
String host = args[ 0 ];
SSLSocketFactory sf = HttpsURLConnection.getDefaultSSLSocketFactory();
SSLSocket s = (SSLSocket) sf.createSocket();
InetSocketAddress target = new InetSocketAddress( host, 443 );
s.connect( target, 5000 ); // allow 5 seconds to connect
OutputStream out = s.getOutputStream();
InputStream in = s.getInputStream();
// Send HTTP "HEAD /" request.
StringBuffer buf = new StringBuffer();
buf.append( "HEAD / HTTP/1.1\n\r" );
buf.append( "Host: " + host + "\n\r" );
buf.append( "\n\r" ); // \n\r\n\r is HTTP's "message terminator"
out.write( buf.toString().getBytes( "UTF-8" ) );
out.flush();
// Read HTTP reply.
byte[] reply = new byte[2048];
int c = in.read( reply );
// Shut down socket.
out.close();
in.close();
s.close();
System.out.println( new String( reply, 0, c ) );
}
On 12/12/06, Richard Suematsu <ri...@syncadd.com> wrote:
>
> Hi,
>
> Does anybody run HttpClient with Java 6? I'm running it with SSL and
> with SocketFactoryWrapper. I'm running a WebStart application. I'm
> getting the following error on the client.
>
> Dec 12, 2006 4:16:21 PM org.apache.commons.httpclient.HttpMethodDirector
> executeWithRetry
> INFO: I/O exception (javax.net.ssl.SSLException) caught when processing
> request: java.lang.NullPointerException
> Dec 12, 2006 4:16:21 PM org.apache.commons.httpclient.HttpMethodDirector
> executeWithRetry
>
>
> javax.net.ssl.SSLException: java.lang.NullPointerException
> at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
> at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
> at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
> at
> com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(Unknown Source)
> at
> com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(Unknown Source)
> at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown Source)
> at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
> at java.io.BufferedOutputStream.flush(Unknown Source)
> at
> org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(
> HttpConnection.java:827)
> at
> org.apache.commons.httpclient.HttpMethodBase.writeRequest(
> HttpMethodBase.java:1975)
> at
> org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java
> :993)
> at
> org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(
> HttpMethodDirector.java:397)
> at
> org.apache.commons.httpclient.HttpMethodDirector.executeMethod(
> HttpMethodDirector.java:170)
> at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java
> :396)
> at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java
> :324)
> at my.own.classes.i.probably.shouldnt.show
> Caused by: java.lang.NullPointerException
> at
>
> com.sun.deploy.security.X509ExtendedDeployTrustManager.isSupportedAlgorithm
> (Unknown
> Source)
> at
> com.sun.deploy.security.X509ExtendedDeployTrustManager.checkServerTrusted
> (Unknown
> Source)
> at
> com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown
> Source)
> at
> com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown
> Source)
> at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
> at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown
> Source)
> at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown
> Source)
> at
> com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown
> Source)
> at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(Unknown
> Source)
>
>
> I'm getting this in the ssl.log on the server:
>
> [Tue Dec 12 16:11:03 2006] [info] Connection to child 248 established
> (server SERVER21:443, client 192.168.0.36)
> [Tue Dec 12 16:11:03 2006] [info] Seeding PRNG with 136 bytes of entropy
> [Tue Dec 12 16:11:03 2006] [info] SSL library error 1 in handshake
> (server SERVER21:443, client 192.168.0.36)
> [Tue Dec 12 16:11:03 2006] [info] SSL Library Error: 336151608
> error:14094438:SSL routines:SSL3_READ_BYTES:tlsv1 alert internal error
> [Tue Dec 12 16:11:03 2006] [info] Connection to child 248 closed with
> abortive shutdown(server SERVER21:443, client 192.168.0.36)
>
>
> I should also say that this works fine with a Java5 client. Any ideas?
>
> --
> Aloha,
> Richard Suematsu
> SynCaDD Systems, Inc.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
--
yours,
Julius Davies
416-652-0183
http://juliusdavies.ca/