Glassfish集群上的JMS连接工厂池查找失败

时间:2016-11-17 12:02:15

标签: java glassfish jms jndi

我的应用程序在独立域上运行但在群集设置中失败。

在我的应用程序中,我有一个JCA资源适配器需要通过JMS消息在EIS中的特定情况发送消息,因此在事件发生后的连接实现中我调用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");
}

我也以那种方式查找Destination并在之后发送JMS消息。现在,当我部署到单个域时,它按预期工作,但当我尝试在集群设置中执行此操作时,我得到此异常(下面的相关详细信息):

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

我认为相关细节是:

Lookup failed for '__SYSTEM/pools/jms/__defaultConnectionFactory-Connection-Pool'.

这似乎找到了' __ SYSTEM / pools'但后来没有' jms'。我确实在Glassfish的GUI中查看了连接池 jms/__defaultConnectionFactory-Connection-Pool的配置,但我没有找到任何关于'目标的信息。那里,所以我认为它应该在整个领域都可用,包括集群。群集配置的“资源”选项卡未列出连接池(或任何其他' __ SYSTEM'条目)。

当我向glassfish询问JNDI资源可用时:

$ 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.

因此,据我所知,jms/__defaultConnectionFactory名称存在,应该在群集设置中找到与域设置一样多。

环境:

  • AS:GlassFish Server开源版4.1.1(版本1)
  • 爪哇:

    • openjdk version" 1.8.0_111"
    • OpenJDK运行时环境(版本1.8.0_111-8u111-b14-2-b14)
    • OpenJDK 64位服务器VM(版本25.111-b14,混合模式)
  • 操作系统:Linux fuchs-linux-pc 4.7.0-1-amd64#1 SMP Debian 4.7.8-1(2016-10-19)x86_64 GNU / Linux

  • 使用maven 3构建

1 个答案:

答案 0 :(得分:1)

我发现这篇文章是因为当我试图将我的项目从独立设置转移到集群设置时,我遇到了与glassfish版本4.0和4.1.1相同的问题。

在做了一些测试之后,我能够发现一些与jms系统相关的问题,仅在群集模式下与jms系统相关,只要我能够测试,从嵌入式openmq设置更改为remote或本地一个修复问题,系统在集群中运行良好。

这种行为让我觉得这个问题与嵌入式openMQ设置的JNDI树有关