You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Graham Freeman <g-...@adfa.edu.au> on 2003/04/23 02:18:06 UTC
Help! CGI unreliable under Tomcat
(This message was sent last week, without reply.)
I have successfully installed Tomcat 4.1.24 on port 80 on a Linux box,
with it processing JSP and servlets without error. I have set up a
simple CGI demonstration and enabled CGI in a container. I am observing
unpredictable behaviour. Sometimes (30% of the time) the CGI program
generates a successful response. On all other occasions, the web page
generated is
HTTP Status 500
Exception report
The server encountered an internal error () that prevented it from
fulfilling this request.
java.io.IOException: Broken pipe
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:257)
at
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:69)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:127)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:128)
at
org.apache.catalina.servlets.CGIServlet$CGIRunner.run(CGIServlet.java:1683)
at org.apache.catalina.servlets.CGIServlet.doGet(CGIServlet.java:635)
at org.apache.catalina.servlets.CGIServlet.doPost(CGIServlet.java:597)
...
I understand that messages like this reported in a log file indicate
that connection to the client was lost. This does not seem to be the
case here; the client also receives this "broken pipe" message.
Has anyone else observed this problem and found a way around it?
The only connector I am using is the tomcat4.CoyoteConnector.
The CGI servlet is org.apache.catalina.servlets.CGIServlet.
The CGI program is a 4-line shell script.
#!/bin/sh
echo Content-type: text/html
echo
echo CGI is working fine
--
------------------------------------------------------------------------
Dr Graham Freeman g-freeman@adfa.edu.au
School of Computer Science Phone +61-2-6268 8186
Australian Defence Force Academy Fax +61-2-6268 8581
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Help! CGI unreliable under Tomcat
Posted by Marc Chamberlin <ma...@easystreet.com>.
Graham -
I recently posted a request to this group requesting help installing Bugzilla on a Linux box using Tomcat as the server. I got one
reply which essentially said this was not a good idea, but that was an inappropriate answer for our situation. Anywise, like you, we
faced a lot of CGI/Tomcat issues because Bugzilla is based on a lot of Perl CGI scripts. So we have forged ahead and now got it
working and I will describe what we found and did below. Some of this may apply to you, and some of this might be of interest to the
Tomcat developers. In addition to what I describe below, we had to change the CGIServlet.java file and I have attached it to this
email.
Bugzilla and Tomcat's CGI-bin servlet don't get along with each other without mods.
The issues that we ran into:
1) bugzilla depends on apache's ability to have different behaviors for the files in the same directory based on file extension.
Especially, it depends on some files having content to be provided according to mime type, and other files to be executed to create
HTML at standard out.
2) tomcat's cgibin behavior provided by CGIServlet.java does not provide for different behaviors as in (1) above.
3) tomcat's cgibin seems to have used perl as a replacement for the natural behaviors of exec() in unix. My suspicion is that this
was done to make cgibin easier for people using perl under Windows. The problem is that when Perl is invoked by Perl, it cannot add
certain behaviors -- specifically, cannot add "Templates" with a "-T" option. Thus the bugzilla scripts that depend on "-T" must be
invoked directly, not by a parent perl "shell".
Solution:
1) to eliminate issue (3) above, CGIServlet.java was modified so that when it builds a command to execute, it does not change the
cgi commands from
<command> <arg1> <arg2> ... <argn>
to
perl <command> <arg1> <arg2> ... <argn>
2) to provide for JPG files and HTML files to be presented directly for their content, the command prefixing capability that used to
be used to use perl as a shell is used to invoke a new action that simply puts an HTML/mime header at the front and cat the file
contents.
% htmlcat <mimetype> <filepath>
This is done so that:
a) *.html files are presented as HTML mime type
and
b) *.jpg files are presented as application/image-jpeg mime type
This is done by providing
a) new conditional code in CGIServlet.java -- see attached for details.
b) the following short bash script made available in tomcat's execution path:
htmlcat:
#! /bin/bash
#date >> /var/log/tomcat4/mine
#echo PWD: $PWD >> /var/log/tomcat4/mine
#echo $0: $* >> /var/log/tomcat4/mine
echo HTTP/1.1
echo Content-Type: $1
echo
cat $2
Hope this helps you, other CGI developers and Tomcat users. Marc.....
----- Original Message -----
From: "Graham Freeman" <g-...@adfa.edu.au>
To: <to...@jakarta.apache.org>
Sent: Tuesday, April 22, 2003 5:18 PM
Subject: Help! CGI unreliable under Tomcat
> (This message was sent last week, without reply.)
>
> I have successfully installed Tomcat 4.1.24 on port 80 on a Linux box,
> with it processing JSP and servlets without error. I have set up a
> simple CGI demonstration and enabled CGI in a container. I am observing
> unpredictable behaviour. Sometimes (30% of the time) the CGI program
> generates a successful response. On all other occasions, the web page
> generated is
>
> HTTP Status 500
> Exception report
> The server encountered an internal error () that prevented it from
> fulfilling this request.
> java.io.IOException: Broken pipe
> at java.io.FileOutputStream.writeBytes(Native Method)
> at java.io.FileOutputStream.write(FileOutputStream.java:257)
> at
> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:69)
> at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:127)
> at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:128)
> at
> org.apache.catalina.servlets.CGIServlet$CGIRunner.run(CGIServlet.java:1683)
> at org.apache.catalina.servlets.CGIServlet.doGet(CGIServlet.java:635)
> at org.apache.catalina.servlets.CGIServlet.doPost(CGIServlet.java:597)
> ...
>
> I understand that messages like this reported in a log file indicate
> that connection to the client was lost. This does not seem to be the
> case here; the client also receives this "broken pipe" message.
>
> Has anyone else observed this problem and found a way around it?
>
> The only connector I am using is the tomcat4.CoyoteConnector.
> The CGI servlet is org.apache.catalina.servlets.CGIServlet.
> The CGI program is a 4-line shell script.
> #!/bin/sh
> echo Content-type: text/html
> echo
> echo CGI is working fine
> --
> ------------------------------------------------------------------------
> Dr Graham Freeman g-freeman@adfa.edu.au
> School of Computer Science Phone +61-2-6268 8186
> Australian Defence Force Academy Fax +61-2-6268 8581
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
Re: Help! CGI unreliable under Tomcat
Posted by Graham Freeman <g-...@adfa.edu.au>.
Thanks. I have sent the report to bugzilla. The missing stack trace is:
java.io.IOException: Broken pipe
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:257)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:69)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:127)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:128)
at
org.apache.catalina.servlets.CGIServlet$CGIRunner.run(CGIServlet.java:1683)
at org.apache.catalina.servlets.CGIServlet.doGet(CGIServlet.java:635)
at org.apache.catalina.servlets.CGIServlet.doPost(CGIServlet.java:597)
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(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
Bill Barker wrote:
>You could try including more of the stack trace. You could also try posting
>to http://nagoya.apache.org/bugzilla, including a simple web-app that
>reproduces this.
>
>"Graham Freeman" <g-...@adfa.edu.au> wrote in message
>news:3EA5DBBE.6020104@adfa.edu.au...
>
>
>>(This message was sent last week, without reply.)
>>
>>I have successfully installed Tomcat 4.1.24 on port 80 on a Linux box,
>>with it processing JSP and servlets without error. I have set up a
>>simple CGI demonstration and enabled CGI in a container. I am observing
>>unpredictable behaviour. Sometimes (30% of the time) the CGI program
>>generates a successful response. On all other occasions, the web page
>>generated is
>>
>>HTTP Status 500
>>Exception report
>>The server encountered an internal error () that prevented it from
>>fulfilling this request.
>>java.io.IOException: Broken pipe
>> at java.io.FileOutputStream.writeBytes(Native Method)
>> at java.io.FileOutputStream.write(FileOutputStream.java:257)
>> at
>>java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:69)
>> at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:127)
>> at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:128)
>> at
>>
>>
>>
>org.apache.catalina.servlets.CGIServlet$CGIRunner.run(CGIServlet.java:1683)
>
>
>> at org.apache.catalina.servlets.CGIServlet.doGet(CGIServlet.java:635)
>> at org.apache.catalina.servlets.CGIServlet.doPost(CGIServlet.java:597)
>>...
>>
>>I understand that messages like this reported in a log file indicate
>>that connection to the client was lost. This does not seem to be the
>>case here; the client also receives this "broken pipe" message.
>>
>>Has anyone else observed this problem and found a way around it?
>>
>>The only connector I am using is the tomcat4.CoyoteConnector.
>>The CGI servlet is org.apache.catalina.servlets.CGIServlet.
>>The CGI program is a 4-line shell script.
>> #!/bin/sh
>> echo Content-type: text/html
>> echo
>> echo CGI is working fine
>>--
>>------------------------------------------------------------------------
>>Dr Graham Freeman g-freeman@adfa.edu.au
>>School of Computer Science Phone +61-2-6268 8186
>>Australian Defence Force Academy Fax +61-2-6268 8581
>>
>>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>
>
--
------------------------------------------------------------------------
Dr Graham Freeman g-freeman@adfa.edu.au
School of Computer Science Phone +61-2-6268 8186
Australian Defence Force Academy Fax +61-2-6268 8581
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Help! CGI unreliable under Tomcat
Posted by Bill Barker <wb...@wilshire.com>.
You could try including more of the stack trace. You could also try posting
to http://nagoya.apache.org/bugzilla, including a simple web-app that
reproduces this.
"Graham Freeman" <g-...@adfa.edu.au> wrote in message
news:3EA5DBBE.6020104@adfa.edu.au...
> (This message was sent last week, without reply.)
>
> I have successfully installed Tomcat 4.1.24 on port 80 on a Linux box,
> with it processing JSP and servlets without error. I have set up a
> simple CGI demonstration and enabled CGI in a container. I am observing
> unpredictable behaviour. Sometimes (30% of the time) the CGI program
> generates a successful response. On all other occasions, the web page
> generated is
>
> HTTP Status 500
> Exception report
> The server encountered an internal error () that prevented it from
> fulfilling this request.
> java.io.IOException: Broken pipe
> at java.io.FileOutputStream.writeBytes(Native Method)
> at java.io.FileOutputStream.write(FileOutputStream.java:257)
> at
> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:69)
> at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:127)
> at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:128)
> at
>
org.apache.catalina.servlets.CGIServlet$CGIRunner.run(CGIServlet.java:1683)
> at org.apache.catalina.servlets.CGIServlet.doGet(CGIServlet.java:635)
> at org.apache.catalina.servlets.CGIServlet.doPost(CGIServlet.java:597)
> ...
>
> I understand that messages like this reported in a log file indicate
> that connection to the client was lost. This does not seem to be the
> case here; the client also receives this "broken pipe" message.
>
> Has anyone else observed this problem and found a way around it?
>
> The only connector I am using is the tomcat4.CoyoteConnector.
> The CGI servlet is org.apache.catalina.servlets.CGIServlet.
> The CGI program is a 4-line shell script.
> #!/bin/sh
> echo Content-type: text/html
> echo
> echo CGI is working fine
> --
> ------------------------------------------------------------------------
> Dr Graham Freeman g-freeman@adfa.edu.au
> School of Computer Science Phone +61-2-6268 8186
> Australian Defence Force Academy Fax +61-2-6268 8581
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org