I have an application that works on a standalone domain but fails in the cluster setup.
In my application I have a JCA Resource Adapter that needs to send a message over a JMS Message on a specific situation in the EIS, so in the Connection Implementation after the event I call getJMSConnectionFactory
.
private Object lookup(String what) {
try {
// needs no environment
Context jndiContext = new InitialContext();
return jndiContext.lookup(what);
} catch (NamingException ex) {
throw MyProjectException.getInstance("lookup of " + what + " failed.", ex);
}
}
public ConnectionFactory getJMSConnectionFactory() throws JMSException {
return (ConnectionFactory)lookup("java:comp/DefaultJMSConnectionFactory");
}
I also lookup the Destination that way and send the JMS message afterwards. Now that works as expected when I deploy to a single domain, but when I try to do that in a clustered setup, I get this exception (relevant details below):
javax.ejb.EJBException
Caused by: myclasspath.MyProjectException: sayHelloyOverJMS
Caused by: myclasspath.MyProjectException: lookup of java:comp/DefaultJMSConnectionFactory failed.
Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/DefaultJMSConnectionFactory' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Lookup failed for 'jms/__defaultConnectionFactory' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Unable to lookup resource : jms/__defaultConnectionFactory [Root exception is com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Lookup failed for '__SYSTEM/pools/jms/__defaultConnectionFactory-Connection-Pool' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}]]]
Caused by: javax.naming.NamingException: Lookup failed for 'jms/__defaultConnectionFactory' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Unable to lookup resource : jms/__defaultConnectionFactory [Root exception is com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Lookup failed for '__SYSTEM/pools/jms/__defaultConnectionFactory-Connection-Pool' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}]]
Caused by: javax.naming.NamingException: Unable to lookup resource : jms/__defaultConnectionFactory [Root exception is com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Lookup failed for '__SYSTEM/pools/jms/__defaultConnectionFactory-Connection-Pool' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}]
Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Lookup failed for '__SYSTEM/pools/jms/__defaultConnectionFactory-Connection-Pool' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
Caused by: javax.naming.NamingException: Lookup failed for '__SYSTEM/pools/jms/__defaultConnectionFactory-Connection-Pool' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: jms]
Caused by: javax.naming.NameNotFoundException: jms
I think the relevant details are:
Lookup failed for '__SYSTEM/pools/jms/__defaultConnectionFactory-Connection-Pool'.
That seems to find '__SYSTEM/pools' but then not 'jms'. I did look into the GUI of Glassfish to the configuration of the connection pool
jms/__defaultConnectionFactory-Connection-Pool
, but I did not find any information about 'targets' there, so I assume it should be available in the whole domain, including clusters. The Resources Tab of the cluster configuration does not list the connection pool (or any other '__SYSTEM' entries for that matter).
When I ask glassfish what JNDI Resources are available:
$ asadmin list-jms-resources cluster_name
jms/DataFlowClusterCommunicationTopic
jms/__defaultConnectionFactory
Command list-jms-resources executed successfully.
$ asadmin list-jms-resources domain-1-instance
remote failure: The list-jms-resources command is not allowed on target domain-1-instance because it is part of cluster cluster_name
Command list-jms-resources failed.
$ asadmin list-jms-resources domain
jms/DataFlowClusterCommunicationTopic
jms/__defaultConnectionFactory
Command list-jms-resources executed successfully.
So, as far as I understood it, the jms/__defaultConnectionFactory
name is present, and should be found in the clustered setup as much as the domain setup.
Environment:
- AS: GlassFish Server Open Source Edition 4.1.1 (build 1)
Java:
- openjdk version "1.8.0_111"
- OpenJDK Runtime Environment (build 1.8.0_111-8u111-b14-2-b14)
- OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)
OS: Linux fuchs-linux-pc 4.7.0-1-amd64 #1 SMP Debian 4.7.8-1 (2016-10-19) x86_64 GNU/Linux
- Build with maven 3