Huang Yujie created WW-4472:
-------------------------------
Summary: @InputConfig annotation is not working when integrating
with spring aop
Key: WW-4472
URL: https://issues.apache.org/jira/browse/WW-4472
Project: Struts 2
Issue Type: Bug
Components: Annotations
Affects Versions: 2.3.20
Reporter: Huang Yujie
Priority: Minor
when configuration a action with the annotation
@Action(value = "/doSubmitCity")
@InputConfig(methodName = "validationFail")
public void doSubmitCity()
{
//The action implementation
}
The action class is integration with spring aop. (CGLIB proxy)
And use struts validation framework to do the data validation.
When the data validation fails.
tracing the code to
DefaultWorkflowInterceptor.java
protected String processInputConfig(final Object action, final String
method, final String currentResultName) throws Exception {
String resultName = currentResultName;
InputConfig annotation = action.getClass().getMethod(method,
EMPTY_CLASS_ARRAY).getAnnotation(InputConfig.class);
if (annotation != null) {
if (!annotation.methodName().equals("")) {
Method m = action.getClass().getMethod(annotation.methodName());
resultName = (String) m.invoke(action);
} else {
resultName = annotation.resultName();
}
if (LOG.isDebugEnabled()) {
LOG.debug("Changing result name from [#0] to [#1] because of
processing annotation [#2] on action [#3]",
currentResultName, resultName,
InputConfig.class.getSimpleName(), action);
}
}
return resultName;
}
This code, action.getClass().getMethod(method,
EMPTY_CLASS_ARRAY).getAnnotation(InputConfig.class)
cannot get any annotation because the class is proxied.
The following stack trace is printing in the log:
Could not find action or result: /test-extjs/login/doLogin.action
No result defined for action com.huawei.test.action.login.LoginAction and
result input
at
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
at
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)
at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
But at the same time, the @Action annotation is still working fine.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)