开发者

JBoss6 with RestEasy client

I want to consume a REST service in my web app (.war with 6.0.0.Final), and recently switched from jersey to resteasy (because of JBoss6 with REST client (jersey-client)).

My client code is this simple example (perfectly working when called from the console):

ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
RegisterBuiltin.register(providerFactory);

ClientRequest request = new ClientRequest(restUrl);
request.accept(MediaType.APPLICATION_XML);

ClientResponse<MyJaxbClass> response = request.get(MyJaxbClass.class);

At the beginning I hoped that everything for RESTeasy is available in JBoss, but while accessing the method I get this error:

Caused by: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod
  at java.lang.Class.getDeclaredConstructors0(Native Method)
  at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
  at java.lang.Class.getConstructor0(Class.java:2699)
  at java.lang.Class.newInstance0(Class.java:326)
  at java.lang.Class.newInstance(Class.java:308)
  at org.jboss.resteasy.client.ClientRequest.createDefaultExecutorInstance(ClientRequest.java:115)
  at org.jboss.resteasy.client.ClientRequest.getDefaultExecutor(ClientRequest.java:94)
  at org.jboss.resteasy.client.ClientRequest.<init>(ClientRequest.java:125)
  at my.own.MyRestEasyClient.members(MyRestEasyClient.java:42)

Well, not a big deal! Although I'm wondering why the deprecated commons-httpcomponents is used, I added commons-httpclient:commons-httpclient:3.1 to my .war. But the error did not disappeared. I double-checked that commons-httpclient-3.1.jar is in the war. Then I removed commons-httpcomponentsand addedorg.jboss.resteasy:resteasy-jaxrs:2.1.0.GAandorg.jboss.resteasy:resteasy-jaxb-provider:2.1.0.GA`. To avoid (maybe I'm already in) 开发者_运维知识库jar-hell I used the resteasy-version which is bundled with JBoss6, but now I'm getting this error:

Caused by: java.lang.annotation.AnnotationTypeMismatchException: Incorrectly
  typed data found for annotation element public abstract
  javax.xml.bind.annotation.XmlNsForm
  org.jboss.xb.annotations.JBossXmlSchema.elementFormDefault()
  (Found data of type Ljavax/xml/bind/annotation/XmlNsForm;.QUALIFIED)

This is not really specifict but I got similar errors if I bundle jars into my .war which are already available in JBoss. I've found ClassNotFound Exception when configuring RestEasy, but this seems not to be related to my issue.


We had the same problem a few days ago, but found this bug report that helped us https://issues.jboss.org/browse/JBAS-8841

To fix (As mentioned in the bug report):

I added commons-httpclient-3.1.jar in deployers/resteasy.deployer to correct the exception. Adding the jar to my webapp didn't worked

And this worked for us.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜