JMS池分配问题

时间:2011-10-15 13:21:03

标签: java glassfish jms

我有一个JMS应用程序(使用玻璃鱼),可以在localhost上完美运行。在部署到我的服务器之后,我继续在FIRST CALL上获得以下堆栈跟踪服务。

#|2011-10-14T22:22:51.927+0400|WARNING|glassfish3.1|javax.enterprise.resource.resourceadapter.com.sun.enterprise.connectors|_ThreadID=9342;_ThreadName=Thread-1;|RAR5117 : Failed to obtain/create connection from connection pool [ jms/MyConnectionFactor ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException|#]

[#|2011-10-14T22:22:51.928+0400|SEVERE|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=9342;_ThreadName=Thread-1;|com.sun.messaging.jms.JMSException: MQRA:DCF:allocation failure:createConnection:Error in allocating a connection. Cause: null
    at com.sun.messaging.jms.ra.DirectConnectionFactory._allocateConnection(DirectConnectionFactory.java:548)
    at com.sun.messaging.jms.ra.DirectConnectionFactory.createQueueConnection(DirectConnectionFactory.java:322)
    at com.sun.messaging.jms.ra.DirectConnectionFactory.createQueueConnection(DirectConnectionFactory.java:299)
    at com.clox.web.boot.ReadOfflineMessage.run(ReadOfflineMessage.java:67)
    at java.lang.Thread.run(Thread.java:619)
Caused by: javax.resource.spi.ResourceAllocationException: Error in allocating a connection. Cause: null
    at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:310)
    at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:190)
    at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:165)
    at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:160)
    at com.sun.messaging.jms.ra.DirectConnectionFactory._allocateConnection(DirectConnectionFactory.java:543)
    ... 4 more
Caused by: com.sun.appserv.connectors.internal.api.PoolingException
    at com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure.addResource(RWLockDataStructure.java:103)
    at com.sun.enterprise.resource.pool.ConnectionPool.addResource(ConnectionPool.java:282)
    at com.sun.enterprise.resource.pool.ConnectionPool.createResourceAndAddToPool(ConnectionPool.java:1497)
    at com.sun.enterprise.resource.pool.ConnectionPool.createResources(ConnectionPool.java:940)
    at com.sun.enterprise.resource.pool.ConnectionPool.initPool(ConnectionPool.java:230)
    at com.sun.enterprise.resource.pool.ConnectionPool.internalGetResource(ConnectionPool.java:511)
    at com.sun.enterprise.resource.pool.ConnectionPool.getResource(ConnectionPool.java:381)
    at com.sun.enterprise.resource.pool.PoolManagerImpl.getResourceFromPool(PoolManagerImpl.java:242)
    at com.sun.enterprise.resource.pool.PoolManagerImpl.getResource(PoolManagerImpl.java:167)
    at com.sun.enterprise.connectors.ConnectionManagerImpl.getResource(ConnectionManagerImpl.java:335)
    at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:304)
    ... 8 more
Caused by: com.sun.appserv.connectors.internal.api.PoolingException
    at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:920)
    at com.sun.enterprise.resource.pool.ConnectionPool.createResource(ConnectionPool.java:1181)
    at com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure.addResource(RWLockDataStructure.java:98)
    ... 18 more
Caused by: java.lang.NullPointerException
    at com.sun.messaging.jms.ra.DirectConnectionFactory._createConnectionId(DirectConnectionFactory.java:424)
    at com.sun.messaging.jms.ra.DirectConnectionFactory._createConnection(DirectConnectionFactory.java:522)
    at com.sun.messaging.jms.ra.ManagedConnection.<init>(ManagedConnection.java:193)
    at com.sun.messaging.jms.ra.ManagedConnectionFactory.createManagedConnection(ManagedConnectionFactory.java:226)
    at com.sun.enterprise.resource.allocator.ConnectorAllocator.createResource(ConnectorAllocator.java:147)
    at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:903)
    ... 20 more

我确信我正在关闭所有资源,但即使我不是,我怎么能在第一次通话时用完连接池?

以下是ReadOfflineMessage.java代码中的代码。

try {
    QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) context.lookup("jms/MyConnectionFactor");

    queueConnection = queueConnectionFactory.createQueueConnection();
    QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

    Queue queue = (Queue) context.lookup("jms/CloxQueue");
    QueueReceiver queueReceiver = queueSession.createReceiver(queue, "client_name = '" + clientName + "'");

    queueReceiver.setMessageListener(new MessageListener() {

        @Override
        public void onMessage(Message message) {
            if (message instanceof TextMessage) {
                try {
                    String clientMessage = ((TextMessage) message).getText();

                    System.out.println("Message: " + clientMessage);
                    clientMessage = clientMessage.replace("message:", "");
                    com.trinisoft.cloxserver.models.Message parsedMessage = parseMessage(clientMessage);
                    System.out.println("parsed Message: " + message);
                    Client toClient = ClientList.getClient(parsedMessage.getTo());
                    toClient.getClientWriter().append("message:" + clientMessage + "\n");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    });

    queueConnection.start();
} catch (Exception e) {
    e.printStackTrace();
}

从堆栈跟踪线67是

queueConnection = queueConnectionFactory.createQueueConnection();

感谢。

1 个答案:

答案 0 :(得分:-1)

好的,我发现了问题。这是一个记忆问题。我的服务器上有756MB。当我部署我的JMS应用程序时,我剩下112MB。出于某种原因,glassfish无法从112MB左侧为jms池分配内存。我将vps升级到1GB,一切都很好。