Hi,
I've been using MySQL with Glassfish v2ur2, and am in the process of trying to move to Glassfish v3. For now, I'm just trying to get a test app up and running to access the database, but no luck so far.
I'm using Glassfish Tools Bundle for Eclipse on a Mac running OSX 10.5.8. I have an EAR project that includes a JPA Project. In the JPA properties for this project, I have the platform set to EclipseLink 1.1.x and the User Library set to EclipseLink 1.1.2 - Galileo.
My persistence.xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" 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_1_0.xsd">
<persistence-unit name="TestJPA" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/testDB</jta-data-source>
<class>com.leadingstep.test.db.User</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
<property name="eclipselink.logging.level" value="ALL"/>
</properties>
</persistence-unit>
</persistence>
I'm using mysql-connector-java-java-5.1.7-bin.jar, but I'm not quite sure where this is supposed to be. I have copies in:
~/workspace/libraries
~/workspace/.metadata/.plugins/com.sun.enterprise.jst.server.sunappsrv92/domain1/lib/ext
and I also specifically refer to the first copy in the java build path as an external jar.
Using the Data Source Explorer from Eclipse, I can access the database and see that it is there and set up with the correct column names, etc., but when I try to access it from the test app using the JPA Project, the injection of the EntityManager fails and I end up with a null EntityManager reference. I'm using:
@PersistenceContext(unitName="TestJPA")
private EntityManager em;
I wanted to turn on logging for JPA in Glassfish, but I don't see that in the available logger settings. Where does that get turned on? I turned on the logging for EclipseLink in the persistence.xml file and using that, I do see some errors generated when I try to use the JPA Tools from Eclipse to tell it to generate the tables from the entities. It gives me:
--------------------------------
Exception [EclipseLink-7060] (Eclipse Persistence Services - 2.0.0.v20091127-r5931)\
: org.eclipse.persistence.exceptions.ValidationException
Exception Description: Cannot acquire data source [jdbc/testDB].
Internal Exception: javax.naming.NamingException: Lookup failed for 'jdbc/testDB' i\
n SerialContext [Root exception is javax.naming.NamingException: Unable to acquire\
SerialContextProvider for SerialContext [Root exception is java.lang.NullPointerE\
xception]]
at org.eclipse.persistence.exceptions.ValidationException.cannotAcquireData\
Source(ValidationException.java:451)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.jav\
a:116)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.jav\
a:94)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(Dat\
asourceLogin.java:162)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDe\
tectDatasource(DatabaseSessionImpl.java:584)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(\
EntityManagerFactoryProvider.java:228)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(Entit\
yManagerSetupImpl.java:368)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerS\
ession(EntityManagerFactoryImpl.java:151)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEnti\
tyManagerImpl(EntityManagerFactoryImpl.java:207)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEnti\
tyManager(EntityManagerFactoryImpl.java:195)
at org.eclipse.jpt.eclipselink.core.ddlgen.Main.perform(Main.java:85)
at org.eclipse.jpt.eclipselink.core.ddlgen.Main.execute(Main.java:76)
at org.eclipse.jpt.eclipselink.core.ddlgen.Main.main(Main.java:63)
Caused by: javax.naming.NamingException: Lookup failed for 'jdbc/testDB' in SerialC\
ontext [Root exception is javax.naming.NamingException: Unable to acquire SerialCo\
ntextProvider for SerialContext [Root exception is java.lang.NullPointerException]\
]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:4\
42)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:5\
69)
at javax.naming.InitialContext.lookup(InitialContext.java:396)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.jav\
a:110)
... 11 more
--------------------------------
I'm not sure how to figure out where the problem is from here. Does anyone know what the problem might be or can you help me to know where to look further to resolve this issue? I sure would appreciate it because I'm really stuck at this point.
Thanks for any help!
Renee
[Message sent by forum member 'drrevis' (renee_at_leadingstep.com)]
http://forums.java.net/jive/thread.jspa?messageID=384083