users@glassfish.java.net

Re: Shared Persistence Unit

From: <glassfish_at_javadesktop.org>
Date: Tue, 11 Aug 2009 08:48:54 PDT

Ok, it deploys, but does not work. It will deploy if I manually deploy the ear through the admin console. If I try to deploy through Netbeans it does not work (Could not resolve persistence unit). My guess is that the order the jar files are loading is the key, and since Netbeans deploys the exploded ear, the jars are loading in a different order. I think this was the problem all along, I was always trying to deploy with Netbeans until just now. I have tried to specify the jar order using application.xml, but that doesn't seem to help. It gives an error that the persistence.jar is invalid, so I put a simple stateless session bean in it and it still gives that error.

Another problem is that when I deploy manually, it seems to deploy, but then when I try to use a named query it says the query doesn't exist. But that query is accessible if I go back to separate persistence units for each ejb jar.

Here's how my ear is now set up:
[code]
META-INF
persistence.jar
    META-INF
        persistence.xml
ejbjar1.jar
ejbjar2.jar
...
[/code]

I have session and entity beans packaged in each ejb jar.
The persistence.xml looks like:
[code]
<?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="MainPU" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>jdbc/clients_db</jta-data-source>
    <jar-file>../ejbjar1.jar</jar-file>
    <jar-file>../ejbjar2.jar</jar-file>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties/>
  </persistence-unit>
</persistence>
[/code]
[Message sent by forum member 'culli' (culli)]

http://forums.java.net/jive/thread.jspa?messageID=359920