• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Unable to retrieve EntityManagerFactory for unitName FibServicePU

 
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying the example in Java Web Service up and running book on p.256.
I have an rc.jar with ch06/ejb/Fib.class, ch06/ejb/FibEJB, ch06/ejb/FibNum
I also have a fib.ear with rc.jar and META-INF/persistence.xml
I put the fib.ear in glassfish 's domains/domain1/autodeploy/ and deploy it.
I create the client side from the WSDL generated from the deployment.
However, when I run the client, I got this on the client window:
javax.xml.ws.soap.SOAPFaultException: javax.ejb.EJBException

The glassfish window shows Unable to retrieve EntityManagerFactory for unitName FibServicePU.

Please help.
 
Creator of Enthuware JWS+ V6
Posts: 3287
296
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Himai,

If I read it well you have put your persistence.xml in the META-INF directory of your EAR-file instead of the META-INF directory of your EJB-JAR file (rc.jar).

Regards,
Frits
 
Himai Minh
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, my fib.ear has rc.jar and META-INF/persistence.xml like this:
fib.ear
-- rc.jar
-- META-INF
--- persistence.xml


I checked online and a web site suggests putting the rc.jar inside lib folder to make this:
fib.ear
-- lib
--- rc.jar

--META-INF
--- persistence.xml

I will try to put create a lib folder and create the fib.ear again tonight and see if it works.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3287
296
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I meant is to put the persistence.xml inside the META-INF dir of the rc.jar (and leave the META-INF dir of the ear empty)


Regards,
Frits
 
Himai Minh
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frits,
I tried your suggestion. But I got this error message:
org.eclipse.persistence.exceptions.ConversionExcepiton.
THe object [oracle.toplink.essentials.platform.database.DerbyPlatform] of class [class java.lang.String] cannot be
converted to [class java.lang.Class]

I cannot deploy my fib.ear

Anyone suggestion?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3287
296
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does your persistence.xml look like?

Regards,
Frits
 
Himai Minh
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I commented out the DerbyPlatform, it works partially.


You can refer to my other post , where I ran into other problems.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3287
296
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I read the story from Oracle Glassfish persistence.xml, it looks a bit different from yours. Maybe you can try the given property from their example (I guess you are already using the <jta-data-source>jdbc/__default</jta-data-source>, right?)

Regards,
Frits
 
Himai Minh
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Frit,
This is the persistence.xml, that I modified from Martin Kalin's book:


I also modified the FibEJB.java

But I got a MarshalException. It seems like the next object cannot be marshalled.

 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3287
296
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Himai,

I had a closer look at it and I found out that there is a coding error. What you select from the database is a List of FibNum's, so this code in the book is wrong:

This is the correct code:

This will show up when the method is call from the client:


INFO: FibNum: 1 : 1
INFO: FibNum: 2 : 1
INFO: FibNum: 3 : 2
INFO: FibNum: 4 : 3
INFO: FibNum: 5 : 5
INFO: FibNum: 6 : 8
INFO: FibNum: 7 : 13


You need to adjust the client as well.

Regards,
Frits
 
Himai Minh
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Frit. Let me try it again later.
By the way, "select f from FibNum f", why we need "f" at the end?
Usually, the syntax is something like this "select name from PeopleTable".
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3287
296
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

By the way, "select f from FibNum f", why we need "f" at the end?


That is just EJB QL syntax (see JSR-317 JPA 2.0)
 
Himai Minh
Ranch Hand
Posts: 1738
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Frit. Thanks a lot. We finally make the code work.
Here is what we need to change:


I need to comment out the property name="toplink.platform.class.name"... in order to make it run.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3287
296
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the difference between the solutions is:

and

The em.createQuery() works as a "SELECT * FROM FibNum" and returns a list of FibNums
The em.createNativeQuery() selects just one column (named "f") and returns a list of Integers

The database has two columns (because of the @Entity): N and F, both Integers.

Regards,
Frits
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!