使用GWT和Maven获得了UnsupportedActionException [英] Got UnsupportedActionException with GWT and Maven

查看:105
本文介绍了使用GWT和Maven获得了UnsupportedActionException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍在尝试使GWT和Maven能够正常工作.

I still trying to make my project with GWT and Maven works.

现在,我在ActionHandlers中遇到错误.

Now, i got errors in ActionHandlers.

我在示例和其他项目(与maven不兼容)中像教程中一样配置了Guice,它按预期方式工作,但是,在这个项目中,guice servlet似乎没有将Action绑定到ServerModule中的ActionHandler:

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);
    }
}

正如您所见,我也放置了一个sysout,但是它从未出现在控制台中.

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)

我只是想不通为什么它不起作用,我的web.xml也是正确的,无论如何,我认为代码是:

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.

推荐答案

我遇到了同样的问题,它是由Eclipse引起的.

I had the same problem and it was caused by Eclipse.

在项目首选项中,"Google-> Web应用程序-> war目录"设置设置为/src/main/webapp.通过此设置,Eclipse生成了rpc存根(和其他内容)到WEB-INF Directroy中,然后在构建应用程序时由maven复制.我不知道为什么,但是eclipse在构建时没有清除此文件.因此,使用了旧的rpc存根,而不是新的.

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.

此问题的解决方案是从webapp目录(和子目录)中删除所有生成的文件,并将"Google-> Web应用程序-> war目录"更改为目标目录.至少对我来说这是有效的.

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.

这篇关于使用GWT和Maven获得了UnsupportedActionException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆