问题
I still trying to make my project with GWT and Maven works.
Now, i got errors in ActionHandlers.
I configured Guice like tutorials in examples and in other project (that isnt working with maven) it works as expected, but, in this project, seems like the guice servlet doesnt bind the Action to ActionHandler in ServerModule:
public class ServerModule extends HandlerModule
{
@Override
protected void configureHandlers()
{
System.out.println("ServerModule.configureHandlers()");
install(new ControllerModule());
bindHandler(SalvarUsuarioAction.class, SalvarUsuarioActionHandler.class);
}
}
I put a sysout too, as you can see, but it never appears in console.
When I try to execute the action, I got this error:
com.gwtplatform.dispatch.shared.UnsupportedActionException: No handler is registered for br.com.tests.shared.commands.usuario.salvar.SalvarUsuarioAction
at com.gwtplatform.dispatch.shared.UnsupportedActionException_FieldSerializer.instantiate(UnsupportedActionException_FieldSerializer.java:16)
at com.gwtplatform.dispatch.shared.UnsupportedActionException_FieldSerializer.create(UnsupportedActionException_FieldSerializer.java:25)
at com.google.gwt.user.client.rpc.impl.SerializerBase.instantiate(SerializerBase.java:115)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:111)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:216)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
I just cant figure out why its not working, my web.xml is correct too, I think, anyway, the code is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<listener>
<listener-class>br.com.testes.server.guice.GuiceServletConfig</listener-class>
</listener>
<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>
<filter>
<filter-name>CacheFilter</filter-name>
<filter-class>br.com.testes.server.filter.CacheFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CacheFilter</filter-name>
<url-pattern>/gwt/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>jUnitHostImpl</servlet-name>
<servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>jUnitHostImpl</servlet-name>
<url-pattern>/br.com.digitaldoc.detran.DetranJUnit/junithost/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jUnitHostImpl</servlet-name>
<url-pattern>/Testes/junithost/*</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Testes.html</welcome-file>
</welcome-file-list>
</web-app>
Am I doing something wrong? Thanks in advance.
回答1:
I had the same problem and it was caused by Eclipse.
In project preferences the 'Google -> Web Application -> war directory' setting was set to /src/main/webapp. With this setting Eclipse generated rpc stubs (and other stuff) into WEB-INF directroy, which was then copied by maven while building application. I don't know why but eclipse didn't clean this files while building. So the old rpc stubs were used instead of the new.
The solution to this problem is removing all generated files from webapp directory (and subdirs), and changing 'Google -> Web Application -> war directory' to your target/ directory. That worked in my case at least.
回答2:
I created a new project with maven and it worked. Cant figure out what happened here.
If someone have an update, please tell me. Thanks.
来源:https://stackoverflow.com/questions/8415720/got-unsupportedactionexception-with-gwt-and-maven