-1

在我的 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>

即使在具有 OpenJPAConfiguration 的 pom.xml 中包含 openjpa-all 依赖项后,我仍然看到此问题。对此的任何帮助将不胜感激。

4

1 回答 1

1

OpenJPA 对 Cassandra 做了什么?

在您的 Maven 依赖项中,我可以看到:

  1. cassandra-驱动程序核心
  2. cassandra 驱动程序映射
  3. 赫克托对象映射器
  4. openjpa-all

如果您使用的是 Cassandra,前 2 个依赖项就足够了。hector-object-mapper是无用的,因为你已经拥有cassandra-driver-mapping并且openjpa-all是无用的,因为它永远不会对 Cassandra 起作用。

请记住,Cassandra != 关系数据库

于 2016-04-21T20:45:38.853 回答