Re: Exception rootCause
Daniel Pitts wrote :
Wojtek wrote:
I just had an app throw a ServletException.
The getMessage() simply states that:
Servlet execution threw an exception
When I debug the app at the point where the Exception is caught, I can look
into the Exception. There is a field called rootCause which in this case
holds:
java.lang.NoClassFoundError: Could not initialize class: class XXX
Now the rootCause holds the really interesting information which I would
really like to log. However there is no method to retrieve it. There IS a
method named getCause(), but it returns null.
So how do I get at the root cause?
Hmm, and printing the stack-trace doesn't include the rootCause? Can you
post any stack-trace? Is is javax.servlet.ServletException? What servlet
container are you using?
Tomcat 5.5.9
Java 1.6.0-b105
Trace:
javax.servlet.ServletException: Servlet execution threw an exception
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter:275
org.apache.catalina.core.ApplicationFilterChain.doFilter:173
org.apache.catalina.core.ApplicationDispatcher.invoke:672
org.apache.catalina.core.ApplicationDispatcher.processRequest:463
org.apache.catalina.core.ApplicationDispatcher.doForward:359
org.apache.catalina.core.ApplicationDispatcher.forward:301
at
com.app.utility.web.framework.servlet.BaseServlet.forward2Servlet(BaseServlet.java:965)
at
com.app.utility.web.framework.servlet.BaseServlet.forward2Servlet(BaseServlet.java:939)
at
com.app.utility.web.framework.servlet.BaseServlet.process(BaseServlet.java:350)
at
com.app.utility.web.framework.servlet.BaseServlet.doPost(BaseServlet.java:125)
javax.servlet.http.HttpServlet.service:709
javax.servlet.http.HttpServlet.service:802
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter:252
org.apache.catalina.core.ApplicationFilterChain.doFilter:173
org.apache.catalina.core.StandardWrapperValve.invoke:213
org.apache.catalina.core.StandardContextValve.invoke:178
org.apache.catalina.core.StandardHostValve.invoke:126
org.apache.catalina.valves.ErrorReportValve.invoke:105
org.apache.catalina.core.StandardEngineValve.invoke:107
org.apache.catalina.connector.CoyoteAdapter.service:148
org.apache.coyote.http11.Http11Processor.process:856
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection:744
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket:527
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt:80
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run:684
java.lang.Thread.run:619
rootCause:
java.lang.NoClassDefFoundError: Could not initialize class
com.app.pt.uc.stuff.edit.Command
Code to produce the stack trace (sorry about the wrap...):
catch (Exception fatal)
{
StackTraceElement[] trace = fatal.getStackTrace();
Log.error( getClassName(), "process", "******* ******* *******" );
Log.error( getClassName(), "process", fatal.toString() );
if (fatal.getCause() != null)
Log.error( getClassName(), "process", fatal.getCause().getMessage()
);
for (int i = 0; i < trace.length; i++)
Log.error( getClassName(), "process", trace[i].getClassName() + "."
+ trace[i].getMethodName() + ":" + trace[i].getLineNumber() );
Log.error( getClassName(), "process", "******* ******* *******" );
}
Answer these, and we'll be better able to answer you :-)
Well, ok, but I do not understand how a stack trace will help you tell
me how to get at a private field which does not have an accessor...
--
Wojtek :-)