Wildfly 8.2.1.Final - EJB000025 - Life cycle management
twdejongh Oct 28, 2015 8:02 AMHi,
I need some assistance with remote EJB calls, and the error "java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling".
To be clear - I have a solution to the error, but what I am after is a deeper/clearer understanding of the
EJBClientContext life cycle, and where it should be managed.
Let's distinguish between the two invocation styles:
1. JNDI invocation - with ("jboss.naming.client.ejb.context", true).
2. EJB Client Properties invocation.
Style #1: JNDI
I find that rapid EJB invocation gives the EJBCLIENT000025 error after about 20 EJB method invocations.
Referring to documentation on scoped EJB contexts,
https://docs.jboss.org/author/display/WFLY8/Scoped+EJB+client+contexts
if I close the ejbRootNamingContext explicitly, I can perform thousands of EJB method invocations
without the EJBCLIENT000025 error.
try {
// close the EJB naming JNDI context
ejbRootNamingContext.close();
} catch (Throwable t) {
t.printStackTrace();
}
try {
// also close our other JNDI context since we are done with it too
jndiCtx.close();
} catch (Throwable t) {l
t.printStackTrace();
}
I debugged the EJBClientContext code, and found that the error originates here:
EJBReceiver requireEJBReceiver(final EJBClientInvocationContext clientInvocationContext, final String appName, final String moduleName, final String distinctName)
throws IllegalStateException {
// try and find a receiver which can handle this combination
final EJBReceiver ejbReceiver = this.getEJBReceiver(clientInvocationContext, appName, moduleName, distinctName);
if (ejbReceiver == null) {
====> throw Logs.MAIN.noEJBReceiverAvailableForDeploymentDuringInvocation(appName, moduleName, distinctName, clientInvocationContext);
}
return ejbReceiver;
}
==> The reason for EJB Receiver being null, is that the EJBClientContext.close() method is invoked, which then leads to the EJB
Receiver not being found.
Questions:
1. Which component invokes the close() method? Even if I re-create the context on every call, it gets closed after a certain
amount of calls. This leads me to believe that some sort of server-side state is involved. Am I correct?
2. Must I absolutely close the ejbRootNamingContext after every EJB method invocation? Can I not increase the timeout before
the context gets closed?
Style #2: EJB Client Properties
Does the use of this style - which I have not experimented with extensively - make client-side lifecycle management unnecessary?