• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA2 and Glassfish: persistence unit not found

 
Antonio Fornie
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I'm trying to make a test project with JEE6 in Glassfish and I'm getting an error related to my persistence unit:

That's my persistence.xml
-------------------------------
<?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">

<persistence-unit name="VuelosWebPersistenceUnit" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<properties>
<property name="eclipselink.target-database" value="DERBY" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.jdbc.url" value="jdbc:derby://localhost:1527/dbname" />
<property name="eclipselink.jdbc.user" value="user" />
<property name="eclipselink.jdbc.password" value="pwd />
</properties>
</persistence-unit>

</persistence>
-------------------------------

My SLSB has this conflicting code:

...
@PersistenceContext
EntityManager em;
...

I tried too with this code
...
@PersistenceContext(name="VuelosWebPersistenceUnit", unitName="VuelosWebPersistenceUnit")
EntityManager em;
...
with the same result.

The error is this one:
Unable to retrieve EntityManagerFactory for unitName VuelosWebPersistenceUnit

And my persistence.xml file is in this path ${warfile}/META-INF/persistence.xml

Any ideas what's my problem or how to solve it?

Thank you very much!

antonio>
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not certain, but if you have an EJB shouldn't you have an ear not a war?

I believe your persistent xml and persistent classes should all be in a jar inside your ear file.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34669
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Sutherland wrote:Not certain, but if you have an EJB shouldn't you have an ear not a war?

You definitely have an EAR. It can contain a WAR though.

James Sutherland wrote:I believe your persistent xml and persistent classes should all be in a jar inside your ear file.

In any case, this is the important point. That the persistence.xml goes in the jar.
 
Antonio Fornie
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not with JEE6, in fact my EJB works perfectly when I don't use JPA. But it's the JAP persistence.xml file that must have an error... the problem is it doesn't show any information about it, not any log.

And I don't even know for sure if my properties prefix is the correct one for the default Glassfish JPA implementation.

Thank you very much for your replies! Any other idea?

antonio
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic