• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB3 2 client apps and 2 different databases

 
eve agostini
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
is it possible to invoke the same EJB3 Session Bean from two different client applications (web application) but in such a way that each different app persists on a different database?
Thanks!

Eve
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34218
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eve,
You would have to deploy the EJB twice to make that happen. Each app could call a different ear that points to the two databases.
 
eve agostini
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your answer

I think I'm putting the persistence.xml file in the wrong place.

I've read I can:
define the unit by placing a JAR file in the lib directory of the EAR, the persistence unit will automatically be visible to all modules in the EAR


So, that's what I tried to do.

Here is the structure of my appplication:


and this is the structure of the DB2 jar file:



I get this exception:
java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName provaPU


I also tried to put the persistence.xml file directly in the archive (without the META-INF directory) but in this case the application won't event start and I'm getting this exception:
Caused by: java.lang.RuntimeException: Could not resolve a persistence unit corresponding to the persistence-context-ref-name [prova.NewSessionBean/entityManager] in the scope of the module called [EnterpriseApplication3#EJBModule1.jar]. Please verify your application.

Here is also the persistence.xml file itself:


Thanks for your help

Eve
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic