Does JBoss EAP 8 / 7 / 6 support remote JNDI lookup of datasource objects?

Solution Verified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 8.x
    • 7.x
    • 6.x

Issue

  • Does EAP 6 or EAP 7 or EAP 8 support remote JNDI lookup of datasource objects?

  • Can we do a remote JNDI lookup of a datasource? If not, is there any workaround?

  • While accessing DataSource remotely using a Standalone client we are getting the following exception:

java MySql_Client remote://localhost:4447

Oct 10, 2012 10:24:02 PM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.4.GA-redhat-1
Oct 10, 2012 10:24:02 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.4.GA-redhat-1
Oct 10, 2012 10:24:02 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.8.GA-redhat-1

     Got InitialContext ic: javax.naming.InitialContext@651dba45

    About to look up jndi name MySqlDS

Oct 10, 2012 10:24:03 PM org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1$MessageReceiver handleMessage
ERROR: org.jboss.remoting3.MessageCancelledException
Exception in thread "main" org.jboss.naming.remote.protocol.NamingIOException: Failed to lookup [Root exception is java.io.NotSerializableException: org.jboss.jca.core.connectionmanager.pool.strategy.OnePool]
    at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:49)
    at org.jboss.naming.remote.protocol.v1.Protocol$1.execute(Protocol.java:104)
    at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.lookup(RemoteNamingStoreV1.java:79)
    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)
    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at MySql_Client.main(MySql_Client.java:37)
Caused by: java.io.NotSerializableException: org.jboss.jca.core.connectionmanager.pool.strategy.OnePool
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:891)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1063)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:998)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:885)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1063)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
    at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:885)
    at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:62)
    at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:119)
    at org.jboss.naming.remote.protocol.v1.Protocol$1$2.write(Protocol.java:138)
    at org.jboss.naming.remote.protocol.v1.WriteUtil.write(WriteUtil.java:61)
    at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:128)
    at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
Caused by: an exception which occurred:
    in field pool
    in field cm
    in object org.jboss.jca.adapters.jdbc.WrapperDataSource@2bb57fd1

Resolution

No, it is not functionally possible to perform a remote JNDI lookup of a datasource starting with JBoss EAP 6.
Although prior to JBoss EAP 6 it was possible, it was never recommended (as discussed on the solution Access JDBC datasource remotely in JBoss EAP) and this functionality has been removed with EAP 6 onwards.
It is recommended, therefore, using an EJB as an intermediary in accessing the data source, and defining a proper contract for how the data should be accessed and operated on. The solution How to configure an EJB client in JBoss EAP 7 can be helpful to set up a client.

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.

Comments