Wildfly 9: EJBCLIENT000025: No EJB receiver available for handling


I recently started migrating an application from JBoss 6 to Wildfly 9 – JMS, security, datasources, significantly changed class loading behaviour – all this seemed surprisingly easy to migrate.

Things got worse when migrating the client – doing EJB3 remote access to the application running in Wildfly 9. The client as described in the Wildfly documentation was not working for me:

java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:j-lawyer-server, moduleName:j-lawyer-server-ejb, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@402bba4f
    at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:774)
    at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)
    at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)
    at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:255)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:200)
    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:183)
    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146)
    at com.sun.proxy.$Proxy2.getObservedDirectoryContent(Unknown Source)
    at WildFlyTestHttpRemoting.main(WildFlyTestHttpRemoting.java:88)

Unfortunately, also none of the other examples on the web worked.

After extensive studying of the APIs, running TRACE logging on both client and server as well as doing remote debugging of the Wildfly itself, I finally found a working clientside code that I would like to share just in case anyone else hits the same issue:

Properties props = new Properties();
props.put("remote.connections", "default");
props.put("remote.connection.default.port", "8080");
props.put("remote.connection.default.host", "localhost");
props.put("remote.connection.default.username", "admin");
props.put("remote.connection.default.password", "123");
props.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
props.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
props.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(props);
ContextSelector<EJBClientContext> contextSelector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
EJBClientContext.setSelector(contextSelector);

Properties properties = new Properties();
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
properties.put("jboss.naming.client.ejb.context", "true");
Context context = new InitialContext(properties);
IntegrationServiceRemote svc= (IntegrationServiceRemote)context.lookup("ejb:j-lawyer-server/j-lawyer-server-ejb//IntegrationService!com.jdimension.jlawyer.services.IntegrationServiceRemote");
svc.doSomething();

Note that this does NOT use an encrypted connection and that this code does not need a jndi.properties or jboss-ejb-client.properties on the class path.

Good luck.