Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Uncaught Throwable in processSockets

342 views
Skip to first unread message

Khalid

unread,
Apr 26, 2001, 6:05:13 PM4/26/01
to

Hello Guys, I need help.
I am uploading a file and using getInputStream
read it and the want to forward the contents of the file to another class for
further processing.
below is the piece of code that actually reads the file

if(req.getContentType().startsWith("multipart/form-data")){
String inline1="",inline2="",inline="";
try{

ServletInputStream sis= req.getInputStream();
int len =req.getContentLength();
System.err.println("InputStream length:"+len);
byte b[] = new byte[len];
sis.read(b,0,len);

int x=0;
do {
inline+=(char)b[x];x++;
}while(x<len);
sis.close();

}catch (SocketException se) {
System.err.println("SocketException caught :"+se.getMessage());
}
catch (Exception e) {
System.err.println("Exception caught:"+e.getMessage());
}

System.err.println(inline);
inline="";

please overlook any perenthesis missing or a comma here.
My problem is the code above works great with tomcat, but when I use it with weblogic
6.0sp1 it just crashes in the middle of reading and gives me the following error

<Apr 26, 2001 2:33:43 PM GMT-06:00> <Error> <Posix Performance Pack> <Uncaught
Throwable in processSockets
java.lang.NullPointerException
at weblogic.socket.TunnelContext.getServlet(TunnelContext.java:24)
at weblogic.servlet.internal.MuxableSocketHTTP.dispatch(MuxableSocketHTTP.java:465)
at weblogic.socket.PosixSocketMuxer.deliverGoodNews(PosixSocketMuxer.java:449)
at weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:378)
at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:23)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

I am stuck with this problem for last 2 days I will be very much obliged if some
one could please help me.

Xiang Rao

unread,
Apr 26, 2001, 9:42:31 PM4/26/01
to

Can you use while loop (don't use content_length as condition, instead, use EOF
or inputstream close) to read your input instead of one sis.read(b,0,len)? There
is no guranttee you can get exact "len" bytes of data. The implication is that
you could close your stream before you finish reading. On the other hand, you
shouldn't use "inline+=(char)b[x];x++" to restore your data. If your file size
is 1M, you will create countless (at least 2M) String objects. You can use one
line of code to add all your input to "inline" with "inline = inline + (new String(b,
0, len))", here "len" should be the exact length of data.

This afternoon, I just wrote a servlet with a help classes to process File Upload
on Weblogic 6 SP1 on W2k. I don't have any problem with my coding style.

Hope it helps.

0 new messages