You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eric Nielsen <er...@gmail.com> on 2010/10/17 17:32:31 UTC

After upgrading from Struts 2.0.x to 2.2.x, static content no longer served...

I recently upgraded from Struts 2.0.x + SmartURLs to Struts 2.2.1 +
Convention plugin.  However after upgrading all my static content is
no longer being served.  I read all the release notes along the way
that I could find and nothing suggests that my old approach should
have stopped working.  Can anyone point out what else I need to
change/tweak to get static content behaving again?

I'm using Maven as the build system.
static content is at
src/main/webapp/css
                        /javascript
                        /template
                        /WEB-INF


Here are my filters from web.xml

    <filter>
      <filter-name>struts-cleanup</filter-name>
      <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
    </filter>
    <filter>
      <filter-name>sitemesh</filter-name>
      <filter-class>org.apache.struts2.sitemesh.FreemarkerPageFilter</filter-class>
    </filter>
	<filter>
	  <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
	  <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
	</filter>
    <filter>
      <filter-name>struts</filter-name>
      <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>

    <filter-mapping>
      <filter-name>struts-cleanup</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
      <filter-name>sitemesh</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
      <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
      <filter-name>struts</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>

Here's the root node and contents of the struts.xml:
<struts>
  <constant name="struts.objectFactory" value="spring" />
  <constant name="struts.devMode" value="true" />
  <constant name="struts.action.extension" value="" />
  <constant name="struts.convention.default.parent.package"
value="cib-default" />

  <package name="cib-default" extends="struts-default">
    <interceptors>
	  <interceptor name="reattachment"
class="com.ballroomregistrar.compinabox.online.web.interceptors.WebSessionReattachmentInterceptor"
/>
	  <interceptor name="authentication"
class="com.ballroomregistrar.compinabox.online.web.interceptors.AuthenticationInterceptor"
/>
	  <interceptor name="authorization"
class="com.ballroomregistrar.compinabox.online.web.interceptors.AuthorizationInterceptor"
/>
      <interceptor-stack name="cibStack">
        <interceptor-ref name="reattachment" />
        <interceptor-ref name="authentication" />
        <interceptor-ref name="authorization" />
        <interceptor-ref name="defaultStack" />
      </interceptor-stack>
 	</interceptors>
    <default-interceptor-ref name="cibStack" />  	
   	<global-results>
      <result name="login" type="redirect">/account/login</result>
      <result name="access_denied" type="redirect">/accessDenied</result>
	</global-results>
   </package>

</struts>

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


Re: After upgrading from Struts 2.0.x to 2.2.x, static content no longer served...

Posted by Lukasz Lenart <lu...@googlemail.com>.
2010/10/18 Eric Nielsen <er...@gmail.com>:
> Here are my filters from web.xml
>
>    <filter>
>      <filter-name>struts-cleanup</filter-name>
>      <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
>    </filter>
>    <filter>
>      <filter-name>sitemesh</filter-name>
>      <filter-class>org.apache.struts2.sitemesh.FreemarkerPageFilter</filter-class>
>    </filter>
>        <filter>
>          <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
>          <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
>        </filter>
>    <filter>
>      <filter-name>struts</filter-name>
>      <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
>    </filter>

Try to use the new filter:
http://struts.apache.org/2.2.1/struts2-core/apidocs/org/apache/struts2/dispatcher/ng/package-summary.html


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Kapituła Javarsovia 2010 http://javarsovia.pl

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


Re: After upgrading from Struts 2.0.x to 2.2.x, static content no longer served...

Posted by Alex Rodriguez Lopez <al...@flordeutopia.pt>.
I'm using a combination of empty extension and exclusions for static 
content which works well now. Got pretty confused too at beginnning when 
I changed to an empty extension though:

http://struts.apache.org/2.2.1/docs/static-content.html

in web.xml:

<filter>
     <filter-name>struts2</filter-name>
     <filter-class>
       org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
     </filter-class>
   </filter>

   <filter-mapping>
     <filter-name>struts2</filter-name>
     <url-pattern>/*</url-pattern>
     <!-- Filter exclusions defined in struts.xml -->
   </filter-mapping>

and in struts.xml:

<constant name="struts.action.extension" value=""/>
   <constant name="struts.action.excludePattern" value="/js/.*, /css/.*, 
/img/.*"/>

Eric Nielsen, 19-10-2010 05:21:
> Li Ying wrote:
>> Are your setting:
>> <constant name="struts.action.extension" value="" />
>> ?
>
> Yes, I was intentionally setting the extension to the empty string.
> This used to work under the SmartUrls plugin in 2.0.x days.  I've dug
> though and found the comments in his source about how the author made
> that work.
>
> First switched to using "action" as the extension and all the filter
> mappings to "*.action" -- things worked again, but had urls of a form
> I don't prefer.
>
> Started to port the SmartURL changes into a custom subclass of
> FilterDispatcher -- and noticed that its deprecated and I should have
> used the StrutsExecuteFilter and StrutsPrepareFilter instead.
> Abandoned the port and switched to the correct filters and the empty
> extension.  Static content worked again.
>
> Changed some jsps, restarted server -- static content stopped working,
> very confused.
> Switched to the "," value you suggested in the followup email and that
> seems to have fixed the static content again, but something broke the
> taglibs.
>
> Started getting the "According to TLD or attribute directive in tag
> file, attribute href does not accept any expressions" error but I'm
> using the correct tag lib:
> <%@ taglib uri="http://java.sun.com/jsp/jstl/core"    prefix="c" %>
> <%@ taglib uri="/struts-tags" prefix="s" %>
> and this was working fine before.
>
> Dug deeper trying to see if I had missed other filter/servlet changes
> over the past couple of years, and yes I had.
>
> Tried following the directions on:
> http://struts.apache.org/2.x/docs/sitemesh-plugin.html
> but can't seem to figure out how to combine that with spring -- If I
> don't use the Struts Listener Freemarker won't start; if I don't use
> the Spring listener none of my beans get injected.  Can't seem to use
> both.
>
> I'm currently Googling trying to find example/tutorials using Struts
> 2.2.x, Spring, Sitemesh, and Freemarker, but so far all are either pre
> 2.1.6 (the new style fitlers) or leave off either spring or sitemesh.
>
> If anyone can point out a good, modern tutorial/guide that deals with
> Struts 2.2, Spring, Sitemesh, Freemarker, (and Hibernate) that would
> be wonderful.  I feel like I'm currently fixing one thing, while
> breaking another...
>
> Thanks.
>
>>
>> Try delete it, use the default setting instead.
>>
>> I take a quick look of the struts source code.
>>
>> In [org.apache.struts2.dispatcher.mapper.DefaultActionMapper],
>>
>> it use the extension of request url to detect if this request should
>> be mapped to an Action.
>>
>> If you set this constant to "", then DefaultActionMapper will map all
>> the request to Action.
>>
>> You can read the source of method
>> [getMapping]/[dropExtension]/[dropExtension] for more information.
>>
>> On Mon, Oct 18, 2010 at 4:25 PM, Eric Nielsen<er...@gmail.com>  wrote:
>>> I recently upgraded from Struts 2.0.x + SmartURLs to Struts 2.2.1 +
>>> Convention plugin.  However after upgrading all my static content is
>>> no longer being served.  I read all the release notes along the way
>>> that I could find and nothing suggests that my old approach should
>>> have stopped working.  Can anyone point out what else I need to
>>> change/tweak to get static content behaving again?  I'm guessing
>>> its related to my have a "" action extension?
>>>
>>> I'm using Maven as the build system.
>>> static content is at
>>> src/main/webapp/css
>>>                         /javascript
>>>                         /template
>>>                         /WEB-INF
>>>
>>>
>>> Here are my filters from web.xml
>>>
>>>     <filter>
>>>       <filter-name>struts-cleanup</filter-name>
>>>       <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
>>>     </filter>
>>>     <filter>
>>>       <filter-name>sitemesh</filter-name>
>>>       <filter-class>org.apache.struts2.sitemesh.FreemarkerPageFilter</filter-class>
>>>     </filter>
>>>         <filter>
>>>           <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
>>>           <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
>>>         </filter>
>>>     <filter>
>>>       <filter-name>struts</filter-name>
>>>       <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
>>>     </filter>
>>>
>>>     <filter-mapping>
>>>       <filter-name>struts-cleanup</filter-name>
>>>       <url-pattern>/*</url-pattern>
>>>     </filter-mapping>
>>>     <filter-mapping>
>>>       <filter-name>sitemesh</filter-name>
>>>       <url-pattern>/*</url-pattern>
>>>     </filter-mapping>
>>>     <filter-mapping>
>>>       <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
>>>       <url-pattern>/*</url-pattern>
>>>     </filter-mapping>
>>>     <filter-mapping>
>>>       <filter-name>struts</filter-name>
>>>       <url-pattern>/*</url-pattern>
>>>     </filter-mapping>
>>>
>>> Here's the root node and contents of the struts.xml:
>>> <struts>
>>>   <constant name="struts.objectFactory" value="spring" />
>>>   <constant name="struts.devMode" value="true" />
>>>   <constant name="struts.action.extension" value="" />
>>>   <constant name="struts.convention.default.parent.package"
>>> value="cib-default" />
>>>
>>>   <package name="cib-default" extends="struts-default">
>>>     <interceptors>
>>>           <interceptor name="reattachment"
>>>
> class="com.ballroomregistrar.compinabox.online.web.interceptors.WebSessionReattachmentInterceptor"
>>> />
>>>           <interceptor name="authentication"
>>> class="com.ballroomregistrar.compinabox.online.web.interceptors.AuthenticationInterceptor"
>>> />
>>>           <interceptor name="authorization"
>>> class="com.ballroomregistrar.compinabox.online.web.interceptors.AuthorizationInterceptor"
>>> />
>>>       <interceptor-stack name="cibStack">
>>>         <interceptor-ref name="reattachment" />
>>>         <interceptor-ref name="authentication" />
>>>         <interceptor-ref name="authorization" />
>>>         <interceptor-ref name="defaultStack" />
>>>       </interceptor-stack>
>>>         </interceptors>
>>>     <default-interceptor-ref name="cibStack" />
>>>         <global-results>
>>>       <result name="login" type="redirect">/account/login</result>
>>>       <result name="access_denied" type="redirect">/accessDenied</result>.
>>>         </global-results>
>>>    </package>
>>>
>>> </struts>
>>>
>
> ---------------------------------------------------------------------
> 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


Re: After upgrading from Struts 2.0.x to 2.2.x, static content no longer served...

Posted by Eric Nielsen <er...@gmail.com>.
Li Ying wrote:
>Are your setting:
><constant name="struts.action.extension" value="" />
>?

Yes, I was intentionally setting the extension to the empty string.
This used to work under the SmartUrls plugin in 2.0.x days.  I've dug
though and found the comments in his source about how the author made
that work.

First switched to using "action" as the extension and all the filter
mappings to "*.action" -- things worked again, but had urls of a form
I don't prefer.

Started to port the SmartURL changes into a custom subclass of
FilterDispatcher -- and noticed that its deprecated and I should have
used the StrutsExecuteFilter and StrutsPrepareFilter instead.
Abandoned the port and switched to the correct filters and the empty
extension.  Static content worked again.

Changed some jsps, restarted server -- static content stopped working,
very confused.
Switched to the "," value you suggested in the followup email and that
seems to have fixed the static content again, but something broke the
taglibs.

Started getting the "According to TLD or attribute directive in tag
file, attribute href does not accept any expressions" error but I'm
using the correct tag lib:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"    prefix="c" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
and this was working fine before.

Dug deeper trying to see if I had missed other filter/servlet changes
over the past couple of years, and yes I had.

Tried following the directions on:
http://struts.apache.org/2.x/docs/sitemesh-plugin.html
but can't seem to figure out how to combine that with spring -- If I
don't use the Struts Listener Freemarker won't start; if I don't use
the Spring listener none of my beans get injected.  Can't seem to use
both.

I'm currently Googling trying to find example/tutorials using Struts
2.2.x, Spring, Sitemesh, and Freemarker, but so far all are either pre
2.1.6 (the new style fitlers) or leave off either spring or sitemesh.

If anyone can point out a good, modern tutorial/guide that deals with
Struts 2.2, Spring, Sitemesh, Freemarker, (and Hibernate) that would
be wonderful.  I feel like I'm currently fixing one thing, while
breaking another...

Thanks.

>
>Try delete it, use the default setting instead.
>
>I take a quick look of the struts source code.
>
>In [org.apache.struts2.dispatcher.mapper.DefaultActionMapper],
>
>it use the extension of request url to detect if this request should
>be mapped to an Action.
>
>If you set this constant to "", then DefaultActionMapper will map all
>the request to Action.
>
>You can read the source of method
>[getMapping]/[dropExtension]/[dropExtension] for more information.
>
>On Mon, Oct 18, 2010 at 4:25 PM, Eric Nielsen <er...@gmail.com> wrote:
>> I recently upgraded from Struts 2.0.x + SmartURLs to Struts 2.2.1 +
>> Convention plugin.  However after upgrading all my static content is
>> no longer being served.  I read all the release notes along the way
>> that I could find and nothing suggests that my old approach should
>> have stopped working.  Can anyone point out what else I need to
>> change/tweak to get static content behaving again?  I'm guessing
>> its related to my have a "" action extension?
>>
>> I'm using Maven as the build system.
>> static content is at
>> src/main/webapp/css
>>                        /javascript
>>                        /template
>>                        /WEB-INF
>>
>>
>> Here are my filters from web.xml
>>
>>    <filter>
>>      <filter-name>struts-cleanup</filter-name>
>>      <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
>>    </filter>
>>    <filter>
>>      <filter-name>sitemesh</filter-name>
>>      <filter-class>org.apache.struts2.sitemesh.FreemarkerPageFilter</filter-class>
>>    </filter>
>>        <filter>
>>          <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
>>          <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
>>        </filter>
>>    <filter>
>>      <filter-name>struts</filter-name>
>>      <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
>>    </filter>
>>
>>    <filter-mapping>
>>      <filter-name>struts-cleanup</filter-name>
>>      <url-pattern>/*</url-pattern>
>>    </filter-mapping>
>>    <filter-mapping>
>>      <filter-name>sitemesh</filter-name>
>>      <url-pattern>/*</url-pattern>
>>    </filter-mapping>
>>    <filter-mapping>
>>      <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
>>      <url-pattern>/*</url-pattern>
>>    </filter-mapping>
>>    <filter-mapping>
>>      <filter-name>struts</filter-name>
>>      <url-pattern>/*</url-pattern>
>>    </filter-mapping>
>>
>> Here's the root node and contents of the struts.xml:
>> <struts>
>>  <constant name="struts.objectFactory" value="spring" />
>>  <constant name="struts.devMode" value="true" />
>>  <constant name="struts.action.extension" value="" />
>>  <constant name="struts.convention.default.parent.package"
>> value="cib-default" />
>>
>>  <package name="cib-default" extends="struts-default">
>>    <interceptors>
>>          <interceptor name="reattachment"
>>
class="com.ballroomregistrar.compinabox.online.web.interceptors.WebSessionReattachmentInterceptor"
>> />
>>          <interceptor name="authentication"
>> class="com.ballroomregistrar.compinabox.online.web.interceptors.AuthenticationInterceptor"
>> />
>>          <interceptor name="authorization"
>> class="com.ballroomregistrar.compinabox.online.web.interceptors.AuthorizationInterceptor"
>> />
>>      <interceptor-stack name="cibStack">
>>        <interceptor-ref name="reattachment" />
>>        <interceptor-ref name="authentication" />
>>        <interceptor-ref name="authorization" />
>>        <interceptor-ref name="defaultStack" />
>>      </interceptor-stack>
>>        </interceptors>
>>    <default-interceptor-ref name="cibStack" />
>>        <global-results>
>>      <result name="login" type="redirect">/account/login</result>
>>      <result name="access_denied" type="redirect">/accessDenied</result>.
>>        </global-results>
>>   </package>
>>
>> </struts>
>>

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


Re: After upgrading from Struts 2.0.x to 2.2.x, static content no longer served...

Posted by Li Ying <li...@gmail.com>.
By the way, if you DO want to set the extension of action to "",

try:
<constant name="struts.action.extension" value="," />

See if it works.

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


Re: After upgrading from Struts 2.0.x to 2.2.x, static content no longer served...

Posted by Li Ying <li...@gmail.com>.
Are your setting:
<constant name="struts.action.extension" value="" />
?

Try delete it, use the default setting instead.

I take a quick look of the struts source code.

In [org.apache.struts2.dispatcher.mapper.DefaultActionMapper],

it use the extension of request url to detect if this request should
be mapped to an Action.

If you set this constant to "", then DefaultActionMapper will map all
the request to Action.

You can read the source of method
[getMapping]/[dropExtension]/[dropExtension] for more information.

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


After upgrading from Struts 2.0.x to 2.2.x, static content no longer served...

Posted by Eric Nielsen <er...@gmail.com>.
I recently upgraded from Struts 2.0.x + SmartURLs to Struts 2.2.1 +
Convention plugin.  However after upgrading all my static content is
no longer being served.  I read all the release notes along the way
that I could find and nothing suggests that my old approach should
have stopped working.  Can anyone point out what else I need to
change/tweak to get static content behaving again?  I'm guessing
its related to my have a "" action extension?

I'm using Maven as the build system.
static content is at
src/main/webapp/css
                       /javascript
                       /template
                       /WEB-INF


Here are my filters from web.xml

   <filter>
     <filter-name>struts-cleanup</filter-name>
     <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
   </filter>
   <filter>
     <filter-name>sitemesh</filter-name>
     <filter-class>org.apache.struts2.sitemesh.FreemarkerPageFilter</filter-class>
   </filter>
       <filter>
         <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
         <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
       </filter>
   <filter>
     <filter-name>struts</filter-name>
     <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
   </filter>

   <filter-mapping>
     <filter-name>struts-cleanup</filter-name>
     <url-pattern>/*</url-pattern>
   </filter-mapping>
   <filter-mapping>
     <filter-name>sitemesh</filter-name>
     <url-pattern>/*</url-pattern>
   </filter-mapping>
   <filter-mapping>
     <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
     <url-pattern>/*</url-pattern>
   </filter-mapping>
   <filter-mapping>
     <filter-name>struts</filter-name>
     <url-pattern>/*</url-pattern>
   </filter-mapping>

Here's the root node and contents of the struts.xml:
<struts>
 <constant name="struts.objectFactory" value="spring" />
 <constant name="struts.devMode" value="true" />
 <constant name="struts.action.extension" value="" />
 <constant name="struts.convention.default.parent.package"
value="cib-default" />

 <package name="cib-default" extends="struts-default">
   <interceptors>
         <interceptor name="reattachment"
class="com.ballroomregistrar.compinabox.online.web.interceptors.WebSessionReattachmentInterceptor"
/>
         <interceptor name="authentication"
class="com.ballroomregistrar.compinabox.online.web.interceptors.AuthenticationInterceptor"
/>
         <interceptor name="authorization"
class="com.ballroomregistrar.compinabox.online.web.interceptors.AuthorizationInterceptor"
/>
     <interceptor-stack name="cibStack">
       <interceptor-ref name="reattachment" />
       <interceptor-ref name="authentication" />
       <interceptor-ref name="authorization" />
       <interceptor-ref name="defaultStack" />
     </interceptor-stack>
       </interceptors>
   <default-interceptor-ref name="cibStack" />
       <global-results>
     <result name="login" type="redirect">/account/login</result>
     <result name="access_denied" type="redirect">/accessDenied</result>
       </global-results>
  </package>

</struts>

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