繁体   English   中英

JBoss6与RestEasy客户端

[英]JBoss6 with RestEasy client

我想在我的网络应用程序中使用REST服务(.war与6.0.0.Final),最近从jersey转为resteasy(因为JBoss6带有REST客户端(jersey-client) )。

我的客户端代码就是这个简单的例子(从控制台调用时非常有效):

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

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

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

一开始我希望在JBoss中可以使用RESTeasy的所有东西,但是在访问该方法时我得到了这个错误:

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)

好吧,没什么大不了的! 虽然我想知道为什么使用已弃用的commons-httpcomponents ,但我将commons-httpclient:commons-httpclient:3.1到我的.war中。 但错误并没有消失。 我仔细检查了commons-httpclient-3.1.jar是否在战争中。 然后我删除了commons-httpcomponents and added org.jboss.resteasy:resteasy-jaxrs:2.1.0.GA and org.jboss.resteasy:resteasy-jaxb-provider:2.1.0.GA`。 为了避免(也许我已经在)jar-hell我使用了与JBoss6捆绑在一起的resteasy-version,但是现在我收到了这个错误:

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)

这不是真正的具体但如果我把罐子捆绑到我的.war中已经可以在JBoss中使用,我也会遇到类似的错误。 在配置RestEasy时发现了ClassNotFound异常 ,但这似乎与我的问题没有关系。

我们几天前遇到了同样的问题,但发现了这个帮助我们的错误报告https://issues.jboss.org/browse/JBAS-8841

修复(如错误报告中所述):

我在deployers / resteasy.deployer中添加了commons-httpclient-3.1.jar来更正异常。 将jar添加到我的webapp无效

这对我们有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM