2017-05-08 22 views
0

私はresteasyクライアントを動作させるためにさまざまな方法を試しましたが、エラーが発生しました。 java.lang.LinkageErrorの:ここORG /のjboss/RESTEasyに/クライアント/ jaxrs /内部/ ClientConfigurationresteasyクライアントを動作させることができません

をリンクに失敗しましたが、私はPOSTとGETできるクライアントとして

public void createIssue() { 
    issue = new Issue(); 
    ResteasyClient client = new ResteasyClientBuilder().build(); 
    ResteasyWebTarget target = client.target("api-being-posted-to"); 
    Response response = target.request().header("Authorization: ", "Basic Foo") 
      .post(Entity.entity(issueJson, "application/json")); 
} 

を使用している方法であり、これは同じデータを使用していますが、私は異なるデータを使ってクライアント作業を行い、別の場所に投稿して、常に同じエラーを表示しようとしました。ここに私のポンポンがあります:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<groupId>org.foo.bar</groupId> 
<artifactId>foo</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>war</packaging> 
<name>example</name> 

<dependencies> 
    <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-jaxrs</artifactId> 
     <version>3.1.0.Final</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-client</artifactId> 
     <version>3.1.0.Final</version> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>jaxrs-api</artifactId> 
     <version>3.0.8.Final</version> 
    </dependency> 

    <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-jackson-provider</artifactId> 
     <version>3.1.0.Final</version> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.3</version> 
     </plugin> 
    </plugins> 
</build> 

、ここでは私のweb.xmlはそれが助け場合、私は、JBoss EAP 6.4を使用してい

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
id="WebApp_ID" version="3.0"> 

<servlet-mapping> 
    <servlet-name>resteasy-servlet</servlet-name> 
    <url-pattern>/rest/*</url-pattern> 
</servlet-mapping> 

<context-param> 
    <param-name>resteasy.scan</param-name> 
    <param-value>true</param-value> 
</context-param> 

<context-param> 
    <param-name>resteasy.servlet.mapping.prefix</param-name> 
    <param-value>/rest</param-value> 
</context-param> 

<listener> 
    <listener-class> 
     org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap 
     </listener-class> 
</listener> 

<servlet> 
    <servlet-name>resteasy-servlet</servlet-name> 
    <servlet-class> 
     org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher 
    </servlet-class> 
</servlet> 

です。

答えて

0
  1. は、私の知る限りは、JBoss EAP 6.4でのRESTEasyの提供バージョンを伝えることができるよう3.0.21.Finalありません3.1.0.Finalしかし、あなたは(参照のためhttps://developer.jboss.org/thread/262213を参照)が変更されている場合があります。

  2. あなたのresteasyライブラリ(3.0.8.Final for jaxrs-api)のバージョンとスコープが異なりますが、それでも問題はないかもしれません。

  3. 私はいつもResteasy Proxy Frameworkを使用することをお勧めします。書くために少しのコードであってもよいが、合計で物事を簡単かつ明確になりますがあります

    public interface IssueIF 
    { 
        @POST 
        @Path("/issue") 
        @Produces("text/plain") 
        Issue postIssue(Issue i); 
    } 
    

    はそれを使用します:

    ResteasyClient client = new ResteasyClientBuilder().build(); 
    ResteasyWebTarget target = client.target("http://example.com/base/uri"); 
    
    SimpleClient simple = target.proxy(IssueIF.class); 
    Issue issue = new Issue(); 
    client.postIssue(issue); 
    

    私はコンパイルされませんでした

インタフェースを定義しますこのコードは、主にドキュメントからコピー/ペーストされますが、必要なものに近いはずです。

編集:docsから

Subclasses of LinkageError indicate that a class has some dependency on another class; however, the latter class has incompatibly changed after the compilation of the former class.

このあなたはありませんので1

で上記参照コンパイルおよび実行時に使用するさまざまなライブラリのバージョンに問題があることを示唆しています特に異なるスコープを使用する場合は、コンパイルと実行時にバージョンが同じであることが不可欠です。したがって、JBossが提供するバージョンを調べ、これらのバージョンのみを使用してください。また、参照されているライブラリのどれが提供されているかを調べ、それらのすべてにスコープを指定します。

+0

残念なことに同じエラーが発生しています。 – GhostDonkeys

+0

何を試しましたか? – martinw

関連する問題