Tuesday, August 14, 2007

Thread Death Error





Ran into a thread death error when using tomcat 5.5 . I have a servlet using some of the log4j for logging Any request which hits this servlet started throwing up this error .

Servlet.service() for servlet project threw exception

java.lang.ThreadDeath at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1252) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1212) at org.apache.log4j.Category.forcedLog(Category.java:388) at org.apache.log4j.Category.log(Category.java:853) at org.apache.commons.logging.impl.Log4JLogger.debug(Log4JLogger.java:171) at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:349) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:461) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:442) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)


The log4j components used in servlet was also pretty straight forward.

/** Logger for this class and subclasses */
protected final Log logger = LogFactory.getLog(getClass());
.... ...

logger.info("ProjectAppController - returning login view");

The log4j.properties were also pretty much in place. All the log4j related jars were placed within a webapp(WEB-INF/lib) Googling about this resulted in a couple of links which talked about the Tomcat server using log4j of the web application So it turned out that if i have log4j jar and commons-logging.jar present in the common/lib of Tomcat server the error vanished. This seemed pretty strange for
1. Why should the server bother about some logging classes present in one of the web applications?
2. Even if tomcat uses log4j extensively should'nt these jars be present in the lib folders?
The solution as well as the problem does'nt seem convincing , Need some more investigation into this