[EXCEPTION]:任务执行异常,原因:java.lang.NoClassDefFoundError:org / apache / openjpa / conf / OpenJPAConfiguration

时间:2016-04-21 17:13:35

标签: maven cassandra persistence openjpa openjpa-maven-plugin

在我的pom.xml中包含与Cassandra相关的新依赖项后,我开始收到此异常。我在我的应用程序中使用它进行日志记录。

[EXCEPTION]:Task execution exception, Cause : java.lang.NoClassDefFoundError: org/apache/openjpa/conf/OpenJPAConfiguration

java.lang.NoClassDefFoundError: org/apache/openjpa/conf/OpenJPAConfiguration
    at java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:1.7.0_79]
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585) ~[na:1.7.0_79]
    at java.lang.Class.getConstructor0(Class.java:2885) ~[na:1.7.0_79]
    at java.lang.Class.newInstance(Class.java:350) ~[na:1.7.0_79]
    at org.apache.geronimo.osgi.locator.ProviderLocator.getServices(ProviderLocator.java:319) ~[geronimo-jpa_2.0_spec-1.1.jar:1.1]
    at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:108) ~[geronimo-jpa_2.0_spec-1.1.jar:1.1]
    at javax.persistence.Persistence$PersistenceUtilImpl.isLoaded(Persistence.java:278) ~[geronimo-jpa_2.0_spec-1.1.jar:1.1]
    at org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:62) ~[hibernate-validator-4.1.0.Final.jar:4.1.0.Final]
    at org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:94) ~[hibernate-validator-4.1.0.Final.jar:4.1.0.Final]
    at org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47) ~[hibernate-validator-4.1.0.Final.jar:4.1.0.Final]org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:324) ~[hibernate-validator-4.1.0.Final.jar:4.1.0.Final]
    at org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:757) ~[hibernate-validator-4.1.0.Final.jar:4.1.0.Final]
    at 

这是我的pom.xml:

<dependencies>
        <dependency> 
            <groupId>com.app.cops</groupId>
            <artifactId>logging</artifactId>
            <version>0.0.5-SNAPSHOT</version>
        </dependency>
</dependencies> 

这是日志项目的pom.xml:

<dependencies>
    <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>cassandra-driver-core</artifactId>
        <version>3.0.0</version>
    </dependency>   
    <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>cassandra-driver-mapping</artifactId>
        <version>3.0.0</version>
    </dependency>   
    <dependency>
    <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>19.0</version>
    </dependency>
    <dependency>
        <artifactId>hector-object-mapper</artifactId>
        <groupId>org.hectorclient</groupId>
        <version>3.1-10</version>
    </dependency>
    <dependency>
        <groupId>org.apache.openjpa</groupId>
        <artifactId>openjpa-all</artifactId>
        <version>2.0.0</version>
    </dependency>
</dependencies>

即使在我的pom.xml中包含openjpa-all依赖项并且有OpenJPAConfiguration之后我仍然会看到这个问题。任何有关这方面的帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

OpenJPA与Cassandra有什么关系?

在你的maven依赖中,我可以看到:

  1. 卡桑德拉驱动器芯
  2. 卡桑德拉驱动程序映射
  3. 赫对象映射器
  4. OpenJPA的-所有
  5. 如果你正在使用Cassandra,前两个依赖就足够了。 hector-object-mapper没用,因为您已经cassandra-driver-mappingopenjpa-all无效,因为它对Cassandra无效。

    记住,Cassandra!=关系数据库