• 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

EJB3 2 client apps and 2 different databases

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic