Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get rid of (check logs) in the stacktrace ?

 
Leinad Nongag
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm creating a feature to send the stacktrace to the right programmer by email, but when I got a NoSuchMethod exception, it trunks the real method name and put (check logs) instead. Why is the Log having the right info and I can't get it myself ?

Thank you !

Leinad
 
Koen Aerts
Ranch Hand
Posts: 344
Java Linux Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have any more details on how exactly you're catching the stacktrace? Maybe you just need to adjust the log level in Log4J, if that is what you're using, I assume? Maybe you need to catch java.lang.Throwable instead of java.lang.Exception?
 
Leinad Nongag
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Koen,

I don't really know where is the original catch because it's handled by the following code in web.xml :



While on the error page, I save the exception in to the session so I can send the stacktrace by mail in my ErrorHandlerAction.

I want this (which is in the log file)


2012-02-07 15:57:09,719 [HttpRequestHandler-74] ERROR org.apache.struts.actions.DispatchAction - Action[/welcome] does not contain method named 'show3'

java.lang.NoSuchMethodException: com.myapp.MyAction.show3(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

at java.lang.Class.getMethod(Class.java:986)

at org.apache.struts.actions.DispatchAction.getMethod(DispatchAction.java:348)

at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:252)

at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)

at com.nurun.sofi.presentation.struts.controleur.BaseTilesRequestProcessor.processActionPerform(BaseTilesRequestProcessor.java:368)

at com.nurun.sofi.presentation.struts.controleur.BaseTilesRequestProcessor.process(BaseTilesRequestProcessor.java:187)

at com.nurun.sofi.presentation.struts.controleur.adf.BaseTilesRequestProcessor.process(BaseTilesRequestProcessor.java:31)

at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)

at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)

at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)

at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)

at com.nurun.sofi.presentation.filtre.FiltreZip.doFilter(FiltreZip.java:75)

at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:20)

at com.nurun.sofi.presentation.filtre.FiltreAuthentification.doFilter(FiltreAuthentification.java:684)

at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:20)

at com.nurun.sofi.presentation.filtre.FiltreUTF8.doFilter(FiltreUTF8.java:20)

at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:659)

at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)

at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)

at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)

at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)

at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)

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


Instead I got this :


2012-02-07 15:57:09,719 [HttpRequestHandler-74] ERROR com.nurun.sofi.presentation.struts.controleur.BaseTilesRequestProcessor - java.lang.NoSuchMethodException: Action[/welcome] does not contain specified method (check logs)

java.lang.NoSuchMethodException: Action[/accueil] does not contain specified method (check logs)

at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:261)

at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)

at com.nurun.sofi.presentation.struts.controleur.BaseTilesRequestProcessor.processActionPerform(BaseTilesRequestProcessor.java:368)

at com.nurun.sofi.presentation.struts.controleur.BaseTilesRequestProcessor.process(BaseTilesRequestProcessor.java:187)

at com.nurun.sofi.presentation.struts.controleur.adf.BaseTilesRequestProcessor.process(BaseTilesRequestProcessor.java:31)

at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)

at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)

at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)

at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)

at com.nurun.sofi.presentation.filtre.FiltreZip.doFilter(FiltreZip.java:75)

at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:20)

at com.nurun.sofi.presentation.filtre.FiltreAuthentification.doFilter(FiltreAuthentification.java:684)

at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:20)

at com.nurun.sofi.presentation.filtre.FiltreUTF8.doFilter(FiltreUTF8.java:20)

at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:659)

at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)

at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)

at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)

at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)

at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)

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



That stack trace can't help at all and the logs are not accessible easily by the programmers when it's on the production server. The users will never see the stacktrace, it's hidden to them. So it's not a security failiure, only the right person will see that stack trace and that person must be able to read something that will help them understand the error.

Maybe this has to do with how I'm getting the Exception. It's in the JSP



I'm cleaning the session right after sending my email...
 
Koen Aerts
Ranch Hand
Posts: 344
Java Linux Oracle
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't remember for sure, but is the "exception" object in your JSP error handling page an instance of Throwable or of Exception? Also, did you check if your JSP page has a throwable object instead of the exception object? Throwable is a parent of Exception and Error.
 
Leinad Nongag
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Koen.

the debugger tells me it's an object of NoSuchMethodException type. So it's not a throwable My guess is that the exception is throwed by Strut's DispatchAction, but I don't have access to the source to see what it does.

Thank you !
 
Koen Aerts
Ranch Hand
Posts: 344
Java Linux Oracle
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.NoSuchMethodException is extended from Exception, which is extended from Throwable. If you catch Throwable, you catch all derived instances. In your case, even catching Exception should normally include NoSuchMethodException. Also, you can download the struts source code from the apache web site.
 
Leinad Nongag
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Koen,

Do you think I can catch the throwable in my JSP page ? I can try.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic