I have a simple action and result classes. Handler for this just increment variable in action and returns it in result. Action
public class IncrementCounter implements Action<IncrementCounterResult> {
private int amount;
/** For serialization only. */
public IncrementCounter(){}
public IncrementCounter(int amount){
this.amount = amount;
}
public int getAmount() {
return amount;
}
}
Result
public class IncrementCounterResult implements Result {
private int amount;
private int current;
/** For serialization only. */
public IncrementCounterResult(){}
public IncrementCounterResult(int amount, int current){
this.amount = amount;
this.current = current;
}
public int getAmount() {
return amount;
}
public int getCurrent() {
return current;
}
}
I have an action module, where i bind action on handler. ActionsModule
public class ActionsModule extends ActionHandlerModule {
@Override
protected void configureHandlers() {
bindHandler(IncrementCounter.class, IncrementCounterHandler.class);
}
}
DispatchServletModule
public class DispatcherServletModule extends ServletModule {
@Override
protected void configureServlets() {
serve("/dispatch").with(GuiceStandardDispatchServlet.class);
}
}
Handler, which increment field in action and returns it in result.
public class IncrementCounterHandler implements ActionHandler<IncrementCounter, IncrementCounterResult> {
private int current = 0;
public Class<IncrementCounter> getActionType() {
return IncrementCounter.class;
}
public IncrementCounterResult execute(IncrementCounter action, ExecutionContext context) throws ActionException {
current += action.getAmount();
return new IncrementCounterResult(action.getAmount(), current);
}
public void rollback(IncrementCounter action, IncrementCounterResult result, ExecutionContext context) throws ActionException {
current = result.getCurrent() - result.getAmount();
}
}
And the last one is listener:
public class RpcCommandGuiceConfig extends GuiceServletContextListener {
@Override
protected Injector getInjector() {
return Guice.createInjector(new ServerDispatchModule(), new ActionsModule());
}
}
Here is my web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>server.RpcCommandGuiceConfig</listener-class>
</listener>
<welcome-file-list>
<welcome-file>Module.html</welcome-file>
</welcome-file-list>
</web-app>
I call dispatch.execute when button clicked. and code jumps in onFailure section. I have this in log :
WARN] 404 - POST /Module/dispatch (127.0.0.1) 1380 bytes
Request headers
Host: 127.0.0.1:8888
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
X-GWT-Permutation: HostedMode
X-GWT-Module-Base: http://127.0.0.1:8888/Module/
Content-Type: text/x-gwt-rpc; charset=utf-8
Referer: http://127.0.0.1:8888/Module/Module.html?gwt.codesvr=127.0.0.1:9997
Content-Length: 238
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Can anybody help to resolve this problem ?
... Here gwt file
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0//EN"
"http://google-web-toolkit.googlecode.com/svn/releases/2.0/distro-source/core/src/gwt-module.dtd">
<module>
<source path="client"/>
<source path="shared"/>
<source path="server"/>
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.mvp4g.Mvp4gModule"/>
<inherits name="org.moxieapps.gwt.highcharts.Highcharts"/>
<inherits name="net.customware.gwt.dispatch.Dispatch" />
<inherits name="com.google.gwt.inject.Inject" />
<entry-point class='client.Module'/>
</module>