users@glassfish.java.net

Accessing an EJB in an ear from a war

From: <forums_at_java.net>
Date: Thu, 27 Dec 2012 07:51:07 -0600 (CST)

Hi everyone, we have the following scenario, please bear with the lengthy
explanation! We are running Glassfish 3.1.2 and we do development in
Netbeans. We have TestEar.ear containing TestWeb.war and TestEjb.jar which
contains some stateless session beans. Then we have VirtualWeb.war which we
deploy to the same Glassfish instance but a separate virtual server.
VirtualWeb.war needs to access the EJBs in TestEjb.jar (in the ear). We add
TestEjb.jar to the libraries of VirtualWeb.war so that it can compile. From
within VirtualWeb.war, we try to lookup a reference to an EJB (say Ejb1)
using the JNDI name "java:global/TestEar/TestEjb/Ejb1", however this fails.
If we instead lookup "java:global/VirtualWeb/Ejb1", this works. This means
that separate EJB components are created when deploying VirtualWeb.war. How
can this be prevented? All we want to do is access the already deployed EJBs
in TestEar.ear. Any help would be appreciated!

--
[Message sent by forum member 'chris1234']
View Post: http://forums.java.net/node/893478