tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ulrich Knecht <kne...@thales.de>
Subject mod_webapp and binary contents
Date Thu, 04 Oct 2001 14:00:45 GMT
Hello,

	I'm currently trying to migrate my project from tomcat 3.2.3 to tomcat
4.0. We're using Apache 1.3.20 as frontend. So far we've used mod_jk
with ajp13 to connect apache and tomcat. Our server is a Linux x86
machine running Suse 7.2, kernel 2.4.5. We're using jdk 1.3.1_01 from
sun. I have sucessfully built and installed mod_webapp and everything
seems to work okay except for two servlets that receive large amounts of
data via HTTP POST: One is retrieving multipart form messages which are
being parsed with the MultipartParser class from the com.oreilly.servlet
package (thanks to Jason Hunter ;-) ), the other talks to an applet and
retrieves a serialized java object via an ObjectInputStream. 

 Both servlets work fine, as long as the data being retrieved just
contains printable characters. However, if I try to send "binary" data
(gifs, jpegs, M$-Excel files e.g.), the communication fails with an
exception on the server side. I had a similar problem with a previous
version of ajp13 which seems to be solved since tomcat 3.2.3 (this one
is also documented in Jason Hunter's bugs faq on www.servlets.com). 

 I would really be thankful for any help on this topic.

	Ulrich Knecht



Further details:

The servlet using multipart forms fails when reading a file part. The
code fragment in question and the exception I get are, respectively (The
parameter that gets passed as 'is' is the output of
FilePart.getInputStream()):

public void  getDataContent(InputStream is)
    throws IOException
{
    contents         = new byte[131071];
    long bytes_read  = 0;
    int  length      = 0;
    
    while(-1 != (bytes_read = is.read(contents, 
				      length, 
				      contents.length - length)))  // <- line 141
    {
      length += bytes_read;

      if(length >= contents.length)
      {
	// Speicherplatz erweitern
 	byte[] buffer = new byte[contents.length + 131071];
	
	for(int j = 0; j < length; j++)
	{
	  buffer[j] = contents[j];
	}

 	contents = buffer;
      }
    }
    
    file_size = length;
}

2001-09-28 15:45:54 ASKMessageServlet: java.io.IOException: unexpected
end of part
java.io.IOException: unexpected end of part
        at java.lang.Throwable.<init>(Throwable.java:96)
        at java.lang.Exception.<init>(Exception.java:44)
        at java.io.IOException.<init>(IOException.java:49)
        at
com.oreilly.servlet.multipart.PartInputStream.fill(PartInputStream.java:95)
        at
com.oreilly.servlet.multipart.PartInputStream.read(PartInputStream.java:178)
        at
de.thales.paddialog.entity.ASKAttachment.getDataContent(ASKAttachment.java:141)
        at
de.thales.paddialog.servlet.ASKMessageServlet.storeMessageMultipart(ASKMessageServlet.java:723)
        at
de.thales.paddialog.servlet.ASKMessageServlet.doHandle(ASKMessageServlet.java:163)
        at
de.thales.paddialog.servlet.PADWMUserSessionServlet.handle(PADWMUserSessionServlet.java:182)
        at org.webmacro.servlet.WMServlet.doRequest(WMServlet.java:269)
        at org.webmacro.servlet.WMServlet.doPost(WMServlet.java:220)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown
Source)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown Source)
        at org.apache.catalina.core.StandardWrapperValve.invoke(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invoke(Unknown
Source)
        at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
        at org.apache.catalina.core.StandardContextValve.invoke(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invoke(Unknown
Source)
        at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
        at org.apache.catalina.core.StandardContext.invoke(Unknown
Source)
        at org.apache.catalina.core.StandardHostValve.invoke(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invoke(Unknown
Source)
        at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
        at org.apache.catalina.core.StandardEngineValve.invoke(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invoke(Unknown
Source)
        at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
        at
org.apache.catalina.connector.warp.WarpRequestHandler.handle(Unknown
Source)
        at org.apache.catalina.connector.warp.WarpConnection.run(Unknown
Source)
        at java.lang.Thread.run(Thread.java:498)


The servlet talking to the applet fails when reading from an
ObjectInputStream. The respective code fragment and exception are:

public Template handle(WebContext context) 
    throws HandlerException
{

  ...

      ObjectInputStream objin = new
ObjectInputStream(context.getRequest().getInputStream());
      PADData data  = (PADData)objin.readObject();  // <-- line 104
  ...
}   


2001-09-28 16:38:30 PADOnlineServlet: java.io.EOFException
java.io.EOFException
        at java.lang.Throwable.<init>(Throwable.java:84)
        at java.lang.Exception.<init>(Exception.java:35)
        at java.io.IOException.<init>(IOException.java:37)
        at java.io.EOFException.<init>(EOFException.java:45)
        at java.io.DataInputStream.readFully(DataInputStream.java:168)
        at
java.io.ObjectInputStream.readFully(ObjectInputStream.java:2076)
        at
java.io.ObjectInputStream.inputArray(ObjectInputStream.java:1064)
        at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:380)
        at
java.io.ObjectInputStream.inputClassFields(ObjectInputStream.java:2268)
        at
java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:525)
        at
java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1417)
        at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:392)
        at
java.io.ObjectInputStream.readObject(ObjectInputStream.java:242)
        at
de.thales.paddialog.servlet.PADOnlineServlet.handle(PADOnlineServlet.java:104)
        at org.webmacro.servlet.WMServlet.doRequest(WMServlet.java:269)
        at org.webmacro.servlet.WMServlet.doPost(WMServlet.java:220)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown
Source)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown Source)
        at org.apache.catalina.core.StandardWrapperValve.invoke(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invoke(Unknown
Source)
        at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
        at org.apache.catalina.core.StandardContextValve.invoke(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invoke(Unknown
Source)
        at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
        at org.apache.catalina.core.StandardContext.invoke(Unknown
Source)
        at org.apache.catalina.core.StandardHostValve.invoke(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invoke(Unknown
Source)
        at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
        at org.apache.catalina.core.StandardEngineValve.invoke(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown
Source)
        at org.apache.catalina.core.StandardPipeline.invoke(Unknown
Source)
        at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
        at
org.apache.catalina.connector.warp.WarpRequestHandler.handle(Unknown
Source)
        at org.apache.catalina.connector.warp.WarpConnection.run(Unknown
Source)
        at java.lang.Thread.run(Thread.java:498)
 
2001-09-28 16:38:36 [org.apache.catalina.connector.warp.WarpConnection]
Exception on socket
java.io.IOException: Premature packet header end
        at java.lang.Throwable.<init>(Throwable.java:96)
        at java.lang.Exception.<init>(Exception.java:44)
        at java.io.IOException.<init>(IOException.java:49)
        at
org.apache.catalina.connector.warp.WarpConnection.recv(Unknown Source)
        at
org.apache.catalina.connector.warp.WarpRequestHandler.handle(Unknown
Source)
        at org.apache.catalina.connector.warp.WarpConnection.run(Unknown
Source)
        at java.lang.Thread.run(Thread.java:498)

Mime
View raw message