File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts 2.3.16 and redirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2.3.16 and redirect " Watch "Struts 2.3.16 and redirect " New topic
Author

Struts 2.3.16 and redirect

Jeremy Jardin
Greenhorn

Joined: Dec 27, 2013
Posts: 10
Hi,

I developped a webapp with struts 2.2.6, and I have to upgrade to 2.3.16. (security :http://struts.apache.org/release/2.3.x/docs/s2-019.html)

It worked using "redirect" in the global-results tag like this :

<global-results>
<result name="sessionDown" type="tiles">expired</result>
<result name="success_no_form" type="redirect">${url}</result>
</global-results>




Each time my actions return success_no_form, I've got that error :
javax.servlet.ServletException: L'exécution du filtre (Filter) a lancé une exception

cause mère

java.lang.AbstractMethodError: org.apache.struts2.dispatcher.StrutsResultSupport$1.evaluate(Ljava/lang/Object;)Ljava/lang/Object;
com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:187)
com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:118)
com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:62)
org.apache.struts2.dispatcher.StrutsResultSupport.conditionalParse(StrutsResultSupport.java:198)
org.apache.struts2.dispatcher.ServletActionRedirectResult.execute(ServletActionRedirectResult.java:166)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:361)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:251)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
fr.gouv.finances.douane.dnsce.corintheng.struts.interceptors.NavigationInterceptor.intercept(NavigationInterceptor.java:33)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
fr.gouv.finances.douane.dnsce.corintheng.struts.interceptors.ActionFormulaireInterceptor.intercept(ActionFormulaireInterceptor.java:117)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
fr.gouv.finances.douane.dnsce.corintheng.struts.interceptors.SessionChecker.intercept(SessionChecker.java:58)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
fr.gouv.finances.douane.dnsce.corintheng.struts.interceptors.ModelInterceptor.doIntercept(ModelInterceptor.java:78)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)



Any help ?

Thank you

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8996
    
    9

Welcome to the JavaRanch.
If I understand parameters in configuration elements correctly, if you have a result set up like so:

Your action should have a "getUrl" method that returns a valid URL.
Since you have left out some information, like what you expect this example to do, what your action code looks like and if it works without "redirect" specified, this is mostly guesswork on my account.


[How To Ask Questions On JavaRanch]
Jeremy Jardin
Greenhorn

Joined: Dec 27, 2013
Posts: 10
Sure, I've got a getUrl method.
That method returns an URL, the one I want to redirect to when my action return "success-no-form" String.

I used that mechanism using struts 2.2.6, and it doesn't work anymore since I upgraded to struts2.3.16.

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8996
    
    9

I took a quick look through the version notes of all the releases between 2.3.16 and 2.2.3 (was there even a 2.2.6? I don't see it) and I don't see any mention of a change. That's not to say they didn't bump into something when fixing something else or the fix may have been in a dependency (from the stack trace, perhaps Xwork).
Anyway, you still haven't shown us your code or how to reproduce the problem, so I'm still guessing. Have a look at this. The better question you ask, the more help we can be.
Jeremy Jardin
Greenhorn

Joined: Dec 27, 2013
Posts: 10
Ok, here are more details

This is my pom.xml file :




Then, there is several actions that return "success_no_form" string.
I focused on one of them, that surely set the url param, with getUrl() method.

I compile with java 6, and the webapp runs on tomcat6.

Maybe i forgot something ?

Thank you for your help.

Jeremy Jardin
Greenhorn

Joined: Dec 27, 2013
Posts: 10
Ok, I tried something else :


<result name="success_no_form" type="redirect">www.google.com</result>


That works !!
So, the problem is around "${url}".
<result name="success_no_form" type="redirect">${url}</result>


I checked, the method getUrl() exists, is public, and return a correct url.

Maybe something to look with Ognl ?
Jeremy Jardin
Greenhorn

Joined: Dec 27, 2013
Posts: 10
I precise the problem... I thought the matter was near global-results and redirect attribute, but, I was wrong.

I used to call session var from my struts.xml file using EL notation like that " ${url} " but it doesn't work anymore
with new struts version. (security ?)

I'm looking for a workaround.... ?

Thank for your help !
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8996
    
    9

First, the Parameters in Configuration Results documentation specifically mentions actions and does not mention sessions, so I would assume that one could not use a session variable.
Second, the OGNL documentation has specific syntax in the examples for accessing a session variable. Perhaps tweaking the syntax may work?
Jeremy Jardin
Greenhorn

Joined: Dec 27, 2013
Posts: 10
Ok, the code I wrote is exactly the one described on that link : Parameters in Configuration Results
You're write, I'm talking about session but I'm wrong, my variable url is an action attribute.

But, it seems that since the 2.3.15 version of struts, it doesn't work anymore.

I really don't know how to make it run again
Jeremy Jardin
Greenhorn

Joined: Dec 27, 2013
Posts: 10
I tried to apply that example : Parameters in configuration results.

It doesn't work with struts-2.3.16... is there a workaround ?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8996
    
    9

Please read this: ItDoesntWorkIsUseless

I created an action like so:


added the following to my struts.xml:


then created a noFormPage.jsp to indicate success and epicFail.jsp to indicate failure.
When I go to the URL /cpta, I get the noFormPage.jsp returned, which means that the code in the example is working.
Jeremy Jardin
Greenhorn

Joined: Dec 27, 2013
Posts: 10
Sorry, for the 'itdoesntwork" ;-)

So, I did that :

<action name="ActionTestCpta" class="com.struts.actions.test.TestAction2" method="execute">
<result name="success">/jsp/commons/epicFail.jsp</result>
<result name="success_no_form" type="redirect">${url}</result>
</action>


I did that :

public class TestAction extends ActionSupport {

private String url = "/jsp/commons/noFormPage.jsp";

public String execute(){
System.out.println("ConfigurationParameterTestAction");
return "success_no_form";
}

public String getUrl(){
return url;
}

public void setUrl(String u){
url = u;
}


Then, I created a noFormPage.jsp to indicate success and epicFail.jsp to indicate failure.


When I go to the URL, this is what I got :

xception

javax.servlet.ServletException: L'exécution du filtre (Filter) a lancé une exception

cause mère

java.lang.AbstractMethodError: org.apache.struts2.dispatcher.StrutsResultSupport$1.evaluate(Ljava/lang/Object;)Ljava/lang/Object;
com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:187)
com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:118)
com.opensymphony.xwork2.util.TextParseUtil.translateVariables(TextParseUtil.java:62)
org.apache.struts2.dispatcher.StrutsResultSupport.conditionalParse(StrutsResultSupport.java:198)
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:185)
org.apache.struts2.dispatcher.ServletRedirectResult.execute(ServletRedirectResult.java:161)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:361)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265)
org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:251)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:128)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)

note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/6.0.35.


Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8996
    
    9

So what's the difference between my app and yours? You said you upgraded Struts. How did you do it? Did you account for all the dependencies?
Jeremy Jardin
Greenhorn

Joined: Dec 27, 2013
Posts: 10

<dependency>
<groupId>com.opensymphony</groupId>
<artifactId>xwork</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.16</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
<version>2.3.16</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.9</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>displaytag</groupId>
<artifactId>displaytag</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-run</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>


This is my pom.xml... maybe I'm using a wrong version of something ?
I forgot to upgrade a dependency ?
How do your pom look like ?

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8996
    
    9

There's one problem:


The Xwork version must match the Struts version. Unfortunately, I don't have any Maven experience, but you'd better go through that list of dependencies carefully to avoid version errors. I thought Struts had a single Maven dependency...
In any case, if you download the Struts distribution, the "lib" directory will have the correct version of all the dependencies, so you can check against that.
Jeremy Jardin
Greenhorn

Joined: Dec 27, 2013
Posts: 10
Yes !

The xwork library changed his groupId... I thought I used the latest one using :
<dependency>
<groupId>com.opensymphony</groupId>
<artifactId>xwork</artifactId>
<version>2.1.3</version>
</dependency>


but, with your help, I understood that this version does not match the struts version.
I Found the good version in another groupID :
<dependency>
<groupId>org.apache.struts.xwork</groupId>
<artifactId>xwork-core</artifactId>
<version>2.3.16</version>
</dependency>


And, that works.

Thank you very much for your help.

Best regards,
Jeremy.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8996
    
    9

Good to hear you got it working.
Make sure to check the other dependencies in your pom to make sure you won't have any other odd problems.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2.3.16 and redirect