【问题标题】:GWT 2.4 Integration With SpringGWT 2.4 与 Spring 的集成
【发布时间】:2011-09-13 07:44:26
【问题描述】:

我目前正在开发 GWT 2.4 / Spring 3 应用程序,并希望使用 RequestFactory API 与 Spring 服务进行通信。

从 GWT 2.4 开始,我看到 RequestFactoryServlet(ThreadLocal 的添加)发生了一些变化,如何轻松集成它们?我不使用 ActiveRecord 样式,而是使用 DAO/Service。

我搜索并发现要从 2.4 开始将 GWT 与 Spring 集成,您只需要创建一个自定义 ServiceLocator 来公开您的 Spring bean。

public class SpringServiceLocator implements ServiceLocator {

public Object getInstance(Class<?> clazz) {
    ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(
            RequestFactoryServlet.getThreadLocalServletContext());
    return context.getBean(clazz);
}

}

您需要按照 Google 文档中的说明配置 RequestFactoryServlet。

我遵循了这些步骤,但是当 GWT 客户端向后端发出请求时,我收到了这个异常:

    Sep 13, 2011 7:42:34 AM com.google.web.bindery.requestfactory.server.RequestFactoryServlet doPost
SEVERE: Unexpected error
java.lang.ArrayIndexOutOfBoundsException: 1
    at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.processInvocationMessages(SimpleRequestProcessor.java:425)
    at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:217)
    at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:125)
    at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.doPost(RequestFactoryServlet.java:118)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:324)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
[ERROR] 500 - POST /gwtRequest (127.0.0.1) 1420 bytes

我错过了配置吗??

【问题讨论】:

  • 你能把RequestFactoryServlet的配置贴出来吗?

标签: spring gwt gwt-rpc


【解决方案1】:

我找到了问题,这是因为我没有在 Lib 文件夹中使用 GWT 2.4 库。

我确实写了一篇小文章,清楚地描述了如何将 Spring 与 GWT 2.4 集成 => http://crazygui.wordpress.com/2011/09/23/spring-gwt-integration-using-the-requestfactory-api/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-10
    • 2013-05-29
    • 1970-01-01
    • 2011-06-29
    • 1970-01-01
    • 1970-01-01
    • 2012-12-04
    • 2013-02-17
    相关资源
    最近更新 更多