What is the ejb: JNDI binding in JBoss EAP 7.2 that is logged at deployment time with WFLYEJB0473: JNDI bindings...
Environment
Red Hat JBoss Enterprise Application Platform (EAP) 7.2
Issue
- What is the ejb: JNDI binding in JBoss EAP 7.2 that is logged at deployment time with WFLYEJB0473: JNDI bindings...
INFO [org.jboss.as.ejb3.deployment] (MSC service thread 1-3) WFLYEJB0473: JNDI bindings for session bean named 'Hello' in deployment unit 'subdeployment "ejb-client.jar" of deployment "app.ear"' are as follows:
java:global/app/ejb-client/Hello!com.jboss.examples.ejb.Hello
java:app/ejb-client/Hello!com.jboss.examples.ejb.Hello
java:module/Hello!com.jboss.examples.ejb.Hello
java:jboss/exported/app/ejb-client/Hello!com.jboss.examples.ejb.Hello
ejb:app/ejb-client/Hello!com.jboss.examples.ejb.Hello
java:global/app/ejb-client/Hello
java:app/ejb-client/Hello
java:module/Hello
Resolution
The ejb: binding is just showing the ejb: lookup that a remote client can use when invoking an EJB from a remote client.
As shown in [1], the remote EJB lookup is prefixed with ejb: so this binding has been there since EAP 6, in EAP 7.2 it is logged.
The java:jboss/exported indicates the EJB is available remotely and this was the indicator of what the remote binding was, as ejb: is just prefixed to the path after java:jboss/exported which is the root of what is visible remotely. All of the other bindings are only accessible when in the same JVM as the EJB.
public void callRemoteEjb() {
HelloRemote remote = getInitialContext(host, port, user, pass).lookup("ejb:helloWorld/helloWorld-ejb/HelloWorldSLSB!org.jboss.examples.ejb.HelloRemote");
remote.helloWorld();
}
public static Context getInitialContext(String host, Integer port, String username, String password) throws NamingException {
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
props.put(Context.PROVIDER_URL, String.format("%s://%s:%d", "remote+http", host, port));
if(username != null && password != null) {
props.put(Context.SECURITY_PRINCIPAL, username);
props.put(Context.SECURITY_CREDENTIALS, password);
}
return new InitialContext(props);
}
[1] How configure an EJB client in EAP 7.1+
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.