Matthew,

What we do is define this in our web.xml file so that when the container
gets a 500, 404, etc... error status code, I can then assign the appropriate
Struts action to handle it. For example:

<error-page>
        <error-code>500</error-code>
        <location>/c/systemError</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/c/fileNotFoundError</location>
</error-page>

For application exceptions that occur in an action class, you
could (as you have already mentioned) defined some general
global exceptions handlers and then define more fine grained
exception handlers as necessary (per action).

hth,

robert

> -----Original Message-----
> From: Matthew J. Vincent [mailto:[EMAIL PROTECTED]
> Sent: Monday, January 12, 2004 11:08 AM
> To: Struts Users Mailing List
> Subject: Generic Error Handler
>
>
> I searched the archives and I must have missed it.  I want to
> have a generic
> JSP or Servlet get invoked when an error occurs in my application.  For
> example, when I try to clink on a link on one of my pages I get an error
> message:
>
> HTTP Status 500 - No action instance for path /detailSearch could
> be created
>
> Looking at the logs it is obvious why there is an error (because I didn't
> create the org.jax.mgi.mtb.wi.actions.DetailSearchAction class).  What is
> the best approach to handle this type of error?  I tried adding the
> following to my struts-config.xml, but it is not going to the appError.jsp
> page.
>
>    <global-exceptions>
>      <exception key="system.error"
>                 type="java.lang.Exception"
>                 path="/appError.jsp"/>
>
>      <exception key="system.error"
>                 type="java.lang.ClassNotFoundException"
>                 path="/appError.jsp"/>
>
>    </global-exceptions>
>
> What is the best way to handle this?  What about other types of
> errors?  Is
> there a rule of thumb that everyone follows?
>
> Sorry for the hopefully easy (probably already asked) question.
>
> Matt
>
>
> Here is an output of the logs:
>
> SEVERE: No action instance for path /detailSearch could be created
> java.lang.ClassNotFoundException:
> org.jax.mgi.mtb.wi.actions.DetailSearchAction
>         at
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClass
> Loader.jav
> a:1366)
>         at
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClass
> Loader.jav
> a:1213)
>         at
> org.apache.struts.util.RequestUtils.applicationClass(RequestUtils.
> java:207)
>         at
> org.apache.struts.util.RequestUtils.applicationInstance(RequestUti
> ls.java:23
> 1)
>         at
> org.apache.struts.action.RequestProcessor.processActionCreate(Requ
> estProcess
> or.java:326)
>         at
> org.apache.struts.action.RequestProcessor.process(RequestProcessor
> .java:268)
>         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
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(A
> pplication
> FilterChain.j
> ava:284)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicati
> onFilterCh
> ain.java:204)
>
>         at
> org.jax.mgi.mtb.wi.filters.TimerFilter.doFilter(TimerFilter.java:23)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(A
> pplication
> FilterChain.j
> ava:233)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicati
> onFilterCh
> ain.java:204)
>
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapp
> erValve.ja
> va:256)
>         at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardV
> alveContex
> t.java:151)
>         at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> java:564)
>         at
> org.apache.catalina.core.StandardContextValve.invokeInternal(Stand
> ardContext
> Valve.java:24
> 5)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardConte
> xtValve.ja
> va:199)
>         at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardV
> alveContex
> t.java:151)
>         at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> java:564)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValv
> e.java:195
> )
>         at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardV
> alveContex
> t.java:151)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValv
> e.java:164
> )
>         at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardV
> alveContex
> t.java:149)
>         at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> java:564)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngine
> Valve.java
> :156)
>         at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardV
> alveContex
> t.java:151)
>         at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.
> java:564)
>         at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
>         at
> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:211)
>         at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:805)
>         at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.pr
> ocessConne
> ction(Http11P
> rotocol.java:696)
>         at
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:605)
>         at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Thre
> adPool.jav
> a:677)
>         at java.lang.Thread.run(Thread.java:534)
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to