Accessing stand-alone resource adapters from Java EE applications

You can access stand-alone resource adapters from Java™ EE applications.

About this task

Stand-alone resource adapter classes and resources can be shared across multiple Java EE applications. By default, Java EE applications do not have access to stand-alone resource adapters. To enable this access, both the resource adapter and the application must be configured in the server configuration

In the following example, an application called Scholar and an application called Student are running on a server called Academy. Both applications need access to a resource adapter called Socrates16, which is provided in the socrates.rar file that is located in the C:/adapters/version-1.6 directory.

Procedure

  1. Configure the stand-alone resource adapter.

    In the server.xml file, configure the stand-alone resource adapter by adding the following code:

     <resourceAdapter id="Socrates16" location="C:/adapters/version-1.6/socrates.rar" /> 
  2. Reference the resource adapter from the applications so that both applications can access the classes and resources that are provided in the resource adapter module.

    In the server.xml file, set the classProviderRef attribute to the ID of the resource adapter within the class loading configurations of the applications by adding the following code:

    <application id="scholar" name="Scholar" type="ear" location="scholar.ear">
     <classloader classProviderRef="Socrates16" />
    </application>
    
    <application id="student" name="Student" type="ear" location="student.ear">
     <classloader classProviderRef="Socrates16" />
    </application>
  3. Optional: Configure the class loading of the stand-alone resource adapter to access third-party APIs.

    By default, neither resource adapters nor Java applications can access third-party APIs. Whenever the class loading configuration of an application requires access to third-party APIs and the application requires access to a stand-alone resource adapter, configure the class loading of the resource adapter to also access third-party APIs.

    In the server.xml file, configure the apiTypeVisibility attribute of the class loading configuration of the resource adapter to access third-party APIs by adding the following code:

    <resourceAdapter id="Socrates16" location="C:/adapters/version-1.6/socrates.rar">
     <classloader apiTypeVisibility="spec, ibm-api, stable, third-party" />
    <resourceAdapter/> 
    
    <application id="scholar" name="Scholar" type="ear" location="scholar.ear">
     <classloader classProviderRef="Socrates16" apiTypeVisibility="spec, ibm-api, stable, third-party" />
    </application>
    
    <application id="student" name="Student" type="ear"location="student.ear">
     <classloader classProviderRef="Socrates16" apiTypeVisibility="spec, ibm-api, stable, third-party" /> 
    </application>