开发者

JBoss6 with REST client (jersey-client)

开发者 https://www.devze.com 2023-04-08 23:47 出处:网络
I want to consume a REST service in my web app (.war with 6.0.0.Final), but have problems adding 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>

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

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 {}

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/FeaturesAndPro开发者_如何学JAVAperties.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消