• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

deploying multiple ejb module

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi experts

I have a problem in injecting EntityManager when I have multiple ejb module in my ear file. Actually, only in one EJB module I need the EntityManager and the others are only a bunch of stateless business object.
there is no persistence.xml in any module except the one that needs EntityManager. the code I am using is:

@PersistenceContext(unitName="pu-cm")
private EntityManager entityManager

but during the deployment the container complains that could not set the em.

I have test with and withour unitName attribute but no success.

the thing is when I make all my classes into one jar file and declare it as an EJB module in the application.xml everything is OK.

I am using TopLink and Sun Glassfish v9.x

I am really stuck any help would be appreciated
 
Mohammad Norouzi
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, I eventually end up to injecting EMF as the following code

@PersistenceUnit(unitName="pu-cm")
private EntityManagerFactory emf;

private EntityManager em;


@PostConstruct
public void construct(){
em = emf.createEntityManager();
}


@PreDestroy
public void destroy(){
em.close();
emf.clode();
}


but this is not good nor does it work fine

please help me
 
Be reasonable. You can't destroy everything. Where would you sit? How would you read a tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic