Use Java EE deployment descriptors and WebSphere bindings to define resource link references

This rule flags Context <ResourceLink> elements found in the META-INF/context.xml file that might need migration.

Apache Tomcat allows Context <ResourceLink> elements to be defined in these locations:

Since the migration tool might not have access to the Tomcat configuration directory, the migration tool only migrates the META-INF/context.xml file. ResourceLink information defined in the other locations can be copied to the META-INF/context.xml file in order for it to be processed.

The automated fix will take the information from the ResourceLink elements and creates a resource reference and a corresponding JNDI name as follows:

Note that the other ResourceLink attributes (factory, username and password) are not automatically migrated. If your application uses these attribute in a ResourceLink , then you will need to create a unique resource in the server configuration, provide the resource with a unique JNDI name, and update the IBM binding file with the new JNDI name.

If the web project is Java EE 5 or higher and the WEB-INF/web.xml does not exist, the WEB-INF/web.xml is created and the new resource link reference elements are added. If the web project is at J2EE 1.4 or lower, the automated fix will report an error.

For example, given a META-INF/Context.xml containing the following ResourceLink :

<ResourceLink global="jdbc/SampleWebGlobal" name="jdbc/SampleWeb" type="javax.sql.DataSource"/>

The automated fix will update or create a new resource-ref in the web.xml file similar to this example:

<resource-ref id="ResourceRef_1313785392722">
<res-ref-name>jdbc/SampleWeb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

The JNDI name is added to the IBM bindings file. It references the existing reference defined in web.xml. If the bindings file does not already exist, it is created.

You will also need to configure the resource in the WebSphere Application Server configuration.

For additional information on the context resource definition in Tomcat see: