• 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

Access EJB out of WAR in JBoss 6

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have multiple WAR files, which read the same EJB (contained in a JAR file). These WAR and JAR files are all separately deployed in JBoss AS 6 (ie. not within the same EAR file).

Is there a way where I can access the EJB via CDI (such as @Inject) from my WAR file?

For example, my EJB:
My consumer in the WAR file:Anyone know if this is achievable? Or do I have to do it the initialContext.lookup() manner?

Thanks, Ad
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The @Inject should work fine.

 
Ad Tan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jaikiran Pai wrote:The @Inject should work fine.

Well, that's what I thought, but it doesn't work. Not even in GlassFish.

So I'm guessing it doesn't work in JEE6.

To clarify a little, here is how they are deployed:
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you actually have 2 separate applications. I'm not sure if that's supported. You can instead package the .jar and .war in a .ear and that should allow the @Inject to work. Is that something that you could try?
 
Ad Tan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was trying if Java EE can "Magically" do all these... I guess it's not there yet... Prob have to do the EAR file

BTW, do you know if I can use global JNDI for these to work?
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ad Tan wrote:

BTW, do you know if I can use global JNDI for these to work?



Yes, manual programatic lookup into java:global should work.
 
I will open the floodgates of his own worst nightmare! All in a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic