tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maven apache <apachemav...@gmail.com>
Subject tomcat shut down normally
Date Mon, 06 Jul 2009 02:46:57 GMT
Hi all:I am working with a web service using the tomcat,however I met some
problems recently. The tomcat shut down when my application work wrongly.
I intend to call some command in my web application by the Runtime class,and
I create a new class which extends the Thread to get the Error stream,if the
error is not null so there must be something wrong when call the command
,then I want to throw a exception which I have defined,but this is not
impossible ,since in the run method one can not tho throw his own exception.
So I can just throw the RuntimeException.
In my thought,when I throw the RuntimeException ,my application can be
down,but the tomcat should not shut down! The fact is that once error
occurs(for example ,the command is wrong),the tomcat is shut down itself.
I wonder someone can give a advise.
The following is my thread class to get the error stream:
------------------------------------------------------------------------------------
final class ThreadError extends Thread {
private static Logger LOGGER = Logger.getLogger(ThreadError.class);
private Process ps;
private String cid;
public ThreadError(Process ps, String cid) {
this.ps = ps;
this.cid = cid;
}
/**
 * Run the command.
 */
public void run() {
try {
java.io.BufferedReader reader = new java.io.BufferedReader(
new java.io.InputStreamReader(this.ps.getErrorStream()));
String line = "";
try {
while ((line = reader.readLine()) != null) {
System.err.println(this.cid + "|ERROR|" + line);
LOGGER.warn(this.cid + "|ERROR|" + line);
}
} finally {
reader.close();
if (this.ps.exitValue() != 0) {
throw new RuntimeException(
this.cid+ "|ERROR|Execution failure, there might be an error in your
command. [exit code="
+ this.ps.exitValue() + "]");
///////////////////////////////// in fact in the above line If I did not
throw the RuntimeException ,the tomcat also shutdown.
}
}
} catch (java.io.IOException ioe) {
ioe.printStackTrace();
}
}
}
-----------------------------------------------------------------------------------------

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message