Glassfish 中的 ResteasyProviderFactory 异常

发布于 2024-11-11 13:24:30 字数 793 浏览 2 评论 0原文

我在使用 RESTEasy 提供的客户端框架调用 RESTful Web 服务时遇到一些问题。当我尝试注册 ResteasyProviderFactory 时,我收到了 ClassCastException 并且没有其他任何作用。

代码如下:

    RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
    LifeGoalClient leClient = ProxyFactory.create(LifeGoalClient.class, "http://localhost:8080/TutorFinanceiro");
    List<LifeGoal> lifeGoals = leClient.getLifeGoals();
    JOptionPane.showMessageDialog(null, lifeGoals);
    return lifeGoals;

例外情况:

    java.lang.ClassCastException: com.sun.jersey.server.impl.provider.RuntimeDelegateImpl cannot be cast to org.jboss.resteasy.spi.ResteasyProviderFactory

我使用的是 Glassfish 3.0.1 和 Resteasy 2.2.1。

我在网上搜索但没有找到解决方案或没有与此相关的信息。 如果有人有解决方案或替代方法,请帮助我!

提前致谢

I'm having some trouble invoking a RESTful webservice using the Client Framework provided by RESTEasy. When I try to register the ResteasyProviderFactory I got a ClassCastException and nothing more works.

Here's the code:

    RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
    LifeGoalClient leClient = ProxyFactory.create(LifeGoalClient.class, "http://localhost:8080/TutorFinanceiro");
    List<LifeGoal> lifeGoals = leClient.getLifeGoals();
    JOptionPane.showMessageDialog(null, lifeGoals);
    return lifeGoals;

And the exception:

    java.lang.ClassCastException: com.sun.jersey.server.impl.provider.RuntimeDelegateImpl cannot be cast to org.jboss.resteasy.spi.ResteasyProviderFactory

I'm using Glassfish 3.0.1 and Resteasy 2.2.1.

I searched through the web but found no solution or no relevant info in respect to this.
If anyone have a solution or an alternative way of doing this, please help me!

Thanks in advance

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

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

发布评论

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

评论(2

海拔太高太耀眼 2024-11-18 13:24:30

我确实通过在“META-INF/services”的类路径中添加一个名为 javax.ws.rs.ext.RuntimeDelegate 的文件来强制在 glassfish 中的 jersey 上实现 Resteasy,该文件仅包含以下行:
org.jboss.resteasy.spi.ResteasyProviderFactory

然而,对我来说,一切似乎都工作正常,直到我尝试使用resteasy-cdi。将最后一个工件添加到我的依赖项并配置所需的上下文参数确实发现了相同的类广播问题。

I did force resteasy over jersey in glassfish by adding a file named javax.ws.rs.ext.RuntimeDelegate in the class path at "META-INF/services", wich contain only the following line :
org.jboss.resteasy.spi.ResteasyProviderFactory

However, for me, all seemed to work fine until I try to use resteasy-cdi. Adding that last artifact to my dependencies and configuring the required context-param did dig up the same classcast problem.

So尛奶瓶 2024-11-18 13:24:30

这是由 jax-rs 实现 - jersey 和 Resteasy 冲突引起的。
为了防止上面的错误,你可以

<context-param>
    <param-name>resteasy.use.deployment.sensitive.factory</param-name>
    <param-value>false</param-value>
</context-param>

在你的web.xml中添加。

通过这样做,resteasy 将选择 ResteasyProviderFactory 的实例。

This is caused by conflicting jax-rs implementation - jersey and resteasy.
In order to prevent the error above, you can add

<context-param>
    <param-name>resteasy.use.deployment.sensitive.factory</param-name>
    <param-value>false</param-value>
</context-param>

in your web.xml.

By doing so, resteasy will choose instance of ResteasyProviderFactory.

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