You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Miguel Almeida (JIRA)" <ji...@apache.org> on 2011/06/08 14:17:58 UTC
[jira] [Created] (WW-3647) Adding a jndi-lookup Spring bean breaks
ServletActionRedirectResult
Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult
-------------------------------------------------------------------
Key: WW-3647
URL: https://issues.apache.org/jira/browse/WW-3647
Project: Struts 2
Issue Type: Bug
Components: Dispatch Filter, Plugin - Spring
Affects Versions: 2.2.3
Reporter: Miguel Almeida
When you add the following bean to a Spring-Struts application:
<jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />
Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
http://localhost:8080/XXXX/index!XXXX.action#XXXX
This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).
This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
<bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
scope="prototype" autowire="byName">
</bean>
and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.
I've added a testCase for you to confirm.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Issue Comment Edited] (WW-3647) Adding a jndi-lookup Spring
bean breaks ServletActionRedirectResult
Posted by "JB (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WW-3647?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13157363#comment-13157363 ]
JB edited comment on WW-3647 at 11/26/11 4:10 AM:
--------------------------------------------------
I don't have a patch ready (yet); however a temporary work-around is to configure the following setting in either your struts.xml or struts.properties file:
*struts.xml*
{code:xml}
<struts>
<constant name="struts.objectFactory.spring.autoWire.alwaysRespect" value="true" />
</struts>
{code}
*struts.properties*
{code}
struts.objectFactory.spring.autoWire.alwaysRespect = true
{code}
In the *buildBean* method of *SpringObjectFactory* class, if the *alwaysRespectAutowireStrategy* variable has a "true" value the error is not produced. Based on the code's comments the mixed injection strategy appears to be the root of the problem. if Spring is utilized for bean creation -- exclusively -- the error does not arise.
*com.opensymphony.xwork2.spring.SpringObjectFactory*
{code}
public class SpringObjectFactory extends ObjectFactory implements ApplicationContextAware {
[...]
public Object buildBean(Class clazz, Map<String, Object> extraContext)
[...]
// Decide to follow autowire strategy or use the legacy approach which mixes injection strategies
if (alwaysRespectAutowireStrategy) {
// Leave the creation up to Spring
bean = autoWiringFactory.createBean(clazz, autowireStrategy, false);
injectApplicationContext(bean);
return injectInternalBeans(bean);
} else {
bean = autoWiringFactory.autowire(clazz, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);
bean = autoWiringFactory.applyBeanPostProcessorsBeforeInitialization(bean, bean.getClass().getName());
[...]
}
{code}
was (Author: jeffblack360):
I don't have a patch ready (yet); however a temporary work-around is to configure the following setting in either your struts.xml or struts.properties file:
*struts.xml*
{code:xml}
<struts>
<constant name="struts.objectFactory.spring.autoWire.alwaysRespect" value="true" />
</struts>
{code}
*struts.properties*
{code}
struts.objectFactory.spring.autoWire.alwaysRespect = true
{code}
In the *buildBean* method of *SpringObjectFactory* class, if the *alwaysRespectAutowireStrategy* variable has a "true" value the error is not produced. Based on the code's comments the mixed injection strategy appears to be the root of the problem. if Spring is utilized for bean creation the error does not arise.
*com.opensymphony.xwork2.spring.SpringObjectFactory*
{code}
public class SpringObjectFactory extends ObjectFactory implements ApplicationContextAware {
[...]
public Object buildBean(Class clazz, Map<String, Object> extraContext)
[...]
// Decide to follow autowire strategy or use the legacy approach which mixes injection strategies
if (alwaysRespectAutowireStrategy) {
// Leave the creation up to Spring
bean = autoWiringFactory.createBean(clazz, autowireStrategy, false);
injectApplicationContext(bean);
return injectInternalBeans(bean);
} else {
bean = autoWiringFactory.autowire(clazz, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);
bean = autoWiringFactory.applyBeanPostProcessorsBeforeInitialization(bean, bean.getClass().getName());
[...]
}
{code}
> Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult
> -------------------------------------------------------------------
>
> Key: WW-3647
> URL: https://issues.apache.org/jira/browse/WW-3647
> Project: Struts 2
> Issue Type: Bug
> Components: Dispatch Filter, Plugin - Spring
> Affects Versions: 2.2.3
> Reporter: Miguel Almeida
> Assignee: Lukasz Lenart
> Labels: injection, redirectAction, spring, struts2
> Attachments: redirectActionErrorTest.zip, redirectActionErrorWithJunitTest.zip
>
>
> When you add the following bean to a Spring-Struts application:
> <jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />
> Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
> http://localhost:8080/XXXX/index!XXXX.action#XXXX
> This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).
> This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
> <bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
> scope="prototype" autowire="byName">
> </bean>
> and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.
> I've added a testCase for you to confirm.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (WW-3647) Adding a jndi-lookup Spring bean breaks
ServletActionRedirectResult
Posted by "Miguel Almeida (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WW-3647?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Miguel Almeida updated WW-3647:
-------------------------------
Attachment: (was: redirectActionErrorTest.zip)
> Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult
> -------------------------------------------------------------------
>
> Key: WW-3647
> URL: https://issues.apache.org/jira/browse/WW-3647
> Project: Struts 2
> Issue Type: Bug
> Components: Dispatch Filter, Plugin - Spring
> Affects Versions: 2.2.3
> Reporter: Miguel Almeida
> Labels: injection, redirectAction, spring, struts2
> Attachments: redirectActionErrorTest.zip
>
>
> When you add the following bean to a Spring-Struts application:
> <jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />
> Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
> http://localhost:8080/XXXX/index!XXXX.action#XXXX
> This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).
> This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
> <bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
> scope="prototype" autowire="byName">
> </bean>
> and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.
> I've added a testCase for you to confirm.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (WW-3647) Adding a jndi-lookup Spring bean breaks
ServletActionRedirectResult
Posted by "Miguel Almeida (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WW-3647?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Miguel Almeida updated WW-3647:
-------------------------------
Attachment: redirectActionErrorTest.zip
To see the problem:
1) run the maven goal jetty:run
2) browse to http://localhost:8080
3) Write "issue" on the top form and submit
Expected:
- The action has an "if issue, return login". Login has a global redirectAction result to index. I'd expect the action to redirect do index, which in turn redirects to /jsp/index.jsp
Actual:
What was expected
CHANGE:
1) Now change type="myRedirect" to type="redirectAction" in struts.xml. This will make Struts use the same ServletActionRedirectResult, but now it's not being managed by Spring.
Actual:
Error - Problem accessing /zzz/index!zzz.action.
It seems Struts is injecting zzz (the default value of the jdni bean) everywhere in ServletActionRedirectResult's constructor!
> Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult
> -------------------------------------------------------------------
>
> Key: WW-3647
> URL: https://issues.apache.org/jira/browse/WW-3647
> Project: Struts 2
> Issue Type: Bug
> Components: Dispatch Filter, Plugin - Spring
> Affects Versions: 2.2.3
> Reporter: Miguel Almeida
> Labels: injection, redirectAction, spring, struts2
> Attachments: redirectActionErrorTest.zip
>
>
> When you add the following bean to a Spring-Struts application:
> <jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />
> Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
> http://localhost:8080/XXXX/index!XXXX.action#XXXX
> This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).
> This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
> <bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
> scope="prototype" autowire="byName">
> </bean>
> and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.
> I've added a testCase for you to confirm.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (WW-3647) Adding a jndi-lookup Spring bean breaks
ServletActionRedirectResult
Posted by "Lukasz Lenart (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WW-3647?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lukasz Lenart updated WW-3647:
------------------------------
Fix Version/s: 3.x
> Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult
> -------------------------------------------------------------------
>
> Key: WW-3647
> URL: https://issues.apache.org/jira/browse/WW-3647
> Project: Struts 2
> Issue Type: Bug
> Components: Dispatch Filter, Plugin - Spring
> Affects Versions: 2.2.3
> Reporter: Miguel Almeida
> Assignee: Lukasz Lenart
> Labels: injection, redirectAction, spring, struts2
> Fix For: 3.x
>
> Attachments: redirectActionErrorTest.zip, redirectActionErrorWithJunitTest.zip
>
>
> When you add the following bean to a Spring-Struts application:
> <jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />
> Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
> http://localhost:8080/XXXX/index!XXXX.action#XXXX
> This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).
> This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
> <bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
> scope="prototype" autowire="byName">
> </bean>
> and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.
> I've added a testCase for you to confirm.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Assigned] (WW-3647) Adding a jndi-lookup Spring bean breaks
ServletActionRedirectResult
Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WW-3647?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lukasz Lenart reassigned WW-3647:
---------------------------------
Assignee: Lukasz Lenart
> Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult
> -------------------------------------------------------------------
>
> Key: WW-3647
> URL: https://issues.apache.org/jira/browse/WW-3647
> Project: Struts 2
> Issue Type: Bug
> Components: Dispatch Filter, Plugin - Spring
> Affects Versions: 2.2.3
> Reporter: Miguel Almeida
> Assignee: Lukasz Lenart
> Labels: injection, redirectAction, spring, struts2
> Attachments: redirectActionErrorTest.zip, redirectActionErrorWithJunitTest.zip
>
>
> When you add the following bean to a Spring-Struts application:
> <jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />
> Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
> http://localhost:8080/XXXX/index!XXXX.action#XXXX
> This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).
> This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
> <bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
> scope="prototype" autowire="byName">
> </bean>
> and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.
> I've added a testCase for you to confirm.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Issue Comment Edited] (WW-3647) Adding a jndi-lookup Spring
bean breaks ServletActionRedirectResult
Posted by "Miguel Almeida (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WW-3647?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13046032#comment-13046032 ]
Miguel Almeida edited comment on WW-3647 at 6/8/11 3:56 PM:
------------------------------------------------------------
Run JNDIProblemTestCase in the attachment redirectActionErrorWithJunitTest.zip to check the problem out.
was (Author: wild_oscar):
Run JNDIProblemTestCase to check out the problem
> Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult
> -------------------------------------------------------------------
>
> Key: WW-3647
> URL: https://issues.apache.org/jira/browse/WW-3647
> Project: Struts 2
> Issue Type: Bug
> Components: Dispatch Filter, Plugin - Spring
> Affects Versions: 2.2.3
> Reporter: Miguel Almeida
> Labels: injection, redirectAction, spring, struts2
> Attachments: redirectActionErrorTest.zip, redirectActionErrorWithJunitTest.zip
>
>
> When you add the following bean to a Spring-Struts application:
> <jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />
> Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
> http://localhost:8080/XXXX/index!XXXX.action#XXXX
> This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).
> This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
> <bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
> scope="prototype" autowire="byName">
> </bean>
> and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.
> I've added a testCase for you to confirm.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (WW-3647) Adding a jndi-lookup Spring bean breaks
ServletActionRedirectResult
Posted by "Miguel Almeida (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WW-3647?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Miguel Almeida updated WW-3647:
-------------------------------
Attachment: redirectActionErrorWithJunitTest.zip
Run JNDIProblemTestCase to check out the problem
> Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult
> -------------------------------------------------------------------
>
> Key: WW-3647
> URL: https://issues.apache.org/jira/browse/WW-3647
> Project: Struts 2
> Issue Type: Bug
> Components: Dispatch Filter, Plugin - Spring
> Affects Versions: 2.2.3
> Reporter: Miguel Almeida
> Labels: injection, redirectAction, spring, struts2
> Attachments: redirectActionErrorTest.zip, redirectActionErrorWithJunitTest.zip
>
>
> When you add the following bean to a Spring-Struts application:
> <jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />
> Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
> http://localhost:8080/XXXX/index!XXXX.action#XXXX
> This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).
> This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
> <bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
> scope="prototype" autowire="byName">
> </bean>
> and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.
> I've added a testCase for you to confirm.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Issue Comment Edited] (WW-3647) Adding a jndi-lookup Spring
bean breaks ServletActionRedirectResult
Posted by "JB (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WW-3647?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13157363#comment-13157363 ]
JB edited comment on WW-3647 at 11/26/11 4:11 AM:
--------------------------------------------------
I don't have a patch ready (yet); however a temporary work-around is to configure the following setting in either your struts.xml or struts.properties file:
*struts.xml*
{code:xml}
<struts>
<constant name="struts.objectFactory.spring.autoWire.alwaysRespect" value="true" />
</struts>
{code}
*struts.properties*
{code}
struts.objectFactory.spring.autoWire.alwaysRespect = true
{code}
In the *buildBean* method of *SpringObjectFactory* class, if the *alwaysRespectAutowireStrategy* variable has a "true" value the error is not produced. Based on the code's comments the mixed injection strategy appears to be the root of the problem. if Spring is utilized for bean creation, exclusively, the error is avoided.
*com.opensymphony.xwork2.spring.SpringObjectFactory*
{code}
public class SpringObjectFactory extends ObjectFactory implements ApplicationContextAware {
[...]
public Object buildBean(Class clazz, Map<String, Object> extraContext)
[...]
// Decide to follow autowire strategy or use the legacy approach which mixes injection strategies
if (alwaysRespectAutowireStrategy) {
// Leave the creation up to Spring
bean = autoWiringFactory.createBean(clazz, autowireStrategy, false);
injectApplicationContext(bean);
return injectInternalBeans(bean);
} else {
bean = autoWiringFactory.autowire(clazz, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);
bean = autoWiringFactory.applyBeanPostProcessorsBeforeInitialization(bean, bean.getClass().getName());
[...]
}
{code}
was (Author: jeffblack360):
I don't have a patch ready (yet); however a temporary work-around is to configure the following setting in either your struts.xml or struts.properties file:
*struts.xml*
{code:xml}
<struts>
<constant name="struts.objectFactory.spring.autoWire.alwaysRespect" value="true" />
</struts>
{code}
*struts.properties*
{code}
struts.objectFactory.spring.autoWire.alwaysRespect = true
{code}
In the *buildBean* method of *SpringObjectFactory* class, if the *alwaysRespectAutowireStrategy* variable has a "true" value the error is not produced. Based on the code's comments the mixed injection strategy appears to be the root of the problem. if Spring is utilized for bean creation -- exclusively -- the error does not arise.
*com.opensymphony.xwork2.spring.SpringObjectFactory*
{code}
public class SpringObjectFactory extends ObjectFactory implements ApplicationContextAware {
[...]
public Object buildBean(Class clazz, Map<String, Object> extraContext)
[...]
// Decide to follow autowire strategy or use the legacy approach which mixes injection strategies
if (alwaysRespectAutowireStrategy) {
// Leave the creation up to Spring
bean = autoWiringFactory.createBean(clazz, autowireStrategy, false);
injectApplicationContext(bean);
return injectInternalBeans(bean);
} else {
bean = autoWiringFactory.autowire(clazz, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);
bean = autoWiringFactory.applyBeanPostProcessorsBeforeInitialization(bean, bean.getClass().getName());
[...]
}
{code}
> Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult
> -------------------------------------------------------------------
>
> Key: WW-3647
> URL: https://issues.apache.org/jira/browse/WW-3647
> Project: Struts 2
> Issue Type: Bug
> Components: Dispatch Filter, Plugin - Spring
> Affects Versions: 2.2.3
> Reporter: Miguel Almeida
> Assignee: Lukasz Lenart
> Labels: injection, redirectAction, spring, struts2
> Attachments: redirectActionErrorTest.zip, redirectActionErrorWithJunitTest.zip
>
>
> When you add the following bean to a Spring-Struts application:
> <jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />
> Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
> http://localhost:8080/XXXX/index!XXXX.action#XXXX
> This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).
> This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
> <bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
> scope="prototype" autowire="byName">
> </bean>
> and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.
> I've added a testCase for you to confirm.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (WW-3647) Adding a jndi-lookup Spring bean
breaks ServletActionRedirectResult
Posted by "JB (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WW-3647?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13157363#comment-13157363 ]
JB commented on WW-3647:
------------------------
I don't have a patch ready (yet); however a temporary work-around is to configure the following setting in either your struts.xml or struts.properties file:
*struts.xml*
{code:xml}
<struts>
<constant name="struts.objectFactory.spring.autoWire.alwaysRespect" value="true" />
</struts>
{code}
*struts.properties*
{code}
struts.objectFactory.spring.autoWire.alwaysRespect = true
{code}
In the *buildBean* method of *SpringObjectFactory* class, if the *alwaysRespectAutowireStrategy* variable has a "true" value the error is not produced. Based on the code's comments the mixed injection strategy appears to be the root of the problem. if Spring is utilized for bean creation the error does not arise.
*com.opensymphony.xwork2.spring.SpringObjectFactory*
{code}
public class SpringObjectFactory extends ObjectFactory implements ApplicationContextAware {
[...]
public Object buildBean(Class clazz, Map<String, Object> extraContext)
[...]
// Decide to follow autowire strategy or use the legacy approach which mixes injection strategies
if (alwaysRespectAutowireStrategy) {
// Leave the creation up to Spring
bean = autoWiringFactory.createBean(clazz, autowireStrategy, false);
injectApplicationContext(bean);
return injectInternalBeans(bean);
} else {
bean = autoWiringFactory.autowire(clazz, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);
bean = autoWiringFactory.applyBeanPostProcessorsBeforeInitialization(bean, bean.getClass().getName());
[...]
}
{code}
> Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult
> -------------------------------------------------------------------
>
> Key: WW-3647
> URL: https://issues.apache.org/jira/browse/WW-3647
> Project: Struts 2
> Issue Type: Bug
> Components: Dispatch Filter, Plugin - Spring
> Affects Versions: 2.2.3
> Reporter: Miguel Almeida
> Assignee: Lukasz Lenart
> Labels: injection, redirectAction, spring, struts2
> Attachments: redirectActionErrorTest.zip, redirectActionErrorWithJunitTest.zip
>
>
> When you add the following bean to a Spring-Struts application:
> <jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />
> Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
> http://localhost:8080/XXXX/index!XXXX.action#XXXX
> This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).
> This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
> <bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
> scope="prototype" autowire="byName">
> </bean>
> and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.
> I've added a testCase for you to confirm.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (WW-3647) Adding a jndi-lookup Spring bean breaks
ServletActionRedirectResult
Posted by "Miguel Almeida (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WW-3647?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Miguel Almeida updated WW-3647:
-------------------------------
Attachment: redirectActionErrorTest.zip
> Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult
> -------------------------------------------------------------------
>
> Key: WW-3647
> URL: https://issues.apache.org/jira/browse/WW-3647
> Project: Struts 2
> Issue Type: Bug
> Components: Dispatch Filter, Plugin - Spring
> Affects Versions: 2.2.3
> Reporter: Miguel Almeida
> Labels: injection, redirectAction, spring, struts2
> Attachments: redirectActionErrorTest.zip
>
>
> When you add the following bean to a Spring-Struts application:
> <jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />
> Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
> http://localhost:8080/XXXX/index!XXXX.action#XXXX
> This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).
> This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
> <bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
> scope="prototype" autowire="byName">
> </bean>
> and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.
> I've added a testCase for you to confirm.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Issue Comment Edited] (WW-3647) Adding a jndi-lookup Spring
bean breaks ServletActionRedirectResult
Posted by "Miguel Almeida (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WW-3647?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13045919#comment-13045919 ]
Miguel Almeida edited comment on WW-3647 at 6/8/11 3:23 PM:
------------------------------------------------------------
To see the problem:
1) run the maven goal jetty:run
2) browse to http://localhost:8080
3) Click the submit button.
Expected:
- The action returns "login", which has has a global redirectAction result to index. We'd expect the action to redirect do index, which in turn redirects to /jsp/index.jsp
Actual:
Error - Problem accessing /zzz/index!zzz.action.
It seems Struts is injecting zzz (the default value of the jdni bean) everywhere in ServletActionRedirectResult's constructor!
CHANGE:
1) Now change type="myRedirect" to type="redirectAction" in struts.xml. This will make Struts use the same ServletActionRedirectResult, but now it's not being managed by Spring.
With this configuration the redirect works as expected!
was (Author: wild_oscar):
To see the problem:
1) run the maven goal jetty:run
2) browse to http://localhost:8080
3) Write "issue" on the top form and submit
Expected:
- The action has an "if issue, return login". Login has a global redirectAction result to index. I'd expect the action to redirect do index, which in turn redirects to /jsp/index.jsp
Actual:
What was expected
CHANGE:
1) Now change type="myRedirect" to type="redirectAction" in struts.xml. This will make Struts use the same ServletActionRedirectResult, but now it's not being managed by Spring.
Actual:
Error - Problem accessing /zzz/index!zzz.action.
It seems Struts is injecting zzz (the default value of the jdni bean) everywhere in ServletActionRedirectResult's constructor!
> Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult
> -------------------------------------------------------------------
>
> Key: WW-3647
> URL: https://issues.apache.org/jira/browse/WW-3647
> Project: Struts 2
> Issue Type: Bug
> Components: Dispatch Filter, Plugin - Spring
> Affects Versions: 2.2.3
> Reporter: Miguel Almeida
> Labels: injection, redirectAction, spring, struts2
> Attachments: redirectActionErrorTest.zip
>
>
> When you add the following bean to a Spring-Struts application:
> <jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />
> Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
> http://localhost:8080/XXXX/index!XXXX.action#XXXX
> This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).
> This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
> <bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
> scope="prototype" autowire="byName">
> </bean>
> and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.
> I've added a testCase for you to confirm.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira