tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MAHAINDRA Ketut" <ketut.mahain...@gemalto.com>
Subject SOLVED: Problem with mod_jk / tomcat on file streaming
Date Mon, 11 Jun 2007 02:17:17 GMT
Hi all,

I managed to solve the problem.
The problem was identified as a problem in tomcat-native 1.1.7 and
below.
The corresponding bug report is:
http://issues.apache.org/bugzilla/show_bug.cgi?id=41124

After deploying the latest tomcat-native (1.1.10) at the time of writing
this mail, the problem disappears.
Thanks to Haroon Rafique for pointing this out.

-- 
Best regards,
 
Ketut Mahaindra (Ito)


-----Original Message-----
From: MAHAINDRA Ketut [mailto:ketut.mahaindra@gemalto.com] 
Sent: Friday, June 01, 2007 3:42 PM
To: users@tomcat.apache.org
Subject: Problem with mod_jk / tomcat on file streaming

Hello all,

 

I have a problem when using Tomcat 5.5.23 and apache/mod_jk 1.2.23.

I have a piece of code that will stream a file when a download request
is made by a user.

 

...

response.setContentType("application/octet-stream");

response.setContentLength((int)fDownload.length());

response.setHeader("Content-Disposition", "attachment; filename=\"" +
fromFileName + "\"");

 

// read the fromFile and write to output stream

FileInputStream  fis = new FileInputStream(location + "/" +
fromFileName);   //$NON-NLS-1$

BufferedOutputStream bos = new
BufferedOutputStream(response.getOutputStream());  

int iLen =0;

byte[]  buffer  =  new  byte[4096];             

while  ((iLen = fis.read(buffer))  !=  -1)  {  

    bos.write(buffer,0,iLen);

}

fis.close();  

bos.close();

...

 

When the application is accessed directly through Tomcat on port 8080,
there is no problem.

But when we put apache / mod_jk to provide connection to tomcat, the
stream is disconnected prematurely at around 450K with the following
exceptions logged in catalina.out.

 

ClientAbortException:  java.io.IOException

        at
org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.j
ava:366)

        at
org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:432)

        at
org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:347)

        at
org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:
392)

        at
org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)

        at
org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStrea
m.java:89)

        at
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)

        at
java.io.BufferedOutputStream.write(BufferedOutputStream.java:109)

        at
com.gemalto.tools.lkms.actions.ManageVersionAction.downloadFile(Unknown
Source)

        at
com.gemalto.tools.lkms.actions.ManageVersionAction.execute(Unknown
Source)

        at
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAc
tion.java:58)

        at
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractE
xecuteAction.java:67)

        at
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommand
Base.java:51)

        at
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)

        at
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.jav
a:304)

        at
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)

        at
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableReq
uestProcessor.java:283)

        at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)

        at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:269)

        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:188)

        at
com.gemalto.tools.lkms.util.SetCharacterEncodingFilter.doFilter(Unknown
Source)

        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:215)

        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:188)

        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:210)

        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:174)

        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:127)

        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:117)

        at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:542
)

        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:108)

        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1
51)

        at
org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:444)

        at
org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpApr
Protocol.java:472)

        at
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286)

        at java.lang.Thread.run(Thread.java:595)

Caused by: java.io.IOException

        at
org.apache.coyote.ajp.AjpAprProcessor.flush(AjpAprProcessor.java:1197)

        at
org.apache.coyote.ajp.AjpAprProcessor$SocketOutputBuffer.doWrite(AjpAprP
rocessor.java:1282)

        at org.apache.coyote.Response.doWrite(Response.java:560)

        at
org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.j
ava:361)

        ... 36 more

 

 

Is there any issue on the code ?

Or is it a known mod_jk issue ? Or is it perhaps a configuration issue
on my side ?

 

-- 

Best regards,

 

Ketut Mahaindra (Ito)

 

 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message