tags:

views:

272

answers:

5

I'm trying to figure out why my web app (I didn't write it, but I'm supposed to debug it) is consistently causing the Tomcat web server to restart. All I see in the logs before the server restarts is:

Jul 24, 2009 7:52:15 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Portable Runtime which allows optimal performance in production environments was not found on the java.library.path: /usr/local/jdk1.5.0_09/jre/lib/i386/server:/usr/local/jdk1.5.0_09/jre/lib/i386:/usr/local/jdk1.5.0_09/jre/../lib/i386
Jul 24, 2009 7:52:15 AM org.apache.coyote.http11.Http11BaseProtocol init

I can actual do this same processing on other groups of files and it works fine, but doing this one particular group causes the server to restart. Mostly I'm hoping somebody can tell me if that's just a timeout, or if there should be some other log file telling me why it's dying. And if it's a timeout, if there's a way to increase it.

Update: I tried starting the server with bin/catalina.sh run which puts the output to stanadard out instead of catalina.out, and all I get instead of the above is the progress from my app and then "Killed".

As an aside, I don't know what's restarting it, but when I try to restart the server with bin/catalina.sh run, I get a BindException, so something restarted it.

Update 2: It was using Tomcat 5.5 and Java 5. I installed Tomcat 6 and set it up to use Java 6, and the same thing is happening. Also, if I do an "echo $?" after the "Killed", it gives me "137", which probably indicates the hosting company is killing it off for some reason.

A: 

Undeploy the webapp and see if Tomcat will come up without it. I suspect a bad Tomcat installation.

Thorbjørn Ravn Andersen
Tomcat comes up and stays up, unless I try this one particular thing on this one particular set of files. If I try the same thing on other files, it woks fine. I'm really hoping somebody can tell me how to figure out what's wrong with my app.
Paul Tomblin
The only thing I could imagine bringing Tomcat down is System.exit(). Try setting a method breakpoint on System.exit() - this requires you can attach to Tomcat with a debugger.
Thorbjørn Ravn Andersen
Do you have the complete source for this application?
Thorbjørn Ravn Andersen
I have source for the app. There is one call to System.exit, but only in a stand-alone main.
Paul Tomblin
Ok. At this particular stage I think you should reinstall Tomcat to ensure it is an absolutely pristine and functional installation. If it persists then consider using Jetty or JBoss for testing. Both have excellent IDE integration.
Thorbjørn Ravn Andersen
According to http://www.museum.state.il.us/ismdepts/library/linuxguides/abs-guide/exitcodes.html#EXITCODESREF 137 indicates that the JVM received a kill -9. You did not mention initially that this Tomcat is hosted - what limitations have the hosting company imposed?
Thorbjørn Ravn Andersen
+1  A: 

I believe that you only see that APR message when the server is first started.

An application deployed in Tomcat should not have the ability to make the entire server stop and start again - that doesn't make a lot of sense. Certain things can be done to make a webapp itself be reloaded (such as changing web.xml, or hitting Reload from Tomcat Manager), but nothing a deployed app does should be able to stop/start the entire server.

Are you sure that there isn't something external stopping and starting the server? A shell script or a cron job somewhere?

matt b
No, it's pretty consistent about restarting when I do this one thing in the app, and not restarting if I don't do it.
Paul Tomblin
and that thing is...?
matt b
+2  A: 

I know this is lame, but it is possible that your app is somehow causing System.exit() to be called?

Stephen C
I have seen this more than once.
phatmanace
There is a call to exit, but it's in a stand-alone test main(), and it's preceeded by a LOG.error - is it possible that System.exit will cause it to exit before the LOG.error gets written, or does it flush buffers?
Paul Tomblin
+2  A: 

AprLifecycleListener's responsibility is to initialize the Apache Portable Runtime, see http://tomcat.apache.org/tomcat-6.0-doc/apr.html

Could you post the log entries of the shutdown (do you have any, or is the above all you see?)?

BTW, you're saying that tomcat restarts, the standard shell scripts only start tomcat once, they just exit when tomcat quits. Do you have any kind of wrapper software (like http://wrapper.tanukisoftware.org/) that might be restarting your server?

WMR
There isn't any wrapper - I'm starting it with bin/startup.sh. And there isn't anything in the log before that AprLifecycleListener entry.
Paul Tomblin
startup.sh will not restart tomcat if the JVM exits. Are you sure you get a full restart?
WMR
No, all I know is that what I'm doing stops, and the catalina.out file shows a bunch of startup messages starting with that AprLifecycleListener message.
Paul Tomblin
A couple of suggestions: First, check if the PID of the JVM really changes before and after what you're doing. Try attaching via JMX with jconsole and see what the threads are doing. Increase the log level of your application and tomcat. Check tomcat's manager application (/manager/html) about the status of your webapp.
WMR
A: 

Never mind - it turns out the hosting company was killing my process (with kill -9 no less) because it was taking too much CPU time. Now I have to figure out how to do this incredibly time consuming task without using 90% of their CPU for more than 10 minutes - I tried "nicing" Tomcat and that didn't help, so I may have to add a "sleep(1000)" in the processing loop or something.

Paul Tomblin