Accessing an EJB in an ear from a war
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!