开发者

ClassLoader problem when using GWT RequestFactory with Grails

In order to get GWT RequestFactory running with Grails, I am using the following approach:

class GwtController extends RequestFactoryServlet {

    public GwtController() {
        super()
    }

    def index = {
        doPost request, response
    }

    @Override
    public ServletContext getServletContext() {
        return ServletContextHolder.servletContext
    }

    @Override
    public ServletConfig getServletConfig() {
        return new DummyServletConfig(getServletContext(),"grails");
    }
}

where DummyServletConfig is a simple implementation of Se开发者_如何学运维rvletConfig

This is working when deploying the app to tomcat. However, using testing or development mode, it is not. I was required to adjust the GWT Servlet in order to prevent it from using the wrong Class Loader:

In line 46 I changed

private static final RequestFactoryInterfaceValidator validator =
  new RequestFactoryInterfaceValidator(log,
      new RequestFactoryInterfaceValidator.ClassLoaderLoader(
          ServiceLayer.class.getClassLoader()));

to

private static final RequestFactoryInterfaceValidator validator = new RequestFactoryInterfaceValidator(
  log, new RequestFactoryInterfaceValidator.ClassLoaderLoader(
      Thread.currentThread()
                        .getContextClassLoader()));

Otherwise, it wouldn't find my Domain classes (which apparently do not reside in the GrailsRootLoader but in the Thread's class loader).

Now I would like to revert my GWT servlet to the official binary released by Google and I wonder how I can fix the incorrect ClassLoader in Grails or make the RequestFactoryServlet work correctly without altering the GWT source.


I hope that GWT 2.3 will fix your problem:

http://code.google.com/p/google-web-toolkit/issues/detail?id=6092

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜