users@glassfish.java.net

step by step directions Persistence API J2SE

From: Lucas Jordan <lucas.jordan_at_childrens.harvard.edu>
Date: Mon, 09 Jan 2006 16:13:49 -0500

have tried a bunch of blog/tutorials trying to get the new Persistence API
working from j2se. I have been unable find a basic working example.

What I want to know is:
1) what jars do i need?
2) what does a persistence.xml file really look like?
3) where exactly must a persistence.xml file go?
4) how can I automatically generate the tables for my POJOs to be stored in?
5) Is there official/current documentation?
6) can I use Derby running as a separate server as a store? if so, how?

I would really appreciate anyone helping me, I'm really tired of looking at
the same outdated examples :)

I was looking at:
https://glassfish.dev.java.net/javaee5/persistence/persistence-example.html

But the example download for j2se is busted. Also it calls for using the
javaagent (-javaagent:${glassfish.home}/lib/toplink-essentials-agent.jar)
command, is this actually required?


-Lucas

P.S. what is wrong when I get a stack trace that looks like:
Exception in thread "main" java.lang.NullPointerException
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.callPredepl
oy(JavaSECMPInitializer.java:120)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initPersist
enceUnits(JavaSECMPInitializer.java:279)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initialize(
JavaSECMPInitializer.java:298)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initializeF
romMain(JavaSECMPInitializer.java:335)
at
oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.getJavaSECM
PInitializer(JavaSECMPInitializer.java:78)
at
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.getServerSes
sion(EntityManagerFactoryProvider.java:235)
at
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntity
ManagerFactory(EntityManagerFactoryProvider.java:94)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61
)
at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:50
)