Reputation: 118
I am new to developing with EclipseLink JPA, i am using eclipselink-2.4.0.v20120608-r11652.zip this version. the full story of my problem is that my lib contain some JPA 1.0 lib and i decide to upgrade to JPA 2.0 by download latest EclipseLink above, by adjust the ordering to load those latest lib to first, my code compile fine with the latest classes from the right lib,
Once i start running, the code fault on createEntityManagerFactory, complaint that it need the class in a datanucleus-api.jar i just get rid of. here is the stack trace:
java.lang.NoClassDefFoundError: org/datanucleus/jpa/exceptions/NoPersistenceXmlException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at core.server.jpa.RawTrades.testMethod(RawTrades.java:18)
at test.testJPA.testMethod(testJPA.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:21)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:194)
my code is standard code below
private static final String PERSISTENCE_UNIT_NAME = "SimTool";
private static EntityManagerFactory factory;
public static void testMethod() {
factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME,new HashMap());
EntityManager em = factory.createEntityManager();
}
my persistence.xml site at /WEB-INFO/classes/META-INFO/persistence.xml, interesting thing is i set it to do logging, but there are not log file generated at all.
<?xml version="1.0" encoding="UTF-8" ?>
<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" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="SimTool" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>core.server.jpa.RawTrade</class>
<class>core.shared.Schedule</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:sqlserver://gprimesqldb1u.eur.nsroot.net:2431;databasename=GlobalPrimeDb" />
<property name="javax.persistence.jdbc.user" value="NoSafeToShare" />
<property name="javax.persistence.jdbc.password" value="OnlyDeterminedOneWillGetIt" />
<!-- EclipseLink should create the database schema automatically -->
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="both" />
<property name="eclipselink.logging.file" value="JPAoutput.log"/>
<property name="eclipselink.logging.logger" value="JavaLogger"/>
<property name="eclipselink.logging.level" value="FINE" />
</properties>
i feel the code is still try to load old JPA lib instead of EclipseLink lib, Many Thanks for the help
Upvotes: 3
Views: 1508