尝试将 GWT 集成到 OSGi 包中

发布于 2024-11-07 09:10:04 字数 525 浏览 4 评论 0原文

我正在尝试将 GWT 与 OSGi (Equinox) 集成,为我的模块化系统的其余部分提供基于 Web 的 UI。到目前为止,我已经成功地将 GWT servlet 嵌入到 OSGi 模块中。

我使用的是 Eclipse GWT 插件生成的 GWT 示例代码项目,它由 3 个包组成:客户端、服务器和共享。服务器包(ui.server.GreetingServiceImpl)中的类实现了客户端包(ui.client.GreetingService)中的接口,并且它们都在同一个包中捆。

当我尝试从客户端网页进行远程过程调用时,我收到错误:

IncompleteRemoteServiceException:无法在默认类加载器中找到请求的接口“ui.client.GreetingService”

我收集该类是类加载器找不到,但我不知道如何解决这个问题。我可以通过请求或导入其他包中的类来访问它们,但不能访问与实现类位于同一包中的接口。有人能指出我正确的方向吗?我已经谷歌搜索了几个小时了。

I am trying to integrate GWT with OSGi (Equinox) to provide a web based UI for the rest of my modular system. So far I've managed to embed the GWT servlet in the OSGi module.

I am using the GWT sample code project generated by the Eclipse GWT plugin, which consists of 3 packages: client, server and shared. The class in the server package (ui.server.GreetingServiceImpl) implements the interface in the client package (ui.client.GreetingService), and all of them are in the same bundle.

When I try to make a Remote Procedure Call from the client side web page I get the error:

IncompatibleRemoteServiceException: Could not locate requested interface 'ui.client.GreetingService' in default classloader

I gather that the class was not found by the classloader, but I don't know how to fix this. I can access classes in other bundles by requiring or importing them, but not the interface that is in the same bundle as the implementing class. Could anyone point me in the right direction? I've been googling for hours.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七度光 2024-11-14 09:10:04

需要在 GreetingServiceImpl 上重写 HttpServlet 的“服务”方法:

@Override 
protected void service(HttpServletRequest req, HttpServletResponse resp) 
        throws ServletException, IOException { 
    // Cache the current thread 
    Thread currentThread = Thread.currentThread(); 
    // We are going to swap the class loader 
    ClassLoader oldContextClassLoader = 
    currentThread.getContextClassLoader(); 
    currentThread.setContextClassLoader(this.getClass().getClassLoader()); 
    super.service(req, resp); 
    currentThread.setContextClassLoader(oldContextClassLoader); 
} 

因此,应用程序在 Equinox 上运行!

It is needed to override method 'service' from HttpServlet on your GreetingServiceImpl:

@Override 
protected void service(HttpServletRequest req, HttpServletResponse resp) 
        throws ServletException, IOException { 
    // Cache the current thread 
    Thread currentThread = Thread.currentThread(); 
    // We are going to swap the class loader 
    ClassLoader oldContextClassLoader = 
    currentThread.getContextClassLoader(); 
    currentThread.setContextClassLoader(this.getClass().getClassLoader()); 
    super.service(req, resp); 
    currentThread.setContextClassLoader(oldContextClassLoader); 
} 

Thus, the application runs on Equinox!!

2024-11-14 09:10:04

IncompleteRemoteServiceException 表示来自 GUI 的 RPC 调用未找到 @RemoteService 注释指定的接口。

您可以发布带有源代码的项目吗?

顺便说一句,您还可以看看这个项目:
http://code.google.com/p/gwt-in-osgi/

IncompatibleRemoteServiceException means that the RPC call from the GUI didn't found the interface specified by the @RemoteService annotation.

Can you post your project with source codes ?

BTW you can also have a look at this project:
http://code.google.com/p/gwt-in-osgi/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文