Quantcast

problem Migrating from Struts 2.3 to 2.5

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

problem Migrating from Struts 2.3 to 2.5

John Aylward
I'm trying to migrate my struts application from 2.3.31 to 2.5.8 but it appears that my struts.xml is not getting loaded. My web.xml is pretty standard:

<?xml version="1.0"?>
<web-app id="app-name" version="3.0"
  xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_0.xsd"
>
  <display-name>app-name</display-name>
  <icon />
  <description />
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
  </filter-mapping>

Then my struts.xml which worked fine in 2.3.31 but is not working in 2.5.8

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
  "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
       <!-- Load in the default Struts configuration so we get all the basic interceptors.
             This is in the struts-core jar file if you need to look at it for reference. -->
       <!-- <include file="struts-default.xml" /> -->

       <!-- Explicitly use the struts Object Factory automatic default. Default
             options with no plugins are 'struts' and 'xwork'. To use 'spring', you need
             to include the struts-spring-plugin in pom.xml and configure it properly -->
       <constant name="struts.objectFactory" value="struts" />

       <!-- Max file upload size of 250 MB -->
       <constant name="struts.multipart.maxSize" value="262144000" />

       <include file="my-base.xml" />
       <include file="my-json-actions.xml" />
</struts>


The struts.xml file is in my resources directory, and I verified it's being copied properly to webapp/WEB-INF/classes. However, when I start up my application in Tomcat, the StrutsPrepareAndExecuteFilter init method is called, but my actions as defined in my-json-actions.xml are not initialized. It appears that the struts.xml file is not loaded at all. I'm also not seeing any exceptions or error messages output.

Do I need to do something different in 2.5 to get my actions loading? My action definitions look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
       <include file="my-json-base.xml" />
       <package name="my-json" namespace="/json" extends="my-json-base">
             <action name="Account!*"
                    class="my.actions.json.AccountAction"
                    method="{1}">
                    <interceptor-ref name="myInterceptor" />
             </action>

Any help would be greatly appreciated! Thanks

--
John

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem Migrating from Struts 2.3 to 2.5

Lukasz Lenart
2016-12-22 6:53 GMT+01:00 John Aylward <[hidden email]>:
> I'm trying to migrate my struts application from 2.3.31 to 2.5.8 but it appears that my struts.xml is not getting loaded. My web.xml is pretty standard:

Please try to use Struts 2.5.5

> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>   "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
>   "http://struts.apache.org/dtds/struts-2.3.dtd">

Change 2.3 to 2.5

> <struts>
>        <!-- Load in the default Struts configuration so we get all the basic interceptors.
>              This is in the struts-core jar file if you need to look at it for reference. -->
>        <!-- <include file="struts-default.xml" /> -->

You don't need that, Struts will automatically load any
struts-default.xml and struts-plugin.xml

> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>     "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
>     "http://struts.apache.org/dtds/struts-2.3.dtd">

Same here, replace 2.3 with 2.5

Anyway, this can be related to
https://issues.apache.org/jira/browse/WW-4727 but I cannot reproduce
this with my example app


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: problem Migrating from Struts 2.3 to 2.5

John Aylward
I combined all my struts.xml files into one and finally got a struts configuration error after a bit of massaging to get rid of old elements that I didn't need anymore and messed one up. At least I know the struts.xml file is being loaded now. I know the actions are being found because I purposefully made an error in the action section and it was properly reported.

However, once I cleaned up my errors, my actions still appear to not be loading, or perhaps they are loading in the wrong namespace.

When I try to access my actions in a browser directly, I get this message:
There is no Action mapped for namespace [/json] and action name [ClientData!loggedIn] associated with context path [].

I placed all my loaded files into the /json namespace:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
  "http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>

        <!-- Max file upload size of 250 MB -->
        <constant name="struts.multipart.maxSize" value="262144000" />

        <package name="my-json" namespace="/json" extends="struts-default">
...

In the 2.3.x branch I would get log message when an action was configured, but in 2.5.x I don't appear to get any such messages.


--
John


-----Original Message-----
From: Lukasz Lenart [mailto:[hidden email]]
Sent: Thursday, December 22, 2016 1:33 AM
To: Struts Users Mailing List <[hidden email]>
Subject: Re: problem Migrating from Struts 2.3 to 2.5

2016-12-22 6:53 GMT+01:00 John Aylward <[hidden email]>:
> I'm trying to migrate my struts application from 2.3.31 to 2.5.8 but it appears that my struts.xml is not getting loaded. My web.xml is pretty standard:

Please try to use Struts 2.5.5

> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC
>   "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
>  
> "http://cp.mcafee.com/d/FZsSd1NJ5xVdBVVx5UTsSzssqenAXIELCQrzzhOYDtBOVJ
> 6UUQsL9TphsdEEEKeczDT73ozkD3Jb7Cdyw2GqhY6YKrFF7MrOVJ6P8Uw-Y_R-hd7bxEVp
> d7afnKnjpjjVBNcQsKcKsJt6OaaJPhO_OEuvkzaT0QSyrodTVdYQsELKe8IICXCM0t9NrD
> jJmSNf-00Uxd2CkD5Kt2WvcYxd0STjUBU_dKc2Wq8UQsLnbydiseQIuoSa1Rd8-3un1l9N
> rDjJmSNf-00CSnzhOYr1vF6y1qdi1_GCy0rAhzIVg8Cy1Sdljh0cjyTexEwjVAQgjGq84-
> vdIc6Sf2aBrb8">

Change 2.3 to 2.5

> <struts>
>        <!-- Load in the default Struts configuration so we get all the basic interceptors.
>              This is in the struts-core jar file if you need to look at it for reference. -->
>        <!-- <include file="struts-default.xml" /> -->

You don't need that, Struts will automatically load any struts-default.xml and struts-plugin.xml

> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC
>     "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
>    
> "http://cp.mcafee.com/d/FZsS71NJ5xVdBVVx5UTsSzssqenAXIELCQrzzhOYDtBOVJ
> 6UUQsL9TphsdEEEKeczDT73ozkD3Jb7Cdyw2GqhY6YKrFF7MrOVJ6P8Uw-Y_R-hd7bxEVp
> d7afnKnjpjjVBNcQsKcKsJt6OaaJPhO_OEuvkzaT0QSCrodTVdYQsELKe8IICXCM0t9NrD
> jJmSNf-00Uxd2CkD5Kt2WvcYxd0STjUBU_dKc2Wq8UQsLnbydiseQIuoSa1Rd8-3un1l9N
> rDjJmSNf-00CSnzhOYr1vF6y1qdi1_GCy0rAhzIVg8Cy1Sdljh0cjyTexEwjVAQgjGq84-
> vdIc6UKR_Jar3J3JL">

Same here, replace 2.3 with 2.5

Anyway, this can be related to
http://cp.mcafee.com/d/k-Kr3x8i6xASyMYCOYYMyYrKrhKed7bOtSknPqdNNEVujKOVsSzssqenAXIEK6Qkkn76hPXzxIhGjxSBzP6Ng1ld8-3undQQzUdVsSzpAsgvuvW_8CzBMQsICzB7HTbFIFFYOUCqen6nemKzp55mVEVvVkffGhBrwqrpdI6XYC-qeknT74mmjtPpesRG9pAGkr-DqJJyvY01MhB7s8hGoF-0a0FtwsCedJQ-9ufPrz0KCyed7bROUzkD3Jb7CdywtjifwTBMlismVQXlJIj_w09JBUQsL6MnWhEwmzkwvWFEw6V4oXek29EwtzlkQg34UJPEq84-pd44WCy1fDPr31I9fTe0fYVuvP but I cannot reproduce this with my example app


Regards
--
Łukasz
+ 48 606 323 122
+ http://cp.mcafee.com/d/1jWVIgdEIf9ILfc8L6XCQrzzhOYDtB5YSzssqenAXIKndET
+ 76zBVeXabxJ555NNAs-UUr4qAUtFoYNIk0ljifwTBPtd8-3undESp747TD-LO9EVsd7b9E
+ VhWZOWraqvcK9CzBNBPBHEShhlKqen-l3PWApmU6CS3r1K_9LCzB5ZNN5BATsS02f-6NDM
+ 07BzYdJQ-9ufPrz0KCyed7bROUzkD3Jb7CdywtjifwTBMlismVQXlJIj_w09JBUQsL6MnW
+ hEwmzkwvWFEw6V4oXek29EwtzlkQg34UJPEq84-pd44WCy1fDPr31KhGv

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: problem Migrating from Struts 2.3 to 2.5

John Aylward
Ok, I got it to work with an include file on 2.5.8. In my main struts.xml I added this:

<struts>

        <!-- Max file upload size of 250 MB -->
        <constant name="struts.multipart.maxSize" value="262144000" />

        <constant name="struts.enable.DynamicMethodInvocation" value="FALSE" />
        <constant name="struts.strictMethodInvocation.methodRegex"
                value="([a-zA-Z]*)" />

        <include file="my-json-actions.xml" />
</struts>


Then in my included file I had to set this:
<struts>
        <package name="my-json" namespace="/json" extends="struts-default"
                strict-method-invocation="false">

The strict method invocation was preventing my actions from loading. Disabling it allowed my wildcard actions to work again. I'm not sure if the regex was needed or not, but I'm leaving it for now since it's working.



--
John J. Aylward

-----Original Message-----
From: John Aylward [mailto:[hidden email]]
Sent: Thursday, December 22, 2016 10:20 AM
To: Struts Users Mailing List <[hidden email]>
Subject: RE: problem Migrating from Struts 2.3 to 2.5

I combined all my struts.xml files into one and finally got a struts configuration error after a bit of massaging to get rid of old elements that I didn't need anymore and messed one up. At least I know the struts.xml file is being loaded now. I know the actions are being found because I purposefully made an error in the action section and it was properly reported.

However, once I cleaned up my errors, my actions still appear to not be loading, or perhaps they are loading in the wrong namespace.

When I try to access my actions in a browser directly, I get this message:
There is no Action mapped for namespace [/json] and action name [ClientData!loggedIn] associated with context path [].

I placed all my loaded files into the /json namespace:

        <!-- Max file upload size of 250 MB -->
        <constant name="struts.multipart.maxSize" value="262144000" />

        <package name="my-json" namespace="/json" extends="struts-default"> ...

In the 2.3.x branch I would get log message when an action was configured, but in 2.5.x I don't appear to get any such messages.


--
John


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem Migrating from Struts 2.3 to 2.5

Lukasz Lenart
Right, SMI is a new addition in Struts 2.5 and it's better to use it
instead of disabling, please read this
https://struts.apache.org/docs/action-configuration.html#ActionConfiguration-StrictMethodInvocation

2016-12-22 17:27 GMT+01:00 John Aylward <[hidden email]>:

> Ok, I got it to work with an include file on 2.5.8. In my main struts.xml I added this:
>
> <struts>
>
>         <!-- Max file upload size of 250 MB -->
>         <constant name="struts.multipart.maxSize" value="262144000" />
>
>         <constant name="struts.enable.DynamicMethodInvocation" value="FALSE" />
>         <constant name="struts.strictMethodInvocation.methodRegex"
>                 value="([a-zA-Z]*)" />
>
>         <include file="my-json-actions.xml" />
> </struts>
>
>
> Then in my included file I had to set this:
> <struts>
>         <package name="my-json" namespace="/json" extends="struts-default"
>                 strict-method-invocation="false">
>
> The strict method invocation was preventing my actions from loading. Disabling it allowed my wildcard actions to work again. I'm not sure if the regex was needed or not, but I'm leaving it for now since it's working.
>
>
>
> --
> John J. Aylward
>
> -----Original Message-----
> From: John Aylward [mailto:[hidden email]]
> Sent: Thursday, December 22, 2016 10:20 AM
> To: Struts Users Mailing List <[hidden email]>
> Subject: RE: problem Migrating from Struts 2.3 to 2.5
>
> I combined all my struts.xml files into one and finally got a struts configuration error after a bit of massaging to get rid of old elements that I didn't need anymore and messed one up. At least I know the struts.xml file is being loaded now. I know the actions are being found because I purposefully made an error in the action section and it was properly reported.
>
> However, once I cleaned up my errors, my actions still appear to not be loading, or perhaps they are loading in the wrong namespace.
>
> When I try to access my actions in a browser directly, I get this message:
> There is no Action mapped for namespace [/json] and action name [ClientData!loggedIn] associated with context path [].
>
> I placed all my loaded files into the /json namespace:
>
>         <!-- Max file upload size of 250 MB -->
>         <constant name="struts.multipart.maxSize" value="262144000" />
>
>         <package name="my-json" namespace="/json" extends="struts-default"> ...
>
> In the 2.3.x branch I would get log message when an action was configured, but in 2.5.x I don't appear to get any such messages.
>
>
> --
> John
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: problem Migrating from Struts 2.3 to 2.5

John Aylward
Yes, for now, I just need the application working as it did before. I'm planning to rewrite all the existing actions using the REST plugin and moving forward from there.

Having STI enabled when using wildcard matching is a little bit of a headache though. The entire point of me using the wildcard matching was because I didn't want to have to type out every method in the configuration. STI makes me have to type out every method in the configuration again.

--
John


-----Original Message-----
From: Lukasz Lenart [mailto:[hidden email]]
Sent: Thursday, December 22, 2016 3:58 PM
To: Struts Users Mailing List <[hidden email]>
Subject: Re: problem Migrating from Struts 2.3 to 2.5

Right, SMI is a new addition in Struts 2.5 and it's better to use it instead of disabling, please read this



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Loading...