You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Gena Ganebnyi <gg...@nebulent.com> on 2010/11/10 11:38:23 UTC

action resolution seems to be not quite correct in Rest and Convention plugins

Hi All,

I have a struts2 project(2.2.1) configured to use both rest and conventions
plugin. Eevrything is configured according to guides, so nothing special
about configuration.
Till now everithings worked perfectly, but yesterday I came across strange
problem.

I had an action *xxx.actions.ApplicationController* that is a regular "rest"
controler. It is accesible via *localhost:8080/mywebapp/application* using
rest plugin syntax.
Since I need some things loaded via ajax I decided to add another action for
this. I placed it under *xxx.actions.ajax.AplicationTabsAction*. this is not
a "rest" action and simply replies on convention annotations.

public class ApplicationTabsAction extends ActionSupport {
 public String index() {
return SUCCESS;
}
 @Action(value="/ajax/application/summary")
public String summary() {
return SUCCESS;
}

}

In theory it should be accessible under *
http://localhost:8080/mywebapp/ajax/application/summary*
But in reality an error ocurres;

java.lang.NullPointerException
	at org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownActionMethod(ConventionUnknownHandler.java:412)
	at com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownMethod(DefaultUnknownHandlerManager.java:102)
	at org.apache.struts2.rest.RestActionInvocation.invokeAction(RestActionInvocation.java:87)
	at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)

Here is some debug output from struts:

2010-11-10 12:29:20,709 DEBUG CommonsLogger.java:68 - Creating an
DefaultActionProxy for namespace /ajax/application and action name
summary
2010-11-10 12:29:20,710 DEBUG CommonsLogger.java:68 - intercept
'/ajax/application/summary' {
2010-11-10 12:29:20,711 DEBUG CommonsLogger.java:68 - applied
invocation context locale=ru_RU
2010-11-10 12:29:20,711 DEBUG CommonsLogger.java:68 - before Locale=ru_RU
2010-11-10 12:29:20,711 DEBUG CommonsLogger.java:68 - Setting params NONE
2010-11-10 12:29:20,712 DEBUG CommonsLogger.java:68 - Setting static
parameters {}
2010-11-10 12:29:20,713 DEBUG CommonsLogger.java:68 - Setting params
2010-11-10 12:29:20,713 DEBUG CommonsLogger.java:68 - Skipping
Interceptor... Method [index] found in exclude list.
2010-11-10 12:29:20,714 DEBUG NavigationInterceptor.java:46 -
Injecting navigation
2010-11-10 12:29:20,714 DEBUG CommonsLogger.java:68 - Executing action
method = summary

After some investigation I found out that *
http://localhost:8080/mywebapp/ajax/application* invokes index()
method of *xxx.actions.ApplicationController
*that is quite right because according to conventions plugin this action
should be mapped to *localhost:8080/mywebapp/application* only.

If I change @Action(value="/ajax/application/summary") to let
say @Action(value="/ajax/applicationtab/summary") everythng works just fine
under *http://localhost:8080/mywebapp/ajax/applicationtab/summary*
*
*
Any ideas why it happens so?

Regards, Genadii