2017-01-24 94 views
0
私は現在、私のプロジェクトにAWS SDK(特にS3のSDK)を使用するが、のように

AWS SDKのNoClassDefFoundError

java.lang.NoClassDefFoundError:com/amazonaws/services/s3/AmazonS3ClientBuilder 

私はMavenを使用して、私のプロジェクトにSDKをインポートした例外を取得し維持しようとしています

SDKのドキュメントhere。私はこの問題が発生する原因となる実行しているコードは、私は問題が原因AWS SDKと私は自分自身をインポートしたバージョンで必要なバージョン間のジャクソンのバージョンの競合に発生されている可能性が疑わ

AmazonS3 amazonS3 = AmazonS3ClientBuilder.standard().withRegion(Regions.EU_WEST_1).build(); 

ですこれを変更することは問題を解決していないようですが、プロジェクトのどこに他のものを使用してください。私は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>com.projectname.restservice</groupId> 
<artifactId>ProjectName</artifactId> 
<packaging>war</packaging> 
<version>1.0-SNAPSHOT</version> 
<name>ProjectName</name> 

<build> 
    <finalName>ProjectName</finalName> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.5.1</version> 
      <inherited>true</inherited> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

<dependencyManagement> 
    <dependencies> 
     <dependency> 
      <groupId>org.glassfish.jersey</groupId> 
      <artifactId>jersey-bom</artifactId> 
      <version>2.16</version> 
      <type>pom</type> 
      <scope>import</scope> 
     </dependency> 
     <dependency> 
      <groupId>com.amazonaws</groupId> 
      <artifactId>aws-java-sdk-bom</artifactId> 
      <version>1.11.22</version> 
      <type>pom</type> 
      <scope>import</scope> 
     </dependency> 
    </dependencies> 
</dependencyManagement> 

<dependencies> 
    <dependency> 
     <groupId>org.glassfish.jersey.containers</groupId> 
     <artifactId>jersey-container-servlet-core</artifactId> 
    </dependency> 

    <!--Removed due to possible conflict with AWS SDK?--> 
    <!--<dependency> 
     <groupId>org.glassfish.jersey.media</groupId> 
     <artifactId>jersey-media-json-jackson</artifactId> 
    </dependency>--> 

    <dependency> 
     <groupId>org.glassfish.jersey.media</groupId> 
     <artifactId>jersey-media-multipart</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
     <version>5.1.35</version> 
    </dependency> 

    <dependency> 
     <groupId>com.amazonaws</groupId> 
     <artifactId>aws-java-sdk-s3</artifactId> 
    </dependency> 

</dependencies> 

出力:mvn dependency:tree -Dverbose -Dincludes=com.amazonaws

com.trailfinder.restservice:TrailFinderRestService:war:1.0-SNAPSHOT 
[INFO] \- com.amazonaws:aws-java-sdk-s3:jar:1.11.22:compile 
[INFO] +- com.amazonaws:aws-java-sdk-kms:jar:1.11.22:compile 
[INFO] | \- (com.amazonaws:aws-java-sdk-core:jar:1.11.22:compile - omitted for duplicate) 
[INFO] \- com.amazonaws:aws-java-sdk-core:jar:1.11.22:compile 
+0

@DaveMapleコメントのために出力が長すぎます。私はリンクを提供します – user3075268

+0

txtファイルは[ここ](https://www.dropbox.com/s /g9akoy35a04mzet/mevenoutput.txt?dl=0) – user3075268

+0

申し訳ありません、これは私が探していたものです: 'mvn依存関係:ツリー-Dverbose -Dincludes = com.amazonaws' –

答えて

0

私が思うに、私はこの問題の解決策/回避策を見つけました。 @DaveMapleからの提案のおかげで、私はコマンドラインからアプリを構築し、手動で働いていたような.warを手動で配備しようとしました。

this questionによると、IntelliJ IDEAは独自のビルドプロセスを使用し、Mavensは使用しません。これは、問題はIntelliJのビルドプロセスであり、AWS SDKやMavenとは関係がないと考えています。この問題を回避するために、IntelliJは独自のビルドプロセスを使用せず、代わりにMavenを使用し、次に結果の.warをデプロイするように設定しました。これを行う方法の説明が見つかりましたhere.