2014-01-19 12 views
5

私はJava EE Webアプリケーションを開発しています。ここApache httpclient 4.3.1 java.lang.NoSuchFieldError:INSTANCE

は私のpom.xmlです:

<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/maven-v4_0_0.xsd"> 

<modelVersion>4.0.0</modelVersion> 
<groupId>bitcoin</groupId> 
<artifactId>bitcoin</artifactId> 
<packaging>war</packaging> 
<version>1.0-SNAPSHOT</version> 
<name>Chens Bitcoin Webapp</name> 
<url>http://maven.apache.org</url> 

<properties> 
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <!-- Define the version of the JBoss BOMs we want to import to specify tested stacks. --> 
    <version.jboss.bom>1.0.5.CR6</version.jboss.bom> 
</properties> 

<repositories> 
    <repository> 
     <id>prime-repo</id> 
     <name>Prime Repo</name> 
     <url>http://repository.primefaces.org</url> 
    </repository> 
</repositories> 

<dependencyManagement> 
    <dependencies> 
     <!-- Define the version of JBoss' Java EE 6 APIs we want to use --> 
     <!-- JBoss distributes a complete set of Java EE 6 APIs including 
      a Bill of Materials (BOM). A BOM specifies the versions of a "stack" (or 
      a collection) of artifacts. We use this here so that we always get the correct 
      versions of artifacts. Here we use the jboss-javaee-6.0-with-security stack 
      (you can read this as the JBoss stack of the Java EE 6 APIs with Security). 
      You can actually use this stack with any version of JBoss AS that implements 
      Java EE 6, not just JBoss AS 7! --> 
     <dependency> 
      <groupId>org.jboss.bom</groupId> 
      <artifactId>jboss-javaee-6.0-with-security</artifactId> 
      <version>${version.jboss.bom}</version> 
      <type>pom</type> 
      <scope>import</scope> 
     </dependency> 
    </dependencies> 
</dependencyManagement> 

<dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-web-api</artifactId> 
     <version>7.0</version> 
     <scope>provided</scope> 
    </dependency> 

    <!--<dependency>--> 
     <!--<groupId>org.jboss.spec.javax.faces</groupId>--> 
     <!--<artifactId>jboss-jsf-api_2.2_spec</artifactId>--> 
     <!--<version>2.2.0</version>--> 
    <!--</dependency>--> 

    <!--<dependency>--> 
     <!--<groupId>com.sun.faces</groupId>--> 
     <!--<artifactId>jsf-spi</artifactId>--> 
     <!--<version>1.0</version>--> 
    <!--</dependency>--> 

    <!-- Rewrite --> 
    <dependency> 
     <groupId>org.ocpsoft.rewrite</groupId> 
     <artifactId>rewrite-servlet</artifactId> 
     <version>2.0.8.Final</version> 
    </dependency> 

    <dependency> 
     <groupId>org.ocpsoft.rewrite</groupId> 
     <artifactId>rewrite-config-prettyfaces</artifactId> 
     <version>2.0.8.Final</version> 
    </dependency> 

    <dependency> 
     <groupId>org.omnifaces</groupId> 
     <artifactId>omnifaces</artifactId> 
     <version>1.6</version> 
    </dependency> 

    <dependency> 
     <groupId>commons-fileupload</groupId> 
     <artifactId>commons-fileupload</artifactId> 
     <version>1.3</version> 
    </dependency> 

    <dependency> 
     <groupId>org.primefaces</groupId> 
     <artifactId>primefaces</artifactId> 
     <version>3.5</version> 
    </dependency> 

    <!-- Data time management --> 
    <dependency> 
     <groupId>joda-time</groupId> 
     <artifactId>joda-time</artifactId> 
     <version>2.2</version> 
    </dependency> 

    <dependency> 
     <groupId>commons-codec</groupId> 
     <artifactId>commons-codec</artifactId> 
     <version>1.9</version> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.httpcomponents</groupId> 
     <artifactId>httpclient</artifactId> 
     <version>4.3.1</version> 
    </dependency> 

    <dependency> 
     <groupId>com.googlecode.json-simple</groupId> 
     <artifactId>json-simple</artifactId> 
     <version>1.1.1</version> 
    </dependency> 

    <!-- Import the PicketLink API, we deploy this as library with the application, 
     and can compile against it --> 
    <dependency> 
     <groupId>org.picketlink</groupId> 
     <artifactId>picketlink-core-api</artifactId> 
    </dependency> 

    <!-- Import the PicketLink implementation, we deploy this as library with the application, 
     but can't compile against it --> 
    <dependency> 
     <groupId>org.picketlink</groupId> 
     <artifactId>picketlink-core-impl</artifactId> 
     <scope>runtime</scope> 
    </dependency> 

<dependency> 
    <groupId>junit</groupId> 
    <artifactId>junit</artifactId> 
    <version>3.8.1</version> 
    <scope>test</scope> 
    </dependency> 
    </dependencies> 
    <build> 
    <finalName>bitcoin</finalName> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.1</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
       <compilerArguments> 
        <endorseddirs>${endorsed.dir}</endorseddirs> 
       </compilerArguments> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.3</version> 
      <configuration> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.jboss.as.plugins</groupId> 
      <artifactId>jboss-as-maven-plugin</artifactId> 
      <version>7.4.Final</version> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.6</version> 
      <executions> 
       <execution> 
        <phase>validate</phase> 
        <goals> 
         <goal>copy</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>${endorsed.dir}</outputDirectory> 
         <silent>true</silent> 
         <artifactItems> 
          <artifactItem> 
           <groupId>javax</groupId> 
           <artifactId>javaee-endorsed-api</artifactId> 
           <version>7.0</version> 
           <type>jar</type> 
          </artifactItem> 
         </artifactItems> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 
</project> 

私はHttpClientをを作成するための方法を持っている、それはJSFページから呼び出すときに問題が発生しただけでは正常に動作しますが、:

public void doSth() { 
    ...... 
    HttpClient httpclient = HttpClientBuilder.create().build(); 
    ...... 
    } 

このメソッドはJSFページのcommonbuttonによって呼び出され、次のエラーが発生したときにボタンをクリックしたときに発生します。

 Caused by: java.lang.NoSuchFieldError: INSTANCE 
    at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:52) [httpcore-4.3.jar:4.3] 
    at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:56) [httpcore-4.3.jar:4.3] 
    at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<clinit>(DefaultHttpRequestWriterFactory.java:46) [httpcore-4.3.jar:4.3] 
     ...... 

はそれをGoogleで検索、HTTPClientのjarファイルは、他のクラスとの競合を持っていますが、私は本当に必要である1、およびPOM内のすべての依存関係を把握することはできませんようです。

私はWildFly 8 CRをサーバーとして使用しています。

ありがとうございます。

+0

クラスパスにhttpclientの2つの異なるバージョンがあります。 WildFlyにhttpclientが付属しているかどうかチェックしましたか?それ以外にも、あなたの依存関係の1つが独自のhttpclientを取得する可能性があります。mvnの依存関係を試してみてください:treeとhttpclientの2つのバージョンがあるかどうかチェックしてください –

+1

また、依存関係管理で "jboss-javaee-6.0-with-security" bomを使用しますが、依存関係ではjavaee- API-7.0 –

答えて

1

アプリで問題が発生する可能性があるので、EE6 & 7 pomsを混合しないでください。

スターターのために、あなたはまた、削除することもできます

<dependency> 
     <groupId>org.wildfly.bom</groupId> 
     <artifactId>jboss-javaee-7.0-with-security</artifactId> 
     <version>8.0.0</version> 
     <type>pom</scope> 
     <scope>import</scope> 
</dependency> 

<dependency> 
     <groupId>org.jboss.bom</groupId> 
     <artifactId>jboss-javaee-6.0-with-security</artifactId> 
     <version>${version.jboss.bom}</version> 
     <type>pom</type> 
     <scope>import</scope> 
</dependency> 

置き換える必要があります。

<dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-web-api</artifactId> 
     <version>7.0</version> 
     <scope>provided</scope> 
    </dependency> 

をあなたが得るように、すべてのこと、既にJBossの-JavaEEの-7.0の一部として、 -with-security pom import しかし、それはとにかく傷ついていません。また

置き換えると

<plugin> 
      <groupId>org.jboss.as.plugins</groupId> 
      <artifactId>jboss-as-maven-plugin</artifactId> 
      <version>7.4.Final</version> 
</plugin> 

<plugin> 
     <groupId>org.wildfly.plugins</groupId> 
     <artifactId>wildfly-maven-plugin</artifactId> 
     <version>1.0.1.Final</version> 
</plugin> 

あなたがwildflyし展開することで、また目標がjboss-as:deployから変更されている問題が発生しますothewiseとして、あなたは全体の検査されなければならない

wildfly:deployへ依存関係ツリーに重複したHTTPクライアントがある場合は、依存関係ツリー。

あなたは

mvn dependency:tree 

を実行することによって、それは依存性で、どこから持っている何を与えることを行うことができます。

補足として、WildFly 8.0.0 Finalにアップグレードする必要があります。あなたの問題に関係はありませんが、多くのバグ修正を取得するだけです...