简体   繁体   English

AWS开发工具包NoClassDefFoundError

[英]AWS SDK NoClassDefFoundError

I am currently trying to use the AWS SDK (specifically the s3 SDK) in my project but keep getting the exception 我目前正在尝试在项目中使用AWS开发工具包(特别是s3开发工具包),但始终遇到异常

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

I have imported the SDK into my project using maven as shown in the SDK documentation here . 我已经进口到SDK使用maven如图所示的SDK文档中我的项目在这里 The code that I am running that causes this to occur is 我正在运行的导致这种情况发生的代码是

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

I suspected the issue may have been occurring due to a conflict in Jackson versions between the version required by the AWS SDK and the version I was importing myself for use else where in the project although changing this does not seem to have resolved the issue. 我怀疑该问题可能是由于AWS开发工具包所需的版本与我自己导入的版本之间的杰克逊版本冲突而引起的,该版本供我在项目中的其他地方使用,尽管更改此版本似乎无法解决该问题。 I will include my POM.xml file below. 我将在下面包含我的POM.xml文件。

Thanks in advance. 提前致谢。

<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>

Output of: mvn dependency:tree -Dverbose -Dincludes=com.amazonaws 输出: 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

I think, I've found a solution / workaround to this issue. 我认为,我已经找到了解决该问题的方法。 Thanks to suggestions from @DaveMaple I tried building the app through the command line and deploying the .war manually which seems to have worked. 感谢@DaveMaple的建议,我尝试通过命令行构建应用程序并手动部署.war,这似乎已经奏效。

According to this question IntelliJ IDEA uses its own build process and not Mavens. 根据这个问题, IntelliJ IDEA使用自己的构建过程,而不是Maven。 This leads me to believe that the issue was with IntelliJ's build process and nothing to do with AWS SDK or Maven. 这使我相信问题出在IntelliJ的构建过程中,而与AWS SDK或Maven无关。 To work around this issue I configured IntelliJ to not use its own build process but instead to use Maven and then to deploy the resulting .war. 要解决此问题,我将IntelliJ配置为不使用自己的生成过程,而是使用Maven,然后部署生成的.war。 Explanation on how to do this can be found here. 有关如何执行此操作的说明,请参见此处。

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

相关问题 jar中的AWS开发工具包NoClassDefFoundError用作smartfox的扩展 - AWS SDK NoClassDefFoundError in jar used as an extension of smartfox 带有 AWS Java SDK 的 JsonErrorUnmarshallerV2 的 NoClassDefFoundError - NoClassDefFoundError for JsonErrorUnmarshallerV2 with AWS Java SDK 使用Amazon AWS开发工具包时遇到NoClassDefFoundError - Encountered NoClassDefFoundError when using Amazon AWS SDK 使用AWS SDK for java运行程序时出现NoClassDefFoundError - NoClassDefFoundError while running a program using AWS SDK for java NoClassDefFoundError:Java SDK 中的 AmazonSNSClient - NoClassDefFoundError: AmazonSNSClient in Java SDK 使用 AWS SDK 为 Java 创建 Amazon S3 存储桶:线程“主”java.lang.NoClassDefFoundError 中的异常 - Creating an Amazon S3 bucket Using the AWS SDK for Java : Exception in thread "main" java.lang.NoClassDefFoundError 使用 AWS SDK for Java v2 创建 Amazon S3 存储桶:线程“main”java.lang.NoClassDefFoundError 中的异常 - Creating an Amazon S3 bucket Using the AWS SDK for Java v2 : Exception in thread "main" java.lang.NoClassDefFoundError 亚马逊AWS KMS + Gradle:NoClassDefFoundError - Amazon AWS KMS + Gradle: NoClassDefFoundError 适用于Android的Dropbox SDK无法正常工作,即将出现NoClassDefFoundError - Dropbox SDK for android is not working, NoClassDefFoundError is coming Firebase 管理员 SDK - java.lang.NoClassDefFoundError - Firebase Admin SDK - java.lang.NoClassDefFoundError
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM