aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Could not resolve a persistence unit corresponding to the persistence-context-ref-name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Could not resolve a persistence unit corresponding to the persistence-context-ref-name" Watch "Could not resolve a persistence unit corresponding to the persistence-context-ref-name" New topic
Author

Could not resolve a persistence unit corresponding to the persistence-context-ref-name

pallavi chaudhari
Ranch Hand

Joined: Jul 02, 2008
Posts: 54
Hi all, I am new to EJB. I just trying to develop one simple application which includes Stateless session bean & Entity bean in netbeans IDE using GlassFish server. when i deploy the application i am getting "Could not resolve a persistence unit corresponding to the persistence-context-ref-name [SessionBeanUsed.BankServiceBean/em] in the scope of the module called" this exception.
I am giving my code below.





where i am going wrong???

Thanks in advance...
Dan Kempten
Greenhorn

Joined: Dec 26, 2008
Posts: 25
I'm no expert but could you show the contents of persistence.xml in your project?
check out whether you create tables or create and drop tables.
Here's mine.

And persistence context type?


pallavi chaudhari
Ranch Hand

Joined: Jul 02, 2008
Posts: 54
Persistence.xml

<?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="TestEntity-ejbPU" transaction-type="JTA">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<jta-data-source>checkPU</jta-data-source>
<properties>
<property name="toplink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
Dan Kempten
Greenhorn

Joined: Dec 26, 2008
Posts: 25
<jta-data-source>checkPU</jta-data-source>

is CheckPU the name of your jdbc database?
pallavi chaudhari
Ranch Hand

Joined: Jul 02, 2008
Posts: 54
Yes,while creating JNDI source i have given that name
pallavi chaudhari
Ranch Hand

Joined: Jul 02, 2008
Posts: 54
pallavi chaudhari wrote:Yes,while creating JNDI source i have given that name


This problem solved........thanks
loren nicolas
Greenhorn

Joined: Nov 06, 2009
Posts: 2
pallavi chaudhari wrote:
pallavi chaudhari wrote:Yes,while creating JNDI source i have given that name


This problem solved........thanks


--> could you please post the details on how you have solved it? I'm facing the same problem right now... appreciate your quick response.. tnx!
pallavi chaudhari
Ranch Hand

Joined: Jul 02, 2008
Posts: 54
Please,make sure that you have given same persistance unit name as you created.

i was facing "Could not resolve a persistence unit corresponding to the persistence-context-ref-name" beacuse i have not given persistence unit name proper.

loren nicolas
Greenhorn

Joined: Nov 06, 2009
Posts: 2
thnx! i was able to solve it too. we have different problems. mine is that i have more than one persistent.xml found on the war file. anyway thanks alot!
Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Hello!

I had half an hour of beating my fist against the table because of this complete nonsense too!



It was resolved by changing this:

into this:

If only I were always far from such things


True person is moral, false is right!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Could not resolve a persistence unit corresponding to the persistence-context-ref-name