带有REST客户端的JBoss6(jersey-client) [英] JBoss6 with REST client (jersey-client)

查看:126
本文介绍了带有REST客户端的JBoss6(jersey-client)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Web应用程序(带有6.0.0.Final的.war)中使用REST服务,但是在添加jersey-client libs时遇到问题:

I want to consume a REST service in my web app (.war with 6.0.0.Final), but have problems adding jersey-client libs:

<dependency>
  <groupId>com.sun.jersey</groupId>
  <artifactId>jersey-client</artifactId>
  <version>1.9.1</version>
  <type>jar</type>
  <scope>compile</scope>
</dependency>

使用此配置,在JBoss启动期间会出现以下错误:

With this configuration I get the following error during JBoss startup:

08:11:28,297 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].
[localhost].[/test]] Exception starting filter Resteasy:
java.lang.ClassCastException: com.aht.erp.web.rest.JaxRsActivator
cannot be cast to javax.ws.rs.core.Application

我的Web应用程序已激活并带有以下注释的JAX-RS:

My webapp has an activated JAX-RS with the following annotation:

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/rest")
public class JaxRsActivator extends Application {}

如果不添加依赖项,我的战争将开始,但是当调用jersey-client时,我当然会得到NoClassDefFoundError: com/sun/jersey/api/client/config/ClientConfig.通过排除jersey-core,我得到以下错误:NoClassDefFoundError: com/sun/jersey/core/util/FeaturesAndProperties.

If I don't add the dependecy my war starts fine, but of course I get a NoClassDefFoundError: com/sun/jersey/api/client/config/ClientConfig when the jersey-client is called. By excluding jersey-core I get this error: NoClassDefFoundError: com/sun/jersey/core/util/FeaturesAndProperties.

推荐答案

我相信问题是您正在尝试在Web应用程序中混合使用两种不同的jax-rs实现.对于您的RESTful资源,您正在使用RESTEasy,而在客户端,您想使用Jersey-所有这些都由同一jar使用.但是,Jersey客户依赖于Jersey核心,该核心与RESTEasy冲突.因此,您将不得不依靠RESTEasy客户端API,或者也要在服务器端切换到Jersey.

I believe the problem is that you are trying to mix two different jax-rs implementations in your web app. For your RESTful resource you are using RESTEasy, while on the client side you want to use Jersey - all utilized by the same jar. However the Jersey client depends on Jersey core, which conflicts with RESTEasy. So, you'll either have to rely on RESTEasy client API, or switch to Jersey for your server-side as well.

这篇关于带有REST客户端的JBoss6(jersey-client)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆