You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Lindholm <gl...@yahoo.com> on 2009/03/03 19:50:01 UTC

Getting Servlets and Struts 2.1.6 to work together?

I'm trying to upgrade from Struts 2.0.11 to 2.1.6 and having a problem, struts isn't passing requests thru to my servlets. 

I have a servlet named 'status' and defined in web.xml like this.

    <servlet-mapping>
        <servlet-name>StatusServlet</servlet-name>
        <url-pattern>/status</url-pattern>
    </servlet-mapping>

After upgrading to 2.1.6 I now get the following exception when I try to go the the status servlet.  I'm not (intentionally) using conventions or any other zero config-ish plugin. It's looking for an action named 'status' which I don't have. I use a '.action' suffix for all my action URL requests. 

2009-03-03 13:41:05,692 WARN  org.apache.struts2.dispatcher.Dispatcher:49 - Could not find action or result
There is no Action mapped for namespace / and action name status. - [unknown location]
    at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:177)
    at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
    at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
    at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458)
    at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:46)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at com.allmanint.common.servlet.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:61)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
    at java.lang.Thread.run(Thread.java:619)

So how do I get it to behave like 2.0.11 and pass any requests that don't have .action suffix thru to the servlets?





      

Re: Getting Servlets and Struts 2.1.6 to work together?

Posted by Dave Newton <ne...@yahoo.com>.
Greg Lindholm wrote:
> I spent some time in the debugger and found out what 'really' changed was
> the default action extensions (struts.action.extension) changed from just
> 'action' to 'action' plus "" (no extension).  This was causing my "/status"
> request with no extension to be treated as an action.
> 
> The old (2.0.11) struts default.properties had:
>     struts.action.extension=action
> 
> The new (2.1.6) has:
>     struts.action.extension=action,,

I'm not quite sure why this happens here instead of in the Convention 
plugin (or maybe it happens both places?) but I'm not convinced the 
default setting is the correct place.

> So I still have the question of what is the 'correct' filter mapping for the
> struts filter? 
> 
> I found the FilterDispatcher javadocs which says:
> "IMPORTANT: this filter must be mapped to all requests. Unless you know
> exactly what you are doing, always map to this URL pattern: /* "

That recommendation still stands, AFAIK: most people probably aren't 
running mixed systems, and unless they're paying enough attention to 
realize that S2 relies on serving its own CSS/JavaScript/etc. via the 
filter, they shouldn't change the mapping.

Dave

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


Re: Getting Servlets and Struts 2.1.6 to work together?

Posted by Greg Lindholm <gl...@yahoo.com>.


Greg Lindholm wrote:
> 
> 
> 
> Wes Wannemacher wrote:
>> 
>> On Tuesday 03 March 2009 14:31:36 Greg Lindholm wrote:
>>> Is this what you mean?
>>>
>>> 	<filter-mapping>
>>> 		<filter-name>struts2</filter-name>
>>> 		<url-pattern>*.action</url-pattern>
>>> 	</filter-mapping>
>>>
>>> I previously had it as <url-pattern>/*</url-pattern> based on all the
>>> books
>>> and examples I was able to find. So is there no reason to include
>>> everything in the filter?
>>>
>> 
>> I would also map /struts/* 
>> 
>> I noticed today as well that struts was picking up an action I had
>> defined, 
>> even though I had no .action. I think I had seen it before
>> intermittently, but 
>> wasn't able to nail it down. Truthfully, I've been using conventions so
>> long 
>> that it strike me as odd at first. It was only because I was explicitly
>> trying 
>> to take it out of the equation for something I was working on that I
>> noticed. 
>> 
>> -Wes
>> 
>> -- 
>> 
>> Wes Wannemacher
>> Author - Struts 2 In Practice 
>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>> http://www.manning.com/wannemacher
>> 
>> 
> 
> Why do you recommend mapping '/struts/*' to the struts filter? What uses
> this convention?
> 
> Clearly there has been a change in behavior between 2.0.11  and 2.1.6, I'm
> wondering if this was intentional?  Does the FilterDispatcher now assume
> that ever request it sees must be an action? If so this kind of feels
> wrong for a Filter, I expect filters to handle what they need to and pass
> everything else through to the next layer.
> 
> 
> 

I spent some time in the debugger and found out what 'really' changed was
the default action extensions (struts.action.extension) changed from just
'action' to 'action' plus "" (no extension).  This was causing my "/status"
request with no extension to be treated as an action.

The old (2.0.11) struts default.properties had:
    struts.action.extension=action

The new (2.1.6) has:
    struts.action.extension=action,,

If I explicitly set the extension back to just 'action' then It works like
it used to and the request goes thru to my servlet.

In my struts.xml I added: <constant name="struts.action.extension"
value="action" />

So I still have the question of what is the 'correct' filter mapping for the
struts filter? 

I found the FilterDispatcher javadocs which says:
"IMPORTANT: this filter must be mapped to all requests. Unless you know
exactly what you are doing, always map to this URL pattern: /* "

I also see that FilterDispatcher has been deprecated, a note in the upgrade
guide would have been nice :).  (I'm going to add what I've found to the
wiki so will include a note.)

 



-- 
View this message in context: http://www.nabble.com/Getting-Servlets-and-Struts-2.1.6-to-work-together--tp22315139p22336289.html
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


Re: Getting Servlets and Struts 2.1.6 to work together?

Posted by Greg Lindholm <gl...@yahoo.com>.


Wes Wannemacher wrote:
> 
> On Tuesday 03 March 2009 14:31:36 Greg Lindholm wrote:
>> Is this what you mean?
>>
>> 	<filter-mapping>
>> 		<filter-name>struts2</filter-name>
>> 		<url-pattern>*.action</url-pattern>
>> 	</filter-mapping>
>>
>> I previously had it as <url-pattern>/*</url-pattern> based on all the
>> books
>> and examples I was able to find. So is there no reason to include
>> everything in the filter?
>>
> 
> I would also map /struts/* 
> 
> I noticed today as well that struts was picking up an action I had
> defined, 
> even though I had no .action. I think I had seen it before intermittently,
> but 
> wasn't able to nail it down. Truthfully, I've been using conventions so
> long 
> that it strike me as odd at first. It was only because I was explicitly
> trying 
> to take it out of the equation for something I was working on that I
> noticed. 
> 
> -Wes
> 
> -- 
> 
> Wes Wannemacher
> Author - Struts 2 In Practice 
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
> 
> 

Why do you recommend mapping '/struts/*' to the struts filter? What uses
this convention?

Clearly there has been a change in behavior between 2.0.11  and 2.1.6, I'm
wondering if this was intentional?  Does the FilterDispatcher now assume
that ever request it sees must be an action? If so this kind of feels wrong
for a Filter, I expect filters to handle what they need to and pass
everything else through to the next layer.



-- 
View this message in context: http://www.nabble.com/Getting-Servlets-and-Struts-2.1.6-to-work-together--tp22315139p22330799.html
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


Re: Getting Servlets and Struts 2.1.6 to work together?

Posted by Wes Wannemacher <we...@wantii.com>.
On Tuesday 03 March 2009 14:31:36 Greg Lindholm wrote:
> Is this what you mean?
>
> 	<filter-mapping>
> 		<filter-name>struts2</filter-name>
> 		<url-pattern>*.action</url-pattern>
> 	</filter-mapping>
>
> I previously had it as <url-pattern>/*</url-pattern> based on all the books
> and examples I was able to find. So is there no reason to include
> everything in the filter?
>

I would also map /struts/* 

I noticed today as well that struts was picking up an action I had defined, 
even though I had no .action. I think I had seen it before intermittently, but 
wasn't able to nail it down. Truthfully, I've been using conventions so long 
that it strike me as odd at first. It was only because I was explicitly trying 
to take it out of the equation for something I was working on that I noticed. 

-Wes

-- 

Wes Wannemacher
Author - Struts 2 In Practice 
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher


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


Re: Getting Servlets and Struts 2.1.6 to work together?

Posted by Greg Lindholm <gl...@yahoo.com>.
Is this what you mean?

	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>*.action</url-pattern>
	</filter-mapping>

I previously had it as <url-pattern>/*</url-pattern> based on all the books
and examples I was able to find. So is there no reason to include everything
in the filter?


Nils-Helge Garli wrote:
> 
> You probably want to edit the url pattern of the struts 2 filter mapping.
> 
> Nils-H
> 
> On Tue, Mar 3, 2009 at 7:50 PM, Greg Lindholm <gl...@yahoo.com> wrote:
>> I'm trying to upgrade from Struts 2.0.11 to 2.1.6 and having a problem,
>> struts isn't passing requests thru to my servlets.
>>
>> I have a servlet named 'status' and defined in web.xml like this.
>>
>>     <servlet-mapping>
>>         <servlet-name>StatusServlet</servlet-name>
>>         <url-pattern>/status</url-pattern>
>>     </servlet-mapping>
>>
>> After upgrading to 2.1.6 I now get the following exception when I try to
>> go the the status servlet.  I'm not (intentionally) using conventions or
>> any other zero config-ish plugin. It's looking for an action named
>> 'status' which I don't have. I use a '.action' suffix for all my action
>> URL requests.
>>
>> 2009-03-03 13:41:05,692 WARN  org.apache.struts2.dispatcher.Dispatcher:49
>> - Could not find action or result
>> There is no Action mapped for namespace / and action name status. -
>> [unknown location]
>>     at
>> com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:177)
>>     at
>> org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
>>     at
>> org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
>>     at
>> com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
>>     at
>> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458)
>>     at
>> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
>>     at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
>>     at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>>     at
>> com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:46)
>>     at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
>>     at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>>     at
>> com.allmanint.common.servlet.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:61)
>>     at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
>>     at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>>     at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>>     at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
>>     at
>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
>>     at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>>     at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
>>     at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
>>     at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
>>     at
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
>>     at
>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>     at
>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>     at
>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>     at
>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
>>     at java.lang.Thread.run(Thread.java:619)
>>
>> So how do I get it to behave like 2.0.11 and pass any requests that don't
>> have .action suffix thru to the servlets?
>>
>>
>>
>>
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Getting-Servlets-and-Struts-2.1.6-to-work-together--tp22315139p22316030.html
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


Re: Getting Servlets and Struts 2.1.6 to work together?

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
You probably want to edit the url pattern of the struts 2 filter mapping.

Nils-H

On Tue, Mar 3, 2009 at 7:50 PM, Greg Lindholm <gl...@yahoo.com> wrote:
> I'm trying to upgrade from Struts 2.0.11 to 2.1.6 and having a problem, struts isn't passing requests thru to my servlets.
>
> I have a servlet named 'status' and defined in web.xml like this.
>
>     <servlet-mapping>
>         <servlet-name>StatusServlet</servlet-name>
>         <url-pattern>/status</url-pattern>
>     </servlet-mapping>
>
> After upgrading to 2.1.6 I now get the following exception when I try to go the the status servlet.  I'm not (intentionally) using conventions or any other zero config-ish plugin. It's looking for an action named 'status' which I don't have. I use a '.action' suffix for all my action URL requests.
>
> 2009-03-03 13:41:05,692 WARN  org.apache.struts2.dispatcher.Dispatcher:49 - Could not find action or result
> There is no Action mapped for namespace / and action name status. - [unknown location]
>     at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:177)
>     at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
>     at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
>     at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
>     at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458)
>     at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
>     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
>     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>     at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:46)
>     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
>     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>     at com.allmanint.common.servlet.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:61)
>     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
>     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
>     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
>     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
>     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
>     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
>     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
>     at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>     at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>     at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>     at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
>     at java.lang.Thread.run(Thread.java:619)
>
> So how do I get it to behave like 2.0.11 and pass any requests that don't have .action suffix thru to the servlets?
>
>
>
>
>
>

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