How to use the legacy EJB client with EAP 7.1 if applications from EAP 6 or 7 are migrated

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.1
  • EJB client application

Issue

  • An application uses the classes EJBClientConfiguration and ConfigBasedEJBClientContextSelector and did not compile after migrating the BOM to 7.1. Is it possible to use that API with EAP 7.1?
  • The remote-naming approach is not longer available with EAP 7.1, how can I use clients with the legacy approach?
  • The scoped-context approach is not longer available with EAP 7.1, how can I use clients with the legacy approach?

Resolution

The remote-naming and scoped-context methods of setting up a remote EJB call still work as is, but enhancements in ejb-client in EAP 7.1 resolves many of the complexities in configuration that EAP 6.x / 7.0 had, such as:

  • you can create an InitialContext(..) and use the same context to make remote EJB calls and JNDI lookups
  • the remote naming works with clustered EJBs
  • you no longer need to hold a reference to the InitialContext when using the remote-naming and scoped-context methods
  • you no longer need to ensure the remote naming / scoped context are closed
  • the # of connections used are reduced when using remote naming / scoped context

While the remote-naming / ejb-scoped-context methods still work, the remote naming InitialContext factory is deprecated in favor of the WildflyInitialContextFactory [1]. If you are using the scoped context method, you can simplify your configuration to that similar to remote naming or EAP 5 / 4 configurations as shown in [1] for JNDI, EJB and Clustered EJB invocations.

If your standalone client application was using the org.jboss.ejb.client.* classes directly to setup the configuration, this is still available , you just need to include the jboss-ejb-legacy jar in your application as described in [1]. Note: if you are packaging the jboss-client.jar in your application and needing the jboss-ejb-client.jar, you should follow the directions on [1] to assemble your standalone java client application as the jboss-client.jar in EAP 7.1 has the current ejb-client classes, where as you need the ejb-client-legacy classes and putting both jars in the same classpath does not work. Though there is no need to use the org.jboss.ejb.client.* classes in EAP 7.1, you can just take the properties you were passing in to PropertiesBasedEJBClientConfiguration and pass them directly into InitialContext(...) and then you have no dependency on the org.jboss.ejb.client classes.

It is recommended to migrate the client to the new API because of several functional drawbacks. The new API uses mostly properties to initialize and configure the InitialContext and support the cluster loadbalancing and transaction features.

But to have a smart migration for legacy clients which does not need the functionality, the underlying protocol is compatible with EAP 6.4 or 7.0 libraries and can connect to an EAP 7.1 server. Also a legacy client library is provided with the EAP server distribution and can be used.
If Maven is used for development the BOM files and dependencies are available for the legacy client as well.

For more information please read the following documentation.
[1] 7.1 Developing EJB applications - Legacy EJB client compatibility
[2] 7.1 release notes for EJB client
[3] How configure an EJB client in EAP 7.1
[4] How to change my standalone client's remote ejb configuration to not reference org.jboss.ejb.client in JBoss EAP 7.1

Root Cause

With EAP 7.1 there are a huge number of enhancements regarding ejb-client, this is based and related to the Elytron subsystem.
Because of this the former, more complicated and WildFly specific API's have been removed from the public API.

Components
Category

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.