persistence@glassfish.java.net

J2SE example with toplink-essentials

From: Jakob Braeuchi <jbraeuchi_at_freesurf.ch>
Date: Sat, 01 Apr 2006 18:19:53 +0200

hi,

i tried to run the example shown on this page:
https://glassfish.dev.java.net/javaee5/persistence/entity-persistence-support.html#Java_SE

i had some problems with an NPE when i create the entityManager withoud
an additional map:

Persistence.createEntityManagerFactory("pu1");

Exception in thread "main" java.lang.NullPointerException
        at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.callPredeploy(JavaSECMPInitializer.java:140)
        at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initPersistenceUnits(JavaSECMPInitializer.java:282)
        at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initialize(JavaSECMPInitializer.java:301)
        at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initializeFromMain(JavaSECMPInitializer.java:338)
        at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.getJavaSECMPInitializer(JavaSECMPInitializer.java:78)
        at
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.getServerSession(EntityManagerFactoryProvider.java:251)
        at
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:96)
        at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:59)
        at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
        at client.Client.main(Client.java:48)


Persistence.createEntityManagerFactory("pu1", new HashMap()); works.

another problem is the the persistence.xml shown on the same page.

the properties prefixed with toplink did not work for me:

<property name="toplink.jdbc.driver" value="<database driver>"/>
<property name="toplink.jdbc.url" value="<database url>"/>
<property name="toplink.jdbc.user" value="<user>"/>
<property name="toplink.jdbc.password" value="<password>"/>

whith these properties (without toplink prefix) the example ran fine:

<property name="toplink.platform.class.name"
value="oracle.toplink.essentials.platform.database.MySQL4Platform"/>

<property name="jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="jdbc.connection.string"
value="jdbc:mysql://localhost:3306/mydb"/>
<property name="jdbc.user" value="myuser"/>
<property name="jdbc.password" value="mypwd"/>


jakob braeuchi