Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 10382 invoked from network); 1 Oct 2007 18:24:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Oct 2007 18:24:22 -0000 Received: (qmail 78411 invoked by uid 500); 1 Oct 2007 18:24:02 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 78385 invoked by uid 500); 1 Oct 2007 18:24:02 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 78374 invoked by uid 99); 1 Oct 2007 18:24:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Oct 2007 11:24:02 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [74.50.11.20] (HELO meteor.lunarpages.com) (74.50.11.20) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Oct 2007 18:24:01 +0000 Received: from c-24-63-210-201.hsd1.ma.comcast.net ([24.63.210.201] helo=[127.0.0.1]) by meteor.lunarpages.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1IcPvg-0006WF-7H for user@struts.apache.org; Mon, 01 Oct 2007 11:23:40 -0700 Message-ID: <47013B0A.4030804@fdar.com> Date: Mon, 01 Oct 2007 14:23:06 -0400 From: Ian Roughley User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Struts Users Mailing List Subject: Re: Struts 2: Unable to catch exceptions via global-exception-mappings References: <12972599.post@talk.nabble.com> <12978952.post@talk.nabble.com> <4700FCD9.805@fdar.com> <12981367.post@talk.nabble.com> <4701159A.3010002@fdar.com> <12982888.post@talk.nabble.com> <470132C8.5020301@fdar.com> <12984801.post@talk.nabble.com> In-Reply-To: <12984801.post@talk.nabble.com> Content-Type: multipart/alternative; boundary="------------040208090501090009000505" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - meteor.lunarpages.com X-AntiAbuse: Original Domain - struts.apache.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - fdar.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Checked: Checked by ClamAV on apache.org --------------040208090501090009000505 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I have no ideas about that one :) mikeh96 wrote: > 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. > > > bar > > > /templates/screens/{1}.vm > > > 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) >>>>>>>>> ---------------------------------------------------------------- >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>> /templates/screens/exception.vm >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> exception="java.lang.Exception" >>>>>>>>> result="Exception"/> >>>>>>>>> >>>>>>>> >>>>>>>>> exception="org.apache.velocity.exception.ResourceNotFoundException" >>>>>>>>> result="Exception"/> >>>>>>>>> >>>>>>>> exception="java.lang.Runtime" >>>>>>>>> result="Exception"/> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> /templates/screens/{1}.vm >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> ---------------------------------------------------------------------- >>>>>>>>> ------ >>>>>>>>> -- >>>>>>>>> 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@struts.apache.org >>>>>>>>> For additional commands, e-mail: user-help@struts.apache.org >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> --------------------------------------------------------------------- >>>>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >>>>>>>> For additional commands, e-mail: user-help@struts.apache.org >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> > > --------------040208090501090009000505--