2012-06-29 64 views
0

我正在通過https://blogs.oracle.com/arungupta/entry/java_ee_6_and_nosql的示例工作。EntityManagerFactory.createEntityManager() - 此操作不支持非關係平臺

這裏是一個模型SRC http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.nosql.mongo/src/

的一部分,是造成我的問題的鏈接是:

EntityManagerFactory factory; 
... 
test.factory = Persistence.createEntityManagerFactory("mongo"); 
EntityManager em = test.factory.createEntityManager();   

當org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager調用我得到

SEVERE: javax.persistence.PersistenceException: Exception [EclipseLink-7108] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.ValidationException 
Exception Description: This operation is not supported for non-relational platforms. 

下面是我使用的所有依存關係:

<classpath> 
    <classpathentry kind="src" path="src/main/java" including="**/*.java"/> 
    <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/> 
    <classpathentry kind="output" path="target/classes"/> 
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 
    <classpathentry kind="var" path="M2_REPO/javax/javaee-web-api/6.0/javaee-web-api-6.0.jar"/> 
    <classpathentry kind="var" path="M2_REPO/com/sun/jersey/jersey-server/1.8/jersey-server-1.8.jar"/> 
    <classpathentry kind="var" path="M2_REPO/asm/asm/3.1/asm-3.1.jar"/> 
    <classpathentry kind="var" path="M2_REPO/com/sun/jersey/jersey-core/1.8/jersey-core-1.8.jar"/> 
    <classpathentry kind="var" path="M2_REPO/org/mongodb/mongo-java-driver/2.7.3/mongo-java-driver-2.7.3.jar"/> 
    <classpathentry kind="var" path="M2_REPO/org/eclipse/persistence/org.eclipse.persistence.oracle.nosql/2.4.0/org.eclipse.persistence.oracle.nosql-2.4.0.jar"/> 
    <classpathentry kind="var" path="M2_REPO/org/eclipse/persistence/javax.persistence/2.0.4.v201112161009/javax.persistence-2.0.4.v201112161009.jar"/> 
    <classpathentry kind="var" path="M2_REPO/org/eclipse/persistence/org.eclipse.persistence.asm/3.3.1.v201206041142/org.eclipse.persistence.asm-3.3.1.v201206041142.jar"/> 
    <classpathentry kind="var" path="M2_REPO/org/eclipse/persistence/org.eclipse.persistence.antlr/3.2.0.v201206041011/org.eclipse.persistence.antlr-3.2.0.v201206041011.jar"/> 
    <classpathentry kind="var" path="M2_REPO/org/eclipse/persistence/org.eclipse.persistence.jpa.jpql/2.4.0/org.eclipse.persistence.jpa.jpql-2.4.0.jar"/> 
    <classpathentry kind="var" path="M2_REPO/org/eclipse/persistence/org.eclipse.persistence.core/2.4.0/org.eclipse.persistence.core-2.4.0.jar"/> 
    <classpathentry kind="var" path="M2_REPO/org/eclipse/persistence/org.eclipse.persistence.nosql/2.4.0/org.eclipse.persistence.nosql-2.4.0.jar"/> 
    <classpathentry kind="var" path="M2_REPO/org/eclipse/persistence/org.eclipse.persistence.jpa/2.4.0/org.eclipse.persistence.jpa-2.4.0.jar"/> 
</classpath> 

服務器是GlassFish服務器開源版3.我無法弄清楚爲什麼createEntityManager不會被允許,當我從其他人的示例代碼複製它的全部?

+0

您能否提供更多詳細信息,如異常堆棧跟蹤(如果存在)以及您的應用程序與第一個示例可能存在差異。也許發佈你的persistence.xml,並確保你也打開日誌記錄來捕獲任何警告,這些警告可能表明是什麼導致異常。 – Chris

回答