Re: Catching: Unable to instantiate Action

View: New views
7 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: Catching: Unable to instantiate Action

by Oscar Calderón-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Maybe using a exception mapping for java.lang.ClassNotFoundException

2009/11/11 Gustavo Felisberto <gustavo.felisberto@...>

> I have a Project were we have in struts.xml:
>
>
>
> <action name="/*_*" class="packge.to.actions.{1}" method="{2}">
>
>            <result name="success">/WEB-INF/plugins/{1}/{2}.jsp</result>
>
> </action>
>
>
>
> <global-exception-mappings>
>
>      <exception-mapping exception="java.lang.Exception" result="error" />
>
> </global-exception-mappings>
>
>
>
> <global-results>
>
>      <result name="error">/WEB-INF/Error.jsp</result>
>
> </global-results>
>
>
>
> If any exception is thrown in my actions the global maping catches it and
> sends to correct JSP. If user enters some Url where the Class exists but
> the
> method does not the exception mapping works ok. Problem is if the Class
> does
> not exist. In that case I get a struts error page (if debug mod is on) or a
> tomcat error page. Any way to catch this exception?
>
>
>
> --
>
> Gustavo Felisberto.
>
> WIT-Software, Lda
>
> Coimbra (Portugal), San Jose (California)
>
> Phone: +351239801030
>
> Web:  <http://www.wit-software.com> http://www.wit-software.com
>
>
>
>


--
Oscar

Re: Catching: Unable to instantiate Action

by RogerV :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wednesday 11 November 2009 17:34:49 Oscar wrote:
> Maybe using a exception mapping for java.lang.ClassNotFoundException
>

This sounds like the same problem that I'm having, Why would mapping
ClssNotFoundException help? It's a sub-class of java.lang.Exception and
mapping that should catch everything - yes?

Regards


> 2009/11/11 Gustavo Felisberto <gustavo.felisberto@...>
>
> > I have a Project were we have in struts.xml:
> >
> >
> >
> > <action name="/*_*" class="packge.to.actions.{1}" method="{2}">
> >
> >            <result name="success">/WEB-INF/plugins/{1}/{2}.jsp</result>
> >
> > </action>
> >
> >
> >
> > <global-exception-mappings>
> >
> >      <exception-mapping exception="java.lang.Exception" result="error" />
> >
> > </global-exception-mappings>
> >
> >
> >
> > <global-results>
> >
> >      <result name="error">/WEB-INF/Error.jsp</result>
> >
> > </global-results>
> >
> >
> >
> > If any exception is thrown in my actions the global maping catches it and
> > sends to correct JSP. If user enters some Url where the Class exists but
> > the
> > method does not the exception mapping works ok. Problem is if the Class
> > does
> > not exist. In that case I get a struts error page (if debug mod is on) or
> > a tomcat error page. Any way to catch this exception?
> >
> >
> >
> > --
> >
> > Gustavo Felisberto.
> >
> > WIT-Software, Lda
> >
> > Coimbra (Portugal), San Jose (California)
> >
> > Phone: +351239801030
> >
> > Web:  <http://www.wit-software.com> http://www.wit-software.com
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


RE: Catching: Unable to instantiate Action

by Gustavo Felisberto-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

My toughts also. But in any case I tested and it did not help.

If you find a solution please drop it here.

Gustavo

-----Mensagem original-----
De: Roger [mailto:roger.varley@...]
Enviada: quarta-feira, 11 de Novembro de 2009 21:02
Para: Struts Users Mailing List
Assunto: Re: Catching: Unable to instantiate Action

On Wednesday 11 November 2009 17:34:49 Oscar wrote:
> Maybe using a exception mapping for java.lang.ClassNotFoundException
>

This sounds like the same problem that I'm having, Why would mapping
ClssNotFoundException help? It's a sub-class of java.lang.Exception and
mapping that should catch everything - yes?

Regards


> 2009/11/11 Gustavo Felisberto <gustavo.felisberto@...>
>
> > I have a Project were we have in struts.xml:
> >
> >
> >
> > <action name="/*_*" class="packge.to.actions.{1}" method="{2}">
> >
> >            <result name="success">/WEB-INF/plugins/{1}/{2}.jsp</result>
> >
> > </action>
> >
> >
> >
> > <global-exception-mappings>
> >
> >      <exception-mapping exception="java.lang.Exception" result="error"
/>

> >
> > </global-exception-mappings>
> >
> >
> >
> > <global-results>
> >
> >      <result name="error">/WEB-INF/Error.jsp</result>
> >
> > </global-results>
> >
> >
> >
> > If any exception is thrown in my actions the global maping catches it
and
> > sends to correct JSP. If user enters some Url where the Class exists but
> > the
> > method does not the exception mapping works ok. Problem is if the Class
> > does
> > not exist. In that case I get a struts error page (if debug mod is on)
or

> > a tomcat error page. Any way to catch this exception?
> >
> >
> >
> > --
> >
> > Gustavo Felisberto.
> >
> > WIT-Software, Lda
> >
> > Coimbra (Portugal), San Jose (California)
> >
> > Phone: +351239801030
> >
> > Web:  <http://www.wit-software.com> http://www.wit-software.com
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Catching: Unable to instantiate Action

by RogerV :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday 12 November 2009 12:35:25 Gustavo Felisberto wrote:
> My toughts also. But in any case I tested and it did not help.
>
> If you find a solution please drop it here.
>
> Gustavo
>
Will do, but I've had even less response to my query than you.

Regards

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Catching: Unable to instantiate Action

by Brian Thompson-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I can only speculate, but it seems logical that the ClassNotFoundException
is being thrown from outside the purview of Struts, in Tomcat's ClassLoaders
- thus the Struts exception mapping never enters into it.

My only suggestion for dealing with this is to configure your actions
explicitly rather than using wildcards in your struts config.  (sorry, I'm
sure that's a LOT of work...)

Also - if you find another way around it, I'm also interested in reading
about it.

-Brian



On Thu, Nov 12, 2009 at 4:13 PM, Roger <roger.varley@...> wrote:

> On Thursday 12 November 2009 12:35:25 Gustavo Felisberto wrote:
> > My toughts also. But in any case I tested and it did not help.
> >
> > If you find a solution please drop it here.
> >
> > Gustavo
> >
> Will do, but I've had even less response to my query than you.
>
> Regards
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>

Re: Catching: Unable to instantiate Action

by RogerV :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Brian Thompson-5 wrote:
I can only speculate, but it seems logical that the ClassNotFoundException
is being thrown from outside the purview of Struts, in Tomcat's ClassLoaders
- thus the Struts exception mapping never enters into it.
Theres definitely something odd going on. With global mappings disabled and devmode set to true, entering an invalid action into the browser gives the Struts formatted "No Action Mapped" exception (it's not ClassNotFoundException"). With global mappings and devmode set to false, entering an invalid action give the Tomcat 404 page with the no Action Mapped message. With global mappings set to catch java.lang.exception and devmode set to false, Struts seems to catch every exception thrown except when an invalid action is keyed into the browser.

The fact that both the error message texts talk about "No Action Mapped" must surely mean that the error is being caught by Struts as Action Mapping is a Struts concept, not a Tomcat concept. I would have thought that catching in Invalid Action was one of the messages you would most want to catch to stop unfriendly users "experimenting" with your application!

Regards

Re: Catching: Unable to instantiate Action

by Greg Lindholm-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I haven't been following this thread so if my answer doesn't help... sorry.

I have configured a default Action setup to catch all unknown actions.

The default-action-ref tag [1] sets the action to use when the requested
action isn't found.
<default-action-ref name="Unknown" />

    <action name="Unknown"
class="com.nexmobile.server.struts.UnknownAction">
      <interceptor-ref name="unknownActionStack" />
      <result type="redirectAction">Login</result>
    </action>

I use a restricted interceptor stack since all I'm going to do is log it and
redirect to the login action.
      <interceptor-stack name="unknownActionStack">
        <interceptor-ref name="log" />
        <interceptor-ref name="servletConfig" />
      </interceptor-stack>

Your other option would be to configure a wildcard default [2]

<action name="*">
  <result>/Unknown.jsp</result>
</action>


[1]
http://struts.apache.org/2.x/docs/action-configuration.html#ActionConfiguration-ActionDefault

[2]
http://struts.apache.org/2.x/docs/action-configuration.html#ActionConfiguration-WildcardDefault

On Fri, Nov 13, 2009 at 5:51 AM, RogerV <roger.varley@...> wrote:

>
>
>
> Brian Thompson-5 wrote:
> >
> > I can only speculate, but it seems logical that the
> ClassNotFoundException
> > is being thrown from outside the purview of Struts, in Tomcat's
> > ClassLoaders
> > - thus the Struts exception mapping never enters into it.
> >
>
> Theres definitely something odd going on. With global mappings disabled and
> devmode set to true, entering an invalid action into the browser gives the
> Struts formatted "No Action Mapped" exception (it's not
> ClassNotFoundException"). With global mappings and devmode set to false,
> entering an invalid action give the Tomcat 404 page with the no Action
> Mapped message. With global mappings set to catch java.lang.exception and
> devmode set to false, Struts seems to catch every exception thrown except
> when an invalid action is keyed into the browser.
>
> The fact that both the error message texts talk about "No Action Mapped"
> must surely mean that the error is being caught by Struts as Action Mapping
> is a Struts concept, not a Tomcat concept. I would have thought that
> catching in Invalid Action was one of the messages you would most want to
> catch to stop unfriendly users "experimenting" with your application!
>
> Regards
>
> --
> View this message in context:
> http://old.nabble.com/Re%3A-Catching%3A-Unable-to-instantiate-Action-tp26303352p26334735.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>