Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
-none-

-none-

2007-10-01       - By mikeh96

 Back

You are right... I am just trying to catch those rare events.

Now here's something crazy:  (and I have checked, and double checked,
restarted server, etc).
BUT if I add a  to my action, the exception mapping WORKS.  If I take it
away, the exception is not caught.

<action name="*" class="com.opensymphony.xwork2.ActionSupport">
         bar
         <interceptor-ref name="exception" />
         <interceptor-ref name="defaultStack" />
         <result type="velocity">/templates/screens/{1}.vm</result>
</action>

That works like a charm, remove the foo/bar and I get 500 error.  struts.xml
file is the same as I posted.

Any ideas?


Ian Roughley wrote:
>
> Yes, that's definitely a valid approach.
>
> I guess the question I have is "how are you using the feature?"  It
> looks like you are simply providing a pass-through to view a velocity
> template that is the same as the action name.  Are you expecting the
> user to make a request to a template that will not exist?  I find that
> most of the time, once construction is complete, exceptions such as the
> one you are getting are never thrown, because the paths through the site
> are well know.
>
> /Ian
>
> mikeh96 wrote:
>> Thanks for the clarification.  Is the solution of extending
>> VelocityResult
>> and configuring it with a
>> template name to return (e.g. 404.vm)  if the requested template throws
>> the
>> ResourceNotFoundException
>> a viable one ?  Or is there a way to handle this more elegantly ?
>>
>> thanks again for your time!
>>
>> mike
>>
>>
>>
>> Ian Roughley wrote:
>>  
>>> The result is executed after the interceptors and after the action has
>>> executed.  Look at the invoke() method on the DefaultActionInvocation
>>> class.  Therefore, because your exception is in rendering the result,
>>> the exception is not managed by the interceptor.  If you threw the same
>>> exception from within the execute() method of an action, it would be
>>> handled as you are expecting.
>>>
>>> I think this comes down to the reasoning behind the interceptor.  I see
>>> it as a means to manage the run-time business logic, and not
>>> developer-based configuration which will usually be managed during the
>>> construction phase.
>>>
>>> /Ian
>>>
>>> mikeh96 wrote:
>>>    
>>>> thanks for looking.  I pasted the full stack trace below.   I am not
>>>> using
>>>> any home grown action code (yet). This is coming from the
>>>> DefaultActionSupport during the rendering stage.
>>>>
>>>> com.opensymphony.xwork2.DefaultActionInvocation.executeResult
(DefaultActionInvocation.java:348)
>>>>
>>>> Do I need to subclass and do something in the action.execute() code ?
>>>>
>>>>
>>>> here's the full trace
>>>>
>>>> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource
(ResourceManagerImpl.java:458)
>>>> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource
(ResourceManagerImpl.java:341)
>>>>   at
>>>> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance
.java:831)
>>>>   at
>>>> org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:491)
>>>>   at
>>>> org.apache.struts2.dispatcher.VelocityResult.getTemplate(VelocityResult
.java:221)
>>>>   at
>>>> org.apache.struts2.dispatcher.VelocityResult.doExecute(VelocityResult.java
:150)
>>>>   at
>>>> org.apache.struts2.dispatcher.StrutsResultSupport.execute
(StrutsResultSupport.java:178)
>>>>   at
>>>> com.opensymphony.xwork2.DefaultActionInvocation.executeResult
(DefaultActionInvocation.java:348)
>>>>   at
>>>> com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:253)
>>>>   at
>>>> org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java
:50)
>>>>   at
>>>> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
>>>>   at
>>>> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher
.java:419)
>>>>   at
>>>> com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain
.java:73)
>>>>   at
>>>> com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter
.java:118)
>>>>   at
>>>> com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter
.java:52)
>>>>   at
>>>> com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain
.java:73)
>>>>   at
>>>> org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter
(ActionContextCleanUp.java:99)
>>>>   at
>>>> com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain
.java:73)
>>>>   at
>>>> com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java
:175)
>>>>   at
>>>> com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation
.java:240)
>>>>   at
>>>> com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:263)
>>>>   at com.caucho.server.port.TcpConnection.run(TcpConnection.java:481)
>>>>   at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:685)
>>>>   at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:607)
>>>>   at java.lang.Thread.run(Thread.java:613)
>>>>
>>>>
>>>>
>>>> Ian Roughley wrote:
>>>>  
>>>>      
>>>>> 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 (See http://uts-2.ora-code.com)%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)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>    
>>>>>>>        
>>>>>>>            
>>>>>>  
>>>>>>      
>>>>>>          
>>>>>    
>>>>>        
>>>>  
>>>>      
>>>    
>>
>>  
>
>

--
View this message in context: http://www.nabble.com/Struts-2 (See http://uts-2.ora-code.com)%3A--Unable-to
-catch-exceptions-via-global-exception-mappings-tf4545971.html#a12984801
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)


©2008 junlu.com - Jax Systems, LLC, U.S.A.