You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Javier Lecuona (JIRA)" <ji...@apache.org> on 2012/10/15 22:43:03 UTC

[jira] [Created] (WW-3898) Redirect Action calls wrong method

Javier Lecuona created WW-3898:
----------------------------------

             Summary: Redirect Action calls wrong method
                 Key: WW-3898
                 URL: https://issues.apache.org/jira/browse/WW-3898
             Project: Struts 2
          Issue Type: Bug
          Components: Plugin - Spring
    Affects Versions: 2.3.4.1, 2.3.4
         Environment: Mac OS X Lion 10.7.4
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
            Reporter: Javier Lecuona


I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().

I've made a simple project that is very simple to test.

In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.

Here is my config

struts.xml

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

<struts>
	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
	<constant name="struts.devMode" value="false" />
	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
	<constant name="struts.action.extension" value="," />

	<package name="general" extends="struts-default">

		<action name="test" method="test"
			class="test.action.Test">
			<result name="success">/jsp/test.jsp</result>
		</action>
		
		<action name="redirect" method="redirect"
			class="test.action.Redirect">
			<result type="redirectAction">test</result>
		</action>
		
	</package>
</struts>

ApplicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- Developer -->
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:security="http://www.springframework.org/schema/security"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
	xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">

	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
		<constructor-arg>
	 		<value type="java.lang.Integer">10</value>
	 	</constructor-arg>
	</bean>
</beans>

Test.java

public class Test {
	
	public String test(){
		return ActionSupport.SUCCESS;
	}

}


Redirect.java

public class Redirect {
	
	public String redirect(){
		return ActionSupport.SUCCESS;
	}

}

RandomString.java

public class RandomString {

	public RandomString() {
	}

	public static char createChar(int temp) {

		return (char) temp;
	}

	public static int createInt(char temp) {

		return (int) temp;
	}

	public static void createAsciiTable() {
		for (int z = 0; z < 256; z++) {
			char[] test3;
			test3 = new char[1];
			test3[0] = RandomString.createChar(z);
			String test2 = new String(test3);
			byte[] t3;
			t3 = test2.getBytes();
			int a2 = t3[0];
			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
			System.out.println("mitChar: " + RandomString.createChar(z) + " "
					+ RandomString.createInt(RandomString.createChar(z))
					+ " mitString: " + test2 + " " + a3);
		}

	}

	public static char createRandomChar() {

		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
		// 255

		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
				|| (temp > 122))

		{
			temp = createRandomChar();
			return (char) temp;
		}

		else {
			// System.out.println(temp);
			return (char) temp;

		}

	}

	public static String createRandomString(int length) {
		StringBuffer sb = new StringBuffer();
		for (int j = 0; j < length; j++) {
			sb.append(createRandomChar());
		}
		return sb.toString();
	}

}




--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Javier Lecuona (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476463#comment-13476463 ] 

Javier Lecuona commented on WW-3898:
------------------------------------

Sorry about that, didn't know that there where code tags. This is the first time I submit a bug.
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (WW-3898) Redirect Action calls wrong method

Posted by "Dave Newton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dave Newton updated WW-3898:
----------------------------

    Description: 
I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().

I've made a simple project that is very simple to test.

In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.

Here is my config

struts.xml

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

<struts>
	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
	<constant name="struts.devMode" value="false" />
	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
	<constant name="struts.action.extension" value="," />

	<package name="general" extends="struts-default">

		<action name="test" method="test"
			class="test.action.Test">
			<result name="success">/jsp/test.jsp</result>
		</action>
		
		<action name="redirect" method="redirect"
			class="test.action.Redirect">
			<result type="redirectAction">test</result>
		</action>
		
	</package>
</struts>
{code}

ApplicationContext.xml

{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<!-- Developer -->
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:security="http://www.springframework.org/schema/security"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
	xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">

	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
		<constructor-arg>
	 		<value type="java.lang.Integer">10</value>
	 	</constructor-arg>
	</bean>
</beans>
{code}

Test.java

{code:java}
public class Test {
	
	public String test(){
		return ActionSupport.SUCCESS;
	}

}
{code}

Redirect.java

{code:java}
public class Redirect {
	
	public String redirect(){
		return ActionSupport.SUCCESS;
	}

}
{code}

RandomString.java

{code:java}
public class RandomString {

	public RandomString() {
	}

	public static char createChar(int temp) {

		return (char) temp;
	}

	public static int createInt(char temp) {

		return (int) temp;
	}

	public static void createAsciiTable() {
		for (int z = 0; z < 256; z++) {
			char[] test3;
			test3 = new char[1];
			test3[0] = RandomString.createChar(z);
			String test2 = new String(test3);
			byte[] t3;
			t3 = test2.getBytes();
			int a2 = t3[0];
			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
			System.out.println("mitChar: " + RandomString.createChar(z) + " "
					+ RandomString.createInt(RandomString.createChar(z))
					+ " mitString: " + test2 + " " + a3);
		}

	}

	public static char createRandomChar() {

		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
		// 255

		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
				|| (temp > 122))

		{
			temp = createRandomChar();
			return (char) temp;
		}

		else {
			// System.out.println(temp);
			return (char) temp;

		}

	}

	public static String createRandomString(int length) {
		StringBuffer sb = new StringBuffer();
		for (int j = 0; j < length; j++) {
			sb.append(createRandomChar());
		}
		return sb.toString();
	}

}
{code}



  was:
I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().

I've made a simple project that is very simple to test.

In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.

Here is my config

struts.xml

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

<struts>
	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
	<constant name="struts.devMode" value="false" />
	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
	<constant name="struts.action.extension" value="," />

	<package name="general" extends="struts-default">

		<action name="test" method="test"
			class="test.action.Test">
			<result name="success">/jsp/test.jsp</result>
		</action>
		
		<action name="redirect" method="redirect"
			class="test.action.Redirect">
			<result type="redirectAction">test</result>
		</action>
		
	</package>
</struts>

ApplicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- Developer -->
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:security="http://www.springframework.org/schema/security"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
	xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">

	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
		<constructor-arg>
	 		<value type="java.lang.Integer">10</value>
	 	</constructor-arg>
	</bean>
</beans>

Test.java

public class Test {
	
	public String test(){
		return ActionSupport.SUCCESS;
	}

}


Redirect.java

public class Redirect {
	
	public String redirect(){
		return ActionSupport.SUCCESS;
	}

}

RandomString.java

public class RandomString {

	public RandomString() {
	}

	public static char createChar(int temp) {

		return (char) temp;
	}

	public static int createInt(char temp) {

		return (int) temp;
	}

	public static void createAsciiTable() {
		for (int z = 0; z < 256; z++) {
			char[] test3;
			test3 = new char[1];
			test3[0] = RandomString.createChar(z);
			String test2 = new String(test3);
			byte[] t3;
			t3 = test2.getBytes();
			int a2 = t3[0];
			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
			System.out.println("mitChar: " + RandomString.createChar(z) + " "
					+ RandomString.createInt(RandomString.createChar(z))
					+ " mitString: " + test2 + " " + a3);
		}

	}

	public static char createRandomChar() {

		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
		// 255

		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
				|| (temp > 122))

		{
			temp = createRandomChar();
			return (char) temp;
		}

		else {
			// System.out.println(temp);
			return (char) temp;

		}

	}

	public static String createRandomString(int length) {
		StringBuffer sb = new StringBuffer();
		for (int j = 0; j < length; j++) {
			sb.append(createRandomChar());
		}
		return sb.toString();
	}

}




    
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476992#comment-13476992 ] 

Lukasz Lenart commented on WW-3898:
-----------------------------------

Docs were updated

https://cwiki.apache.org/confluence/display/WW/Spring+Plugin

                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476968#comment-13476968 ] 

Lukasz Lenart commented on WW-3898:
-----------------------------------

First of all, you configured the application in wrong way. To use struts2-spring-plugin just drop the plugin jar into project's lib folder - it contains all is needed.

As I see the docs [1] about the plugin are wrong, instead
{code:xml}
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
{code}

should be

{code:xml}
<constant name="struts.objectFactory" value="spring" />
{code}

but as I said, just put the jar in the lib folder.

[1] http://struts.apache.org/2.x/docs/spring-plugin.html
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (WW-3898) Redirect Action calls wrong method

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart updated WW-3898:
------------------------------

    Fix Version/s: 2.3.6
    
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Javier Lecuona (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476963#comment-13476963 ] 

Javier Lecuona commented on WW-3898:
------------------------------------

Sure, just give me a couple of minutes
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13477895#comment-13477895 ] 

Lukasz Lenart commented on WW-3898:
-----------------------------------

No problem, I've learnt something new as well :-)
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>            Assignee: Lukasz Lenart
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test-struts2.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476962#comment-13476962 ] 

Lukasz Lenart commented on WW-3898:
-----------------------------------

Could you prepare a Maven based project or export it to ?
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (WW-3898) Redirect Action calls wrong method

Posted by "Javier Lecuona (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476463#comment-13476463 ] 

Javier Lecuona edited comment on WW-3898 at 10/15/12 9:16 PM:
--------------------------------------------------------------

Sorry about that, didn't know that there were code tags. This is the first time I submit a bug.
                
      was (Author: javiercbk):
    Sorry about that, didn't know that there where code tags. This is the first time I submit a bug.
                  
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (WW-3898) Redirect Action calls wrong method

Posted by "Javier Lecuona (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Javier Lecuona updated WW-3898:
-------------------------------

    Attachment:     (was: test.zip)
    
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test-struts2.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Javier Lecuona (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476986#comment-13476986 ] 

Javier Lecuona commented on WW-3898:
------------------------------------

Actually I made a simple project to test this issue in a reduced environment. I have a web app that it's currently working with this config and it was working fine until I came up with this. I will test your suggestion.
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Javier Lecuona (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13477888#comment-13477888 ] 

Javier Lecuona commented on WW-3898:
------------------------------------

WOW....you are right...I'm deeply sorry to bother you guys (and I'm also a bit embarrassed).
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>            Assignee: Lukasz Lenart
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test-struts2.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13477686#comment-13477686 ] 

Lukasz Lenart commented on WW-3898:
-----------------------------------

Hmmm... I think the problem is in Spring and how did you configure it ;-) Your bean testRandomString will be used to create each String in the application because you defined createRandomString() method as a factory method which returns String :P
And as Spring is now in charge of creating each framework component (in this case ActionInvocation and ActionProxy) it simple applies createRandomString() everywhere. Check the url when you call http://localhost:8080/test-struts2/redirect - it will contain also random strings ;-)

I've redefined your RandomString class as below:

{code:java}
	public static RandomString createRandomString(int length) {
		StringBuffer sb = new StringBuffer();
		for (int j = 0; j < length; j++) {
			sb.append(createRandomChar());
		}
		return new RandomString(sb.toString());
	}
{code}

and now everything works!

So next time be more careful using factory-method option ;-)
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test-struts2.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (WW-3898) Redirect Action calls wrong method

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart resolved WW-3898.
-------------------------------

    Resolution: Not A Problem
      Assignee: Lukasz Lenart
    
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>            Assignee: Lukasz Lenart
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test-struts2.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13477673#comment-13477673 ] 

Lukasz Lenart commented on WW-3898:
-----------------------------------

Does it happen all the time or just randomly ? I cannot reproduce your problem (I've used Jetty, will try with Tomcat now)
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test-struts2.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476765#comment-13476765 ] 

Lukasz Lenart commented on WW-3898:
-----------------------------------

You can upload files under More Actions -> Attach Files
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476993#comment-13476993 ] 

Lukasz Lenart commented on WW-3898:
-----------------------------------

Check the plugin

http://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/spring/src/main/resources/struts-plugin.xml

and the struts.properties

http://svn.apache.org/repos/asf/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/default.properties

search for struts.objectFactor and you will see that the proper configuration is:

struts.objectFactor = spring

                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Dave Newton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13478556#comment-13478556 ] 

Dave Newton commented on WW-3898:
---------------------------------

Verrrrry interesting; I can think of all sorts of mayhem to cause with this.

Nice analysis.
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>            Assignee: Lukasz Lenart
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test-struts2.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (WW-3898) Redirect Action calls wrong method

Posted by "Javier Lecuona (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Javier Lecuona updated WW-3898:
-------------------------------

    Attachment: test.zip

Here is my simple project. If you add Struts 2.3.4 or 2.3.4.1 dependencies and Spring 3.1 dependencies it should work, well it should be able to test the bug
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3898) Redirect Action calls wrong method

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13477675#comment-13477675 ] 

Lukasz Lenart commented on WW-3898:
-----------------------------------

Ok, got it :-) I had to execute redirect action.
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test-struts2.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (WW-3898) Redirect Action calls wrong method

Posted by "Javier Lecuona (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3898?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Javier Lecuona updated WW-3898:
-------------------------------

    Attachment: test-struts2.zip

Ok, here is my project with maven. just run mvn tomcat:run and it should be ready to test
                
> Redirect Action calls wrong method
> ----------------------------------
>
>                 Key: WW-3898
>                 URL: https://issues.apache.org/jira/browse/WW-3898
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Spring
>    Affects Versions: 2.3.4, 2.3.4.1
>         Environment: Mac OS X Lion 10.7.4
> java version "1.6.0_35"
> Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
> Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
>            Reporter: Javier Lecuona
>              Labels: Bug, Spring
>             Fix For: 2.3.6
>
>         Attachments: test-struts2.zip, test.zip
>
>
> I call an action and expect to be redirected to another action BUT instead I get java.lang.NoSuchMethodException. In my example Spring is in charge of constructing my Action object and I have a naive object that returns a random String. It turns out that this random string is being somehow mistaken by the action name, so I get something like java.lang.NoSuchMethodException: test.action.Test.TSldxhPcLq().
> I've made a simple project that is very simple to test.
> In the following example you can call "redirect" action and see the bug. I have a small zip with this test project but I'm not finding any upload button.
> Here is my config
> struts.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>  "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
>  "http://struts.apache.org/dtds/struts-2.1.7.dtd">
> <struts>
> 	<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
> 	<constant name="struts.devMode" value="false" />
> 	<!-- Prevents struts from appending .action ... use a comma for empty suffix --> 
> 	<constant name="struts.action.extension" value="," />
> 	<package name="general" extends="struts-default">
> 		<action name="test" method="test"
> 			class="test.action.Test">
> 			<result name="success">/jsp/test.jsp</result>
> 		</action>
> 		
> 		<action name="redirect" method="redirect"
> 			class="test.action.Redirect">
> 			<result type="redirectAction">test</result>
> 		</action>
> 		
> 	</package>
> </struts>
> {code}
> ApplicationContext.xml
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Developer -->
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:security="http://www.springframework.org/schema/security"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
> 	xmlns:tx="http://www.springframework.org/schema/tx"  xmlns:task="http://www.springframework.org/schema/task"
> 	xsi:schemaLocation="
>     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
> 	<bean id="testRandomKey" class="test.utils.RandomString" factory-method="createRandomString" lazy-init="false">
> 		<constructor-arg>
> 	 		<value type="java.lang.Integer">10</value>
> 	 	</constructor-arg>
> 	</bean>
> </beans>
> {code}
> Test.java
> {code:java}
> public class Test {
> 	
> 	public String test(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> Redirect.java
> {code:java}
> public class Redirect {
> 	
> 	public String redirect(){
> 		return ActionSupport.SUCCESS;
> 	}
> }
> {code}
> RandomString.java
> {code:java}
> public class RandomString {
> 	public RandomString() {
> 	}
> 	public static char createChar(int temp) {
> 		return (char) temp;
> 	}
> 	public static int createInt(char temp) {
> 		return (int) temp;
> 	}
> 	public static void createAsciiTable() {
> 		for (int z = 0; z < 256; z++) {
> 			char[] test3;
> 			test3 = new char[1];
> 			test3[0] = RandomString.createChar(z);
> 			String test2 = new String(test3);
> 			byte[] t3;
> 			t3 = test2.getBytes();
> 			int a2 = t3[0];
> 			int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
> 			System.out.println("mitChar: " + RandomString.createChar(z) + " "
> 					+ RandomString.createInt(RandomString.createChar(z))
> 					+ " mitString: " + test2 + " " + a3);
> 		}
> 	}
> 	public static char createRandomChar() {
> 		int temp = new Random().nextInt(256); // limitation of Ascii Char 33 to
> 		// 255
> 		if ((temp < 48) || (temp > 47 && temp < 65) || (temp > 90 && temp < 97)
> 				|| (temp > 122))
> 		{
> 			temp = createRandomChar();
> 			return (char) temp;
> 		}
> 		else {
> 			// System.out.println(temp);
> 			return (char) temp;
> 		}
> 	}
> 	public static String createRandomString(int length) {
> 		StringBuffer sb = new StringBuffer();
> 		for (int j = 0; j < length; j++) {
> 			sb.append(createRandomChar());
> 		}
> 		return sb.toString();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira