aspose file tools*
The moose likes JBoss/WildFly and the fly likes Access EJB out of WAR in JBoss 6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Access EJB out of WAR in JBoss 6" Watch "Access EJB out of WAR in JBoss 6" New topic
Author

Access EJB out of WAR in JBoss 6

Ad Tan
Greenhorn

Joined: Oct 30, 2009
Posts: 22
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
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10263
    
168

The @Inject should work fine.


[My Blog] [JavaRanch Journal]
Ad Tan
Greenhorn

Joined: Oct 30, 2009
Posts: 22
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
Marshal

Joined: Jul 20, 2005
Posts: 10263
    
168

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

Joined: Oct 30, 2009
Posts: 22
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
Marshal

Joined: Jul 20, 2005
Posts: 10263
    
168

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Access EJB out of WAR in JBoss 6