java.lang.ClassNotFoundException:来自模块 com.amazonaws 的 com.fasterxml.jackson.core.JsonParser$Feature:来自本地模块加载器的 main

问题描述 投票:0回答:1

我正在开发现有应用程序的增强功能,该应用程序是在 EJB、消息驱动 Bean、Hibernate、Maven 上开发的,作为构建工具,并在 Wildfly 10 上作为服务器。增强功能是从现有应用程序访问 S3 存储桶并将 zip 文件放在那里。因此,我在 pom.xml 文件中添加了 aws 和 opencsv 依赖项。 有 MANIFEST.MF 文件,我在其中添加了 amazon aws 和 opencsv 的依赖项,如下所示

Manifest-Version: SR.170.03
Class-Path: 
Dependencies: com.amazonaws,org.hibernate,com.opencsv

我能够使用 Maven clean install 成功构建应用程序。 然后我将war文件放在wildfly 10的部署文件夹中。war部署也成功了。 当我在调试模式下执行应用程序时,出现以下异常。

java.lang.ClassNotFoundException: com.fasterxml.jackson.core.JsonParser$Feature from Module com.amazonaws:main from local module loader @80169cf (finder: local module finder @5427c60c (roots: D:\Installables\wildfly-10.1.0.Final\modules,D:\Installables\wildfly-10.1.0.Final\modules\system\layers\base))
java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonParser$Feature

我已将 amazonaws jar、fasterxml jar 和 opencsv 放置在 Wildfly 10 模块文件夹中,如下所示

  1. 下面是 amazonaws fastxml 和 pom.xml 的 module.xml

     <module xmlns="urn:jboss:module:1.3" name="com.amazonaws">
         <resources>
             <resource-root path="aws-java-sdk-s3-1.12.125.jar"/> 
             <resource-root path="aws-java-sdk-core-1.12.125.jar"/>
             <resource-root path="aws-java-sdk-kms-1.12.125.jar"/>
             <resource-root path="jmespath-java-1.12.125.jar"/>
         </resources>
         <dependencies>
             <module name="com.fasterxml.jackson.core.jackson-databind"/>
             <module name="com.fasterxml.jackson.dataformat.jackson-dataformat-cbor"/>
             <module name="org.apache.commons.codec"/>
             <module name="org.apache.commons.logging"/>
             <module name="org.joda.time"/>
             <module name="org.apache.httpcomponents"/>
             <module name="software.amazon.ion"/>
         </dependencies>
     </module>
    
     <?xml version="1.0" encoding="UTF-8"?>
     <module xmlns="urn:jboss:module:1.3" name="com.fasterxml.jackson.core.jackson-core">
          <resources>
             <resource-root path="jackson-core-2.12.3.jar"/>
         </resources>
    
         <dependencies>
             <module name="javax.api"/>
         </dependencies>
     </module>
    
     <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>uk.co.tui</groupId>
         <artifactId>Cyrus</artifactId>
         <version>1.0</version>
         <packaging>jar</packaging>
         <name>Cyrus8</name>
         <url>https://maven.apache.org</url>
         <repositories>
            <repository>
               <id>Central Maven repository</id>
               <name>Jboss Loggings</name>
               <url>https://repository.jboss.org/nexus/content/repositories/public/</url>
            </repository>
             <repository>
               <id>Central JBOSS Maven repository</id>
               <name>Jboss Maven Logging</name>
               <url>https://repository.jboss.org/maven2/</url>
            </repository>
          </repositories>
         <properties>
             <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
             <sonar.language>java</sonar.language>
             <sonar.binaries>target/classes</sonar.binaries>
             <sonar.tests>src/test</sonar.tests>
             <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
             <sonar.junit.reportsPaths>target/test-reports</sonar.junit.reportsPaths>
             <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
             <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
             <sonar.jacoco.reportPath>${project.build.directory}/jacoco-ut.exec</sonar.jacoco.reportPath>
             <sonar.jacoco.itReportPath>${project.build.directory}/jacoco-it.exec</sonar.jacoco.itReportPath>
             <sonar.coverage.exclusions>
                 src/main/java/**/entity/BookParametersPK.java,
             </sonar.coverage.exclusions>
             <sonar.jacoco.reportMissing.force.zero>true</sonar.jacoco.reportMissing.force.zero>
         </properties>
    
         <dependencies>
             <dependency>
                 <groupId>org.sonarsource.scanner.maven</groupId>
                 <artifactId>sonar-maven-plugin</artifactId>
                 <version>3.2</version>
             </dependency>   
             <dependency>
                 <groupId>asm</groupId>
                 <artifactId>asm</artifactId>
                 <version>3.3.1</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>cglib</groupId>
                 <artifactId>cglib</artifactId>
                 <version>2.2.2</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>junit</groupId>
                 <artifactId>junit</artifactId>
                 <version>4.10</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>org.objenesis</groupId>
                 <artifactId>objenesis</artifactId>
                 <version>1.2</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>org.jboss.jbossas</groupId>
                 <artifactId>jboss-as-client</artifactId>
                 <type>pom</type>
                 <version>5.1.0.GA</version>
             </dependency>
             <dependency>
                 <groupId>org.mockito</groupId>
                 <artifactId>mockito-all</artifactId>
                 <version>1.9.5</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>org.powermock</groupId>
                 <artifactId>powermock-module-junit4</artifactId>
                 <version>1.5.6</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>org.powermock</groupId>
                 <artifactId>powermock-api-mockito</artifactId>
                 <version>1.5.6</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>javax.ejb</groupId>
                 <artifactId>javax.ejb-api</artifactId>
                 <version>3.2</version>
                 <scope>provided</scope>
             </dependency>
             <dependency>
                 <groupId>jboss</groupId>
                 <artifactId>jboss-annotations-ejb3</artifactId>
                 <version>4.2.2.GA</version>
             </dependency>
             <dependency>
                 <groupId>org.jboss.as</groupId>
                 <artifactId>jboss-as-ejb3</artifactId>
                 <version>7.1.0.CR1</version>
             </dependency>
             <dependency>
                 <groupId>org.wildfly</groupId>
                 <artifactId>wildfly-ejb3</artifactId>
                 <version>10.1.0.Final</version>
             </dependency>
             <dependency>
                 <groupId>org.wildfly</groupId>
                 <artifactId>wildfly-naming</artifactId>
                 <version>10.1.0.Final</version>
             </dependency>
             <dependency>
                 <groupId>jboss</groupId>
                 <artifactId>jboss-jmx</artifactId>
                 <version>4.2.2.GA</version>
             </dependency>
             <dependency>
                 <groupId>org.hibernate</groupId>
                 <artifactId>hibernate-core</artifactId>
                 <version>4.1.4.Final</version>
             </dependency>             
             <dependency>
                 <groupId>javax.persistence</groupId>
                 <artifactId>persistence-api</artifactId>
                 <version>1.0.2</version>
             </dependency>
             <dependency>
                 <groupId>com.amazonaws</groupId>
                 <artifactId>aws-java-sdk-s3</artifactId>
                 <version>1.12.125</version>
             </dependency>
             <dependency>
                 <groupId>com.opencsv</groupId>
                 <artifactId>opencsv</artifactId>
                 <version>4.0</version>
             </dependency>       
         </dependencies>
         <build>
             <plugins>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-compiler-plugin</artifactId>
                     <version>3.6.1</version> <!-- Replace with the desired version -->
                     <configuration>
                         <source>1.6</source> <!-- Replace with the desired Java version -->
                         <target>1.6</target> <!-- Replace with the desired Java version -->
                     </configuration>
                 </plugin>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-plugin</artifactId>
                     <configuration>
                         <!-- Sets the VM argument line used when unit tests are run. -->
                         <argLine>${surefireArgLine}</argLine>
                         <!-- Skips unit tests if the value of skip.unit.tests property is true -->
                         <skipTests>${skip.unit.tests}</skipTests>
                         <!-- Excludes integration tests when unit tests are run. -->
                         <argLine>-XX:-UseSplitVerifier</argLine>
                         <argLine>${surefire.jacoco.argLine}</argLine>
                         <!-- Excludes integration tests when unit tests are run -->
                         <excludes>
                             <exclude>**/*IT.java</exclude>
                         </excludes>
                     </configuration>
                 </plugin>
                 <plugin>
                     <groupId>org.jacoco</groupId>
                     <artifactId>jacoco-maven-plugin</artifactId>
                      <version>0.7.5.201505241946</version>
                     <!-- Unit testing configuration -->
                     <executions>
                         <execution>
                             <id>jacoco-initialize</id>
                             <configuration>
                                 <propertyName>surefire.jacoco.argLine</propertyName>
                                 <destFile>${project.build.directory}/jacoco-ut.exec</destFile>
                             </configuration>
                             <goals>
                                 <goal>prepare-agent</goal>
                             </goals>
                         </execution>
                         <execution>
                             <id>jacoco-report</id>
                             <phase>test</phase>
                             <goals>
                                 <goal>report</goal>
                             </goals>
                             <configuration>
                                 <!-- Sets the path to the file which contains the execution data. -->
                                 <dataFile>${project.build.directory}/jacoco-ut.exec</dataFile>
                                 <!-- Sets the output directory for the code coverage report. -->
                                 <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                             </configuration>
                         </execution>
    
                     </executions>
                     <configuration>
                         <propertyName>surefire.jacoco.argLine</propertyName>
                         <destFile>${project.build.directory}/jacoco-ut.exec</destFile>
                     </configuration>
                 </plugin>
                 <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-jar-plugin</artifactId>
                      <version>2.3.2</version>
                     <configuration>
                         <finalName>abcdef8</finalName>  
                         <archive>
                             <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
                         </archive>                  
                     </configuration>
                 </plugin>
    
             </plugins>
         </build>
     </project>
    

我已经浏览了与此类错误相关的主题,但没有得到解决方案。请有人帮忙解决这个问题

我尝试将所有 amazonaws jar 放在 Wildfly 10 模块中的一个位置。

java amazon-s3 jackson jackson2
1个回答
0
投票

您的 pom.xml 似乎缺少 Jackson 依赖项。

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version><some_version></version>
</dependency>
© www.soinside.com 2019 - 2024. All rights reserved.