【问题标题】:Restlet jse2 client resource interface not visible from class loaderRestlet jse2 客户端资源接口在类加载器中不可见
【发布时间】:2011-11-29 18:13:02
【问题描述】:

我在 Google App Engine 中为我的 Restlet 服务器遵循了本教程:http://wiki.restlet.org/docs_2.0/13-restlet/21-restlet/318-restlet/303-restlet.html 它适用于 GWT 客户端。

现在我正在尝试使用 OSGi 和 Restlet 构建一个 jse2 桌面客户端。

OSGi 包中 Restlet 客户端的代码与提供的教程相同。

当我启动 OSGi Felix 框架时,我还启动了 org.restlet.jar 包,该包用于导出 restlet 框架包,并使用 toturail 中给出的此代码启动包:

ClientResource cr = new ClientResource("localhost:8888/contacts/123");
// Get the Contact object
ContactResource resource = cr.wrap(ContactResource.class);
Contact contact = resource.retrieve();

ContactResoure 接口与捆绑激活器在同一个包中,但我仍然收到这条奇怪的消息:java.lang.IllegalArgumentException: interface nl.nhl.minor.crm.desktop.restlet.ContactResource is not visible from类加载器

这个问题与 OSGi 或 Restlet 有关吗?我该如何解决这个问题?

OSGi 包的清单文件由 maven 包插件创建。

【问题讨论】:

    标签: maven osgi restlet


    【解决方案1】:

    加载类的正确方法很简单:

    ClientResource cr = new ClientResource("http://127.0.0.1:8888/contacts/123");
    Class<ContactResource> clazs = (Class<ContactResource>) cr.getClass().getClassLoader().loadClass("your.package.name.ClassName");
    cr.wrap(clazs);
    

    这个解决方案给您带来了另一个问题,org.restlet 包没有导入该类。

    请参阅import package without edit the manifest file in org.restlet 了解有关该问题的问题。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-21
    • 1970-01-01
    • 2011-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-24
    • 1970-01-01
    相关资源
    最近更新 更多