• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

JPA2 and Glassfish: persistence unit not found

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I just had the craziest dream. This tiny ad was in it.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic