Using JNDI Provider to invoke an EJB session bean on a remote WebLogic domain

In the recipe, Exposing an EJB session bean as a service on the OSB using the EJB transport, we have assumed that the EJB session bean is deployed on the OSB server and by that in the same WebLogic domain.

If the EJB session bean to invoke is deployed on another WebLogic domain, which in the real world is the more typical scenario, then a JNDI Provider resource needs to be created on the OSB configuration.

Getting ready

Make sure that the EJB session bean is deployed to the OSB server as shown in the Introduction section of this chapter.

Import the OSB project containing the solution from the recipe, Exposing an EJB session bean as a service on the OSB using the EJB transport, into Eclipse from chapter-4getting-readyusing-jndi-provider-to-invoke-remote-ejb.

How to do it...

In Eclipse OEPE, perform the following steps to register a JNDI Provider resource:

  1. Right-click on the obs-cookbook-configuration configuration project and select New | JNDIProvider.
  2. Enter JNDIProviderEJB into the File name field and click on Next.
  3. Enter the URL of the JNDI Provider, in our case t3://localhost:7001 into the Provider URL field.
  4. If access to the target JNDI Provider requires a username and password, enter it into the User Name, Password, and Confirm Password fields:
    How to do it...
  5. Click on the Finish button.
  6. In order for the business service to use the JNDI Provider, the Endpoint URI needs to be changed:
  7. Navigate to the Transport tab of the CustomerManagement.biz business service.
  8. Delete the existing URI by clicking on Delete on the right side of the list.
  9. Enter the following value into the Endpoint URI field and click on Add: ejb:JNDIProviderEJB:CustomerManagementService#cookbook.model.services.CustomerManagement. The only difference to the old URI is the JNDI Provider specified after the ejb: prefix.
  10. Deploy the project to the OSB server.

The business service is now using the configured JNDI Provider to get and cache the EJB stubs.

The preferred communication mechanism from an OSB to a WebLogic server domain is either t3 or t3s, as used here.

How it works...

A JNDI Provider allows us to specify the communication protocols and security credentials used to retrieve the EJB subs bound in a JNDI tree located on a remove WebLogic server domain.

The JNDI Provider also implements an efficient caching mechanism for the remote connections as well as the EJB stubs.

If the EJBs are located in the same domain, a JNDI Provider can also be used to specify credentials and take advantage of the caching mechanism, but it's optional.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset