Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: Struts 2: Unable to catch exceptions via global-exception-mappings

Ian Roughley

2007-10-01

Replies:

Is the exception occurring during the call to execute() (or equivalent)
business logic method? This is where the exception handler interceptor
is applied. It seems like the exception you are receiving is from a
rendering phase outside the execution of the actions logic.

/Ian

mikeh96 wrote:
> Thanks for taking the time.. unfortunately, the exceptions are still
> percolating up.
> Do you have it working?
>
>
>
>
> Brian Trzupek wrote:
>  
>> I am not 100% sure on this, but I think you need to have
>> struts.devMode = false in struts.properties.
>>
>> Give that a whirl.
>>
>> Brian-
>>
>> On Sep 30, 2007, at 9:43 PM, mikeh96 wrote:
>>
>>  
>>> I am unable to trap an exception and it's being pushed up until it
>>> becomes a
>>> 500 Servlet Exception.
>>>
>>> Basically, I want to catch the exception if a user mistypes an
>>> action name
>>>
>>> I am using struts2 (2.0.9).
>>>
>>> Here's the top of the trace:
>>> org.apache.velocity.exception.ResourceNotFoundException:
>>> Unable to find resource '/templates/screens/inddd2ex.vm'
>>> at
>>> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(
>>> ResourceManagerImpl.java:458)
>>>
>>> Here's my struts.xml file
>>>
>>> (thanks for helping)
>>> ----------------------------------------------------------------
>>> <package name="default" extends="struts-default">
>>>
>>> <interceptors>
>>> <interceptor-stack name="simpleStack">
>>> <interceptor-ref name="defaultStack" />
>>> </interceptor-stack>
>>> </interceptors>
>>>
>>>
>>> <global-results>
>>> <result name="Exception" type="velocity"
>>>    
>>>> /templates/screens/exception.vm</result>
>>>>      
>>> </global-results>
>>>
>>> <global-exception-mappings>
>>> <exception-mapping
>>>   exception="java.lang.Exception"
>>>   result="Exception"/>
>>> <exception-mapping
>>>   exception="org.apache.velocity.exception.ResourceNotFoundException"
>>>   result="Exception"/>
>>> <exception-mapping
>>>   exception="java.lang.Runtime"
>>>   result="Exception"/>
>>> </global-exception-mappings>
>>>
>>>
>>> <action name="*" class="com.opensymphony.xwork2.ActionSupport">
>>> <interceptor-ref name="exception" />
>>> <interceptor-ref name="defaultStack" />
>>> <result type="velocity">/templates/screens/{1}.vm</result>
>>> </action>
>>>
>>> </package>
>>> ----------------------------------------------------------------------
>>> ------
>>> --
>>> View this message in context: http://www.nabble.com/Struts-2%3A--
>>> Unable-to-catch-exceptions-via-global-exception-mappings-
>>> tf4545971.html#a12972599
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>    
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>>
>>  
>
>  
©2008 junlu.com - Jax Systems, LLC, U.S.A.