-
1. Re: No EJB client context is available
wdfink Feb 9, 2012 3:02 PM (in response to suman.ganta)Access to EJBs is different in AS7 see [1], for JNDI you should have a look at [2]
[1] https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI
-
2. Re: No EJB client context is available
suman.ganta Feb 9, 2012 3:14 PM (in response to wdfink)Yeah, I saw all those articles. In my case, both my webapp and the ejb are deployed together as ear. And I'm looking up with the below code -
InitialContext context = new InitialContext();
Object obj = context.lookup("java:global/<appname>/<ejbjar-name>/<ejb name>!<interface>");
MyInterface myejb = (MyInterface) obj;
The lookup works fine. Issue is with invoking methods on myejb object. It always fails with the exception mention in my first post.
-
3. Re: No EJB client context is available
wdfink Feb 9, 2012 3:17 PM (in response to suman.ganta)Why do you don't use injection and let the container do the work for you?
-
4. Re: No EJB client context is available
suman.ganta Feb 9, 2012 3:41 PM (in response to wdfink)No luck. I tried that too now. I annotated my ref with @EJB and it is being injected by the container properly (just like how the lookup was working properly) but, upon invoking a method on it, i get the same "No EJB client context is available exception".
Here is the whole situation -
my webapp receives a request, which instantiates a class A (packaged along with ejb jar). Class A has a ejb reference (@EJB(beanInterface=ICounterStore.class)) to an EJB packaged in the same jar.
Here is the EJB definition -
@Stateless
@Remote(ICounterStore.class)
public class CounterStoreBean implements ICounterStore
{
}
-
5. Re: No EJB client context is available
jaikiran Feb 9, 2012 10:11 PM (in response to suman.ganta)Please post the entire exception stacktrace.
-
6. Re: No EJB client context is available
sfcoy Feb 9, 2012 10:41 PM (in response to suman.ganta)This smells like you're doing these lookups in a new thread that you (or a library you use) created.
I don't think you can do that.
JNDI lookups from Quartz Scheduler jobs is a typical offender here.
-
7. Re: No EJB client context is available
prasad.deshpande Feb 10, 2012 10:35 AM (in response to suman.ganta)Do you by chance have jndi.properties in your classpath (lib)?