users@glassfish.java.net

Re: Can't deploy app client with Glassfish v3 - JPA problem

From: Bobby Bissett <Robert.Bissett_at_Sun.COM>
Date: Thu, 14 Jan 2010 09:45:58 -0500

> Thanks for the hint. I am able to get the checkbox unghosted by
> editing the PU xml as you suggested. It looks like I have some
> research to get it working.

I know the feeling. Here's an example persistence.xml file in case it
helps. It has both the non-JTA and JTA flavors in it for comparison. I
used NB to create both of these. Since the entities aren't explicitly
listed, all entities in the app will be included.

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd
">

   <!-- this is the type I think you don't want -->
   <persistence-unit name="your_name_here1" transaction-
type="RESOURCE_LOCAL">
     <provider>org.eclipse.persistence.jpa.PersistenceProvider</
provider>
     <exclude-unlisted-classes>false</exclude-unlisted-classes>
     <properties>
       <property name="javax.persistence.jdbc.url" value="jdbc:derby://
localhost:1527/sun-appserv-samples"/>
       <property name="javax.persistence.jdbc.password" value="APP"/>
       <property name="javax.persistence.jdbc.driver"
value="org.apache.derby.jdbc.ClientDriver"/>
       <property name="javax.persistence.jdbc.user" value="APP"/>
       <property name="eclipselink.ddl-generation" value="create-
tables"/>
     </properties>
   </persistence-unit>

   <!-- this is the JTA type. let GFv3 handle the details. -->
   <persistence-unit name="your_name_here2" transaction-type="JTA">
     <provider>org.eclipse.persistence.jpa.PersistenceProvider</
provider>
     <jta-data-source>jdbc/your_jndi_name_here</jta-data-source>
     <properties>
       <property name="eclipselink.ddl-generation" value="create-
tables"/>
     </properties>
   </persistence-unit>

</persistence>


> I was not able to get it to work by the gui add method you
> describe and show in the video. Netbeans 6.8 on windows must be
> different.

That was quite the random workaround -- maybe it was specific to
whatever version I was using. At least they know about it now. :)

If you need a full example of creating the database connection pool,
jndi resource, and then how to connect it to your persistence.xml
file, let me know. I just happen to have some screenshots on my
desktop that I have as reminders.

Cheers,
Bobby