0

我正在尝试在 Weblogic 10.3.6 上运行基于 Spring 的 Web 应用程序。此应用程序使用 Apache Cassandra 2.0.7 版来存储/访问数据。

我们使用 JPA 2.0 和 persistence.xml 文件,如下所示:

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
             http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
    <persistence-unit name="cassandra">
        <provider>com.impetus.kundera.KunderaPersistence</provider>
        <properties>
            <property name="kundera.dialect" value="cassandra"/>
            <property name="cql.version" value="3.0.0"/>
            <property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.thrift.ThriftClientFactory"/>

            <property name="kundera.keyspace" value="abc"/>
            <property name="kundera.nodes" value="localhost"/>
            <property name="kundera.port" value="9160"/>
            <property name="kundera.ddl.auto.prepare" value="validate"/>

        </properties>
    </persistence-unit>
</persistence>

我还通过如下修改 commEnv.sh 文件在 Weblogic 10.3.6 中应用了 JPA 2.0 补丁:

# Enable JPA2.0 support
PRE_CLASSPATH="${PRE_CLASSPATH}:${MW_HOME}/modules/com.oracle.jpa2support_1.0.0.0_2-1.jar:${MW_HOME}/modules/javax.persistence_1.1.0.0_2-0-0.jar"
export PRE_CLASSPATH

应用程序部署成功,但在尝试通过 EntityManager 访问后端时,我看到如下错误:

Caused by: java.lang.NoSuchMethodError: javax.persistence.EntityManagerFactory.getCache()Ljavax/persistence/Cache;
        at com.impetus.kundera.persistence.EntityManagerImpl.<init>(EntityManagerImpl.java:128)
        at com.impetus.kundera.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:246)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

pom文件中的相关条目是:

<dependency>
    <groupId>com.impetus.kundera.client</groupId>
    <artifactId>kundera-cassandra</artifactId>
    <version>2.11</version>
</dependency>

<dependency>
    <groupId>com.impetus.kundera.core</groupId>
    <artifactId>kundera-core</artifactId>
    <version>2.11</version>
</dependency>

<dependency>
    <groupId>org.hibernate.javax.persistence</groupId>
    <artifactId>hibernate-jpa-2.0-api</artifactId>
    <version>1.0.1.Final</version>
</dependency> 

有人可以通过建议这里有什么问题来帮忙吗?

问候,

阿南德

4

1 回答 1

0

请删除以下依赖项

<dependency>
    <groupId>org.hibernate.javax.persistence</groupId>
    <artifactId>hibernate-jpa-2.0-api</artifactId>
    <version>1.0.1.Final</version>
</dependency> 

之后它应该工作。

于 2014-06-04T10:14:14.707 回答