Access JDBC datasource remotely in JBoss EAP

Solution Verified - Updated

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 5.x
    • 4.3
    • 4.2

Issue

  • Access JDBC datasource remotely.

Resolution

Please note that accessing a datasource from a remote client is strongly discouraged for the following reasons:

  1. It is no longer allowed in JBoss EAP 6 Does EAP 6 support remote JNDI lookup of datasource objects?
  2. It is not a good idea to have an unreliable client directly controlling the resources of your server (i.e. JDBC connections).  If the client loses network connectivity or crashes before it is able to close the connection then the connection will not be closed until the server is shutdown (i.e. it will be leaked).
  3. It is very slow.  All database operations are proxied through an MBean.
  4. Transaction propagation is not supported.

If remote access to a datasource is required then a remote session bean facade is the recommended approach.


Set <use-java-context>false</use-java-context> in the *-ds.xml for the datasource in question.  Note: This has the side-effect of causing any other component (e.g a custom application) that uses "java:/<jndi-name>" in its JNDI lookup to fail.  JNDI references to the datasource should remove "java:/" from their lookups.

Root Cause

JDBC datasources are bound into the "java:/" namespace by default.

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.