How to change my standalone client's remote ejb configuration to not reference org.jboss.ejb.client in JBoss EAP 7.1

Solution Verified - Updated -

Issue

  • How to change my standalone client's remote ejb configuration to not reference org.jboss.ejb.client in JBoss EAP 7.1
  • We were using the PropertiesBasedEJBClientConfiguration configuration in JBoss EAP 6.x / 7.0 for our standalone application to call a remote EJB in JBoss EAP, is it possible to not depend on the org.jboss.ejb.client classes?
import org.jboss.ejb.client.EJBClientConfiguration;
import org.jboss.ejb.client.ContextSelector;
import org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration;
import org.jboss.ejb.client.EJBClientContext;
import org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector;

private void setupEJBContext(String host, String port, String username, String password) {
  Properties p = new Properties();           
  p.put("remote.connections", "default");
  p.put("remote.connection.default.host", host);
  p.put("remote.connection.default.port", port);
  p.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
  p.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
  p.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
  p.put("remote.connection.default.username", username);
  p.put("remote.connection.default.password", password);

  EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(p);
  ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
  EJBClientContext.setSelector(selector);
}
public void invokeEJB(String host, String port, String username, String password) {
  setupEJBContext(host, port, username, password);
  Properties env = new Properties();
  env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
  InitialContext ctx = new InitialContext(env);
  Hello ejbObject = (Hello) ctx.lookup("ejb:/ejb-client//Hello!jboss.example.ejb.Hello");
  System.out.println("Response: " + ejbObject.sayHello());
}

Environment

Red Hat JBoss Enterprise Application Platform (EAP) 7.1

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.