I have this scenario:
1. EJB Module deployed in apps folder ex: MyEJB.java is a stateless EJB
and doesn't implement any interface.
2. Web app (JSF+EJB) deployed in webapps folder.
3. All in the same server
When i want to lookup an EJB from any managedbean i do this:
String lookUp = "java:global/myEJBModuleName/MyEJB!com.test.MyEJB";
MyEJB myObject = (MyEJB) InitialContext.doLookup(lookUp);
And it works.
But when i try to do the same (lookup, same code above) inside of any EJB
that resides in my webapp i always get a
NameNotFoundException.
Debuging my project i can see the nex:
When i iterate from any managedbean, i can see my EJB Module, but when i do
the same from an EJB (that is located in webapp) i cant.
//This only works when i execute it from managedbean but not in an EJB
(from my webapp)
InitialContext ctx = new InitialContext();
NamingEnumeration<NameClassPair> list2 =
ctx.list("java:global/myEJBModuleName");
while (list2.hasMore()) {
NameClassPair next = list2.next();
System.out.println(next.getName());
}
Why i cant find my ejbmodule from EJB that is residing in my webapp??? Do i
have to do something different in EJB?