Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem when get all the exception stacktrace

 
Haifeng Jiang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can get all the exception stacktrace by using below method. but it only can display the stacktrace on the console.

results:
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O *************
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O com.ibm.ws.webcontainer.webapp.WebAppErrorReport:
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.webcontainer.servlet.ServletWrapper.constructErrorReport(ServletWrapper.java:789)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:694)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3444)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:815)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1466)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:119)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O Caused by: javax.servlet.ServletException
at com.ibm.partnerworld.incentives.management.RequestProcessor.processException(RequestProcessor.java)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
at com.ibm.partnerworld.incentives.management.RequestProcessor.processActionPerform(RequestProcessor.java:114)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at com.ibm.partnerworld.incentives.management.RequestProcessor.process(RequestProcessor.java:205)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1096)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:570)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3444)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:815)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1466)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:119)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
---- Begin backtrace for Nested Throwables
java.lang.NullPointerException
at com.ibm.partnerworld.incentives.management.action.PaymentRegister.execute(PaymentRegister.java)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at com.ibm.partnerworld.incentives.management.RequestProcessor.processActionPerform(RequestProcessor.java:114)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at com.ibm.partnerworld.incentives.management.RequestProcessor.process(RequestProcessor.java:205)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1096)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:570)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3444)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:815)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1466)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:119)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)

[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.partnerworld.incentives.management.RequestProcessor.processException(RequestProcessor.java)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.partnerworld.incentives.management.RequestProcessor.processActionPerform(RequestProcessor.java:114)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.partnerworld.incentives.management.RequestProcessor.process(RequestProcessor.java:205)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1096)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:570)
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O ... 17 more
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O *************


when I use this method, I cannot get all exception stacktrace.

result:
[4/8/09 16:40:09:125 CST] 00000038 SystemOut O 22222222222222com.ibm.ws.webcontainer.webapp.WebAppErrorReport:
at com.ibm.ws.webcontainer.servlet.ServletWrapper.constructErrorReport(ServletWrapper.java:789)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:694)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3444)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:815)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1466)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:119)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
Caused by: javax.servlet.ServletException
at com.ibm.partnerworld.incentives.management.RequestProcessor.processException(RequestProcessor.java)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
at com.ibm.partnerworld.incentives.management.RequestProcessor.processActionPerform(RequestProcessor.java:114)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at com.ibm.partnerworld.incentives.management.RequestProcessor.process(RequestProcessor.java:205)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1096)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:570)
... 17 more
3333333333

Why I get different result?
I just want to put all the exception stacktrace into a String object and display on the web page. So how can I get it? Any advice? Thanks.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it wise to put the stack trace on a website? The users will never understand it.

How about Throwable#getStackTrace()?
 
Haifeng Jiang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Is it wise to put the stack trace on a website? The users will never understand it.

How about Throwable#getStackTrace()?


Thanks for your response.
But if I use getStackTrace method I cannot get the deep exception. For example. I get NullpointerException in A class. I throw it out. Then B class catch it and wrap it to ServletException(or other exception). Then in C class I catch it and want to get all the exception stacktrace. In this case I can only get the ServletException. But cannot get all the NullpointerException stacktrace. Any advice?
>
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are the classes throwing the exceptions "chained"? If so, you should be able to use getCause().
 
Haifeng Jiang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Are the classes throwing the exceptions "chained"? If so, you should be able to use getCause().

I got one solution. just set the original exception stacktrace to the new exception stacktrace as below.
 
Haifeng Jiang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haifeng Jiang wrote:
Campbell Ritchie wrote:Are the classes throwing the exceptions "chained"? If so, you should be able to use getCause().

I got one solution. just set the original exception stacktrace to the new exception stacktrace as below.


But I cannot get the original exception name by using the solution,
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this article.
 
Haifeng Jiang
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe Verré wrote:Check this article.


Thanks so much! It is very helpful
Now I use below code when catched the exception.


and get the full stacktrace by using below code.


OK, thanks all again!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic