The Structure of an Exception Stack Trace

Listing 7-4 is an example of a stack trace that has been generated by the JVM. This stack trace is from the Tomcat application that failed to load my web application due to a malformed web. xml. As you can see, such things cannot be predicted; hence they are exceptions to normal operation.

Listing 7-4. An example of an exception stack trace

Jan 17, 2010 10:07:04 AM org.apache.catalina.startup.ContextConfig applicationWebConfig

SEVERE: Parse error in application web.xml file at jndi:/localhost/test/WEB-INF/web.xml org.xml.sax.SAXParseException: The element type "servlet-class" must be terminated^ by the matching end-tag "</servlet-class>".

at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1562)

at org.apache.catalina.startup.ContextConfig.applicationWebConfig'-' (ContextConfig.java:348)

at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1043) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)

at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent^ (LifecycleSupport.java:120)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4144) at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1105) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1203) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent^ (LifecycleSupport.java:120) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1306)

at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.^ processChildren(ContainerBase.java:1570)

at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.^ processChildren(ContainerBase.java:1579)

at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run^ (ContainerBase.java:1559)

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

Like "normal" log entries, this starts with a time stamp showing when the entry was created. It also spans a few lines; in fact, most stack traces are rather lengthy and may contain over a hundred lines, depending on the application structure. A stack trace effectively is a call stack and prints out the entire function hierarchy down to the one that has encountered the exceptional situation.

The structure of a Java exception stack trace log is not formal in any way; I'm just splitting it for my own convenience, as this will help me to organize these log entries later in the parser code. You should be able to apply the same structure without much trouble.

The first line of the log entry I'm going to call the logline. This line contains a timestamp of when the log entry was created and also the module name and the function where the exception occurred:

Jan 17, 2010 10:07:04 AM org.apache.catalina.startup.ContextConfig applicationWebConfig

The following line I'm going to call the headline. This line is not really part of the actual stack trace, but is printed out by the application code that "caught" the exception:

SEVERE: Parse error in application web.xml file at jndi:/localhost/test/WEB-INF/web.xml

And finally, the third section contains the "body" of the exception. This includes all the following lines and is the last part of the log entry. Usually the last line is a Java thread run method.

org.xml.sax.SAXParseException: The element type "servlet-class" must be terminated by the matching end-tag "</servlet-class>".

at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)

Was this article helpful?

0 0

Post a comment