Проблема распределения пула JMS - PullRequest
1 голос
/ 15 октября 2011

У меня есть JMS-приложение (использующее стеклянную рыбку), которое отлично работает на localhost.После развертывания на моем сервере я продолжаю получать приведенную ниже трассировку стека при ПЕРВОМ ВЫЗОВЕ в службу.

#|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 голосов
/ 16 октября 2011

ОК, я нашел проблему. Это была проблема с памятью. У меня 756 МБ на моем сервере. Когда я развернул свое приложение JMS, у меня осталось 112 МБ. По какой-то причине glassfish не смог выделить память для пула jms с оставшихся 112 МБ. Я обновил свой VPS до 1 ГБ, и все хорошо.

...