Java Glassfish中的ResteasyProviderFactory异常
我在使用RESTEasy提供的客户机框架调用RESTful Web服务时遇到了一些问题。当我尝试注册ResteasyProviderFactory时,我得到了一个ClassCastException,没有其他的功能 代码如下:Java Glassfish中的ResteasyProviderFactory异常,java,rest,httpclient,resteasy,Java,Rest,Httpclient,Resteasy,我在使用RESTEasy提供的客户机框架调用RESTful Web服务时遇到了一些问题。当我尝试注册ResteasyProviderFactory时,我得到了一个ClassCastException,没有其他的功能 代码如下: RegisterBuiltin.register(ResteasyProviderFactory.getInstance()); LifeGoalClient leClient = ProxyFactory.create(LifeGoalClient.cl
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;
我正在使用Glassfish 3.0.1和Resteasy 2.2.1
我在网上搜索,但没有找到解决方案,也没有相关信息。
如果有人有解决方案或其他方法,请帮助我
提前感谢这是由jax-rs实现-jersey和resteasy冲突引起的。 为了防止上述错误,您可以添加
<context-param>
<param-name>resteasy.use.deployment.sensitive.factory</param-name>
<param-value>false</param-value>
</context-param>
resteasy.use.deployment.sensitive.factory
假的
在web.xml中
通过这样做,resteasy将选择ResteasyProviderFactory的实例。我在glassfish中通过在类路径“META-INF/services”中添加名为javax.ws.rs.ext.RuntimeDelegate的文件强制resteasy覆盖jersey,该文件仅包含以下行: org.jboss.resteasy.spi.ResteasyProviderFactory
然而,对我来说,在我尝试使用resteasy cdi之前,一切似乎都很好。将最后一个工件添加到我的依赖项中并配置所需的上下文参数确实发现了同样的classcast问题。我对此进行了大量研究,没有发现任何无用的东西,只是找到了一些不太管用的解决方法。我认为在这种情况下,将球衣换成RestEasy是更好的选择。
<context-param>
<param-name>resteasy.use.deployment.sensitive.factory</param-name>
<param-value>false</param-value>
</context-param>