Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

EJB3 2 client apps and 2 different databases

 
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
 
author & internet detective
Posts: 40213
818
Eclipse IDE VI Editor Java
  • 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
 
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic