You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by OG <og...@yahoo.com> on 2006/01/16 21:05:54 UTC

3.2.1, NPE at DefaultBroker:579

Hello,

I'm getting a NPE from DefaultBroker
(./modules/core/src/java/org/activemq/broker/impl/DefaultBroker.java),
line 579 (in release 3.2.1).

Line 579:
transientTopicMCM.sendMessage(client, message);

So transientTopicMCM must be null.


I get this errors when I try to put something in the JMS queue.  Also,
I should say that I _am_ having some issues with database connections
(running out of them), and this is very likely related to this problem.
I was wondering if somebody could take a quick look at the code below,
and tell me if I'm doing something stupid.

Code and description of DB/connection situation is followed by the
exception stack trace.

// static block in my code, executed only once in the JVM
// is doing this in a static block a bad idea?
    static {
        _connectionFactory = new ActiveMQConnectionFactory(BROKER_URL);
       
_connectionFactory.setBrokerXmlConfig(XML_CONFIGURATION_LOCATION);
    }

// called whenever a new message is sent to JMS queue, once for each
message
    public Connection createConnection() throws JMSException {
        Connection connection = _connectionFactory.createConnection();
        connection.start();
        return connection;
    }
    public Session createSession(Connection connection) throws
JMSException {
        Session session = connection.createSession(false, ACK_MODE);
        return session;
    }
    public MessageProducer createProducer(Session session, String
queue) throws JMSException {
        Destination destination = session.createQueue(queue);
        MessageProducer producer = session.createProducer(destination);
        producer.setDeliveryMode(DeliveryMode.PERSISTENT);
        return producer;
    }


The code that sends the message in the first place looks like this:


    Connection connection = null;
    Session session = null;
    MessageProducer producer = null;

    try {
        // create connection, session, producer
        connection = jmsAdapter.createConnection();
        session = jmsAdapter.createSession(connection);
        producer = jmsAdapter.createProducer(session, queue);

        // send message
        jmsAdapter.sendBinaryMessage(session, producer,
messageContent);
    } catch (JMSException e) {
        // log and rethrow
    } catch (Throwable t) {
        // log and rethrow
    }
    finally {
        try {
            // release used JMS resources
            jmsAdapter.close(connection, session, producer);
        } catch (JMSException e1) {
            // log and rethrow
        }
    }


It looks to me like there is something in ActiveMQ that gets
nulled/messed-up when the connection to the DB fails (e.g. I run out of
DB connections).
This makes 100% sense - if the DB is out of connections, and my JMS
queues are stored in the DB, of course ActiveMQ won't be able to get a
connection.

However, once my DB recovers and there ARE available connections,
further attempts to get a Connection from ActiveMQConnectionFactory
with the above code go _connectionFactory.getConnection(), STILL fail. 
It looks as if ActiveMQConnectionFactory, once messed up a bit by the
lack of DB connections, never tries to get new connections when its
getConnection() method is called.

I imagine one way of working around this is to simply create a new
ActiveMQConnectionFactory every time you need a Connection, but this
looks like a misuse of the API.

Any help would be very appreciated, as I'm having problems with this on
a production system right now. :(


This is the exception stack trace:

Caused by: javax.jms.JMSException
        at
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
        at
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:37)
        at
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:60)
        at
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1382)
        at
org.activemq.ActiveMQConnection.sendConnectionInfoToBroker(ActiveMQConnection.java:1617)
        at
org.activemq.ActiveMQConnection.start(ActiveMQConnection.java:643)
        at
com.simpy.jms.ActiveMqAdapter.createConnection(ActiveMqAdapter.java:139)
        at
com.simpy.jms.JmsQueueService.sendBinaryMessage(JmsQueueService.java:53)
        ... 33 more
Caused by: java.lang.NullPointerException
        at
org.activemq.broker.impl.DefaultBroker.doMessageSend(DefaultBroker.java:579)
        at
org.activemq.broker.impl.DefaultBroker.sendMessage(DefaultBroker.java:320)
        at
org.activemq.broker.impl.AdvisorySupport.dispatchToBroker(AdvisorySupport.java:395)
        at
org.activemq.broker.impl.AdvisorySupport.addConnection(AdvisorySupport.java:166)
        at
org.activemq.broker.impl.DefaultBroker.addClient(DefaultBroker.java:235)
        at
org.activemq.broker.impl.BrokerContainerImpl.registerConnection(BrokerContainerImpl.java:316)
        at
org.activemq.broker.impl.BrokerConnectorImpl.registerClient(BrokerConnectorImpl.java:154)
        at
org.activemq.broker.impl.BrokerClientImpl.consumeConnectionInfo(BrokerClientImpl.java:557)
        at
org.activemq.broker.impl.BrokerClientImpl.consume(BrokerClientImpl.java:373)
        at
org.activemq.transport.vm.VmTransportChannel.asyncSend(VmTransportChannel.java:143)
        at
org.activemq.transport.TransportChannelSupport.doAsyncSend(TransportChannelSupport.java:433)
        at
org.activemq.transport.TransportChannelSupport.asyncSendWithReceipt(TransportChannelSupport.java:160)
        at
org.activemq.transport.TransportChannelSupport.send(TransportChannelSupport.java:145)
        at
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1377)
        ... 37 more


Thanks,
Otis


Re: 3.2.1, NPE at DefaultBroker:579

Posted by og...@yahoo.com.
Hello,

Here are two more types of exceptions I am seeing in my JMS logs.

This one happened regularly, for a while, and then suddently stopped:

2006-01-17 00:06:24,338 ERROR [/localhost]              org.activemq.transport.NetworkChannel Failed to start NetworkChannel: reliable:tcp://localhost
javax.jms.JMSException: Failed to connect to resource(s): tcp://localhost
        at org.activemq.transport.composite.CompositeTransportChannel.establishConnection(CompositeTransportChannel.java:328)        at org.activemq.transport.composite.CompositeTransportChannel.start(CompositeTransportChannel.java:86)
        at org.activemq.ActiveMQConnection.checkClosed(ActiveMQConnection.java:810)
        at org.activemq.ActiveMQConnection.setClientID(ActiveMQConnection.java:559)
        at org.activemq.transport.NetworkChannel.initializeRemote(NetworkChannel.java:585)
        at org.activemq.transport.NetworkChannel.initialize(NetworkChannel.java:565)
        at org.activemq.transport.NetworkChannel$1.run(NetworkChannel.java:185)
        at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:595)


This one happens every time the connection to DB fails:

2006-01-17 14:53:17,627 DEBUG [stener0-18]          org.activemq.broker.impl.BrokerClientImpl brokerConnectorConnector clien\t initialized
2006-01-17 14:53:17,627 DEBUG [stener0-18]       org.activemq.broker.impl.BrokerConnectorImpl Starting new client: brokerCon\nector-client:(14760352) : VmTransportChannel: null
2006-01-17 14:53:17,629 DEBUG [stener0-18]                   org.activemq.broker.CommandTrace broker for null received: ACTI\VEMQ_CONNECTION_INFO: id = 1 ConnectionInfo{ clientId = 'ID:hvar-50409-1137474758535-30882:0' , userName = 'defaultUser' , h\ostName = 'hvar' , clientVersion = '3.2.1' , wireFormatVersion = -1, startTime = 1137527597628, started = true, closed = fal\se, properties = {noDelay=false} }
2006-01-17 14:53:17,636 WARN  [stener0-18]          org.activemq.broker.impl.BrokerClientImpl caught exception consuming pac\ket: ACTIVEMQ_CONNECTION_INFO: id = 1 ConnectionInfo{ clientId = 'ID:hvar-50409-1137474758535-30882:0' , userName = 'default\User' , hostName = 'hvar' , clientVersion = '3.2.1' , wireFormatVersion = -1, startTime = 1137527597628, started = true, clo\sed = false, properties = {noDelay=false} }
java.lang.NullPointerException
        at org.activemq.broker.impl.DefaultBroker.doMessageSend(DefaultBroker.java:579)
        at org.activemq.broker.impl.DefaultBroker.sendMessage(DefaultBroker.java:320)
        at org.activemq.broker.impl.AdvisorySupport.dispatchToBroker(AdvisorySupport.java:395)
        at org.activemq.broker.impl.AdvisorySupport.addConnection(AdvisorySupport.java:166)
        at org.activemq.broker.impl.DefaultBroker.addClient(DefaultBroker.java:235)
        at org.activemq.broker.impl.BrokerContainerImpl.registerConnection(BrokerContainerImpl.java:316)
        at org.activemq.broker.impl.BrokerConnectorImpl.registerClient(BrokerConnectorImpl.java:154)
        at org.activemq.broker.impl.BrokerClientImpl.consumeConnectionInfo(BrokerClientImpl.java:557)
        at org.activemq.broker.impl.BrokerClientImpl.consume(BrokerClientImpl.java:373)
        at org.activemq.transport.vm.VmTransportChannel.asyncSend(VmTransportChannel.java:143)
        at org.activemq.transport.TransportChannelSupport.doAsyncSend(TransportChannelSupport.java:433)
        at org.activemq.transport.TransportChannelSupport.asyncSendWithReceipt(TransportChannelSupport.java:160)
        at org.activemq.transport.TransportChannelSupport.send(TransportChannelSupport.java:145)
        at org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1377)
        at org.activemq.ActiveMQConnection.sendConnectionInfoToBroker(ActiveMQConnection.java:1617)
        at org.activemq.ActiveMQConnection.start(ActiveMQConnection.java:643)
        at com.simpy.jms.ActiveMqAdapter.createConnection(ActiveMqAdapter.java:139)
        ...
2006-01-17 14:53:17,641 DEBUG [stener0-18]                   org.activemq.broker.CommandTrace broker for ID:hvar-50409-11374\74758535-30882:0 sending: RECEIPT_INFO: id = 1 Receipt{ brokerMessageCapacity = 100, correlationId = '1' , brokerName = 'ID:\hvar-50409-1137474758535-0:0' , clusterName = 'default' , exception = java.lang.NullPointerException, failed = true }
2006-01-17 14:53:17,641 DEBUG [stener0-18]               org.activemq.util.JMSExceptionHelper
java.lang.NullPointerException
        at org.activemq.broker.impl.DefaultBroker.doMessageSend(DefaultBroker.java:579)
        at org.activemq.broker.impl.DefaultBroker.sendMessage(DefaultBroker.java:320)
        at org.activemq.broker.impl.AdvisorySupport.dispatchToBroker(AdvisorySupport.java:395)
        at org.activemq.broker.impl.AdvisorySupport.addConnection(AdvisorySupport.java:166)
        at org.activemq.broker.impl.DefaultBroker.addClient(DefaultBroker.java:235)
        at org.activemq.broker.impl.BrokerContainerImpl.registerConnection(BrokerContainerImpl.java:316)
        at org.activemq.broker.impl.BrokerConnectorImpl.registerClient(BrokerConnectorImpl.java:154)
        at org.activemq.broker.impl.BrokerClientImpl.consumeConnectionInfo(BrokerClientImpl.java:557)
        at org.activemq.broker.impl.BrokerClientImpl.consume(BrokerClientImpl.java:373)
        at org.activemq.transport.vm.VmTransportChannel.asyncSend(VmTransportChannel.java:143)
        at org.activemq.transport.TransportChannelSupport.doAsyncSend(TransportChannelSupport.java:433)
        at org.activemq.transport.TransportChannelSupport.asyncSendWithReceipt(TransportChannelSupport.java:160)
        at org.activemq.transport.TransportChannelSupport.send(TransportChannelSupport.java:145)
        at org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1377)
        at org.activemq.ActiveMQConnection.sendConnectionInfoToBroker(ActiveMQConnection.java:1617)
        at org.activemq.ActiveMQConnection.start(ActiveMQConnection.java:643)
        at com.simpy.jms.ActiveMqAdapter.createConnection(ActiveMqAdapter.java:139)
        ...



Thanks,
Otis


----- Original Message ----
From: ogjunk-amq@yahoo.com
To: activemq-users@geronimo.apache.org
Sent: Tue 17 Jan 2006 02:28:50 PM EST
Subject: Re: 3.2.1, NPE at DefaultBroker:579

Hello,

After running the code with the network channel set to 'reliable:tcp://localhost', I still get the same error and NPE that I described after ActiveMQ first encounters a situation where the DB has no available connections).

The first time ActiveMQ encounters the problem the stack trace looks like this:

javax.jms.JMSException: Failed to create transaction: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Backend start-up failed: FATAL: connection limit exceeded for non-superusers.)
        at org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
        at org.activemq.store.jdbc.JDBCPersistenceAdapter.beginTransaction(JDBCPersistenceAdapter.java:130)
        at org.activemq.store.jdbc.JDBCPersistenceAdapter.start(JDBCPersistenceAdapter.java:175)
        at org.activemq.broker.impl.DefaultBroker.start(DefaultBroker.java:165)
        at org.activemq.broker.impl.BrokerContainerImpl.start(BrokerContainerImpl.java:159)
        at org.activemq.broker.BrokerContext.getBrokerContainerByName(BrokerContext.java:57)
        at org.activemq.ActiveMQConnectionFactory.getContainer(ActiveMQConnectionFactory.java:838)
        at org.activemq.ActiveMQConnectionFactory.createBrokerConnector(ActiveMQConnectionFactory.java:845)
        at org.activemq.ActiveMQConnectionFactory.createTransportChannel(ActiveMQConnectionFactory.java:815)
        at org.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:608)
        at org.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:598)
        ....
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Backend start-up failed: FATAL: connection limit exceeded for non-superusers.)
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:855)
        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
        at org.activemq.store.jdbc.JDBCPersistenceAdapter.beginTransaction(JDBCPersistenceAdapter.java:125)
        ... 16 more
Caused by: org.postgresql.util.PSQLException: Backend start-up failed: FATAL: connection limit exceeded for non-superusers.
        at 



After this, any call to ActiveMQConnectionFactory's createConnection() method fails with the exception that is included further down.

Any help would be very appreciated!
Thanks,
Otis


----- Original Message ----
From: OG <og...@yahoo.com>
To: activemq-users@geronimo.apache.org
Sent: Mon 16 Jan 2006 05:29:29 PM EST
Subject: Re: 3.2.1, NPE at DefaultBroker:579

Hi,

I found James Strachan's pointer to:
  http://activemq.org/How+can+I+support+auto+reconnection

I've been trying to use the "reliable" configuration without any luck
so far.  I currently have this:

  <broker>
    <connector>
      <serverTransport uri="vm://localhost"/>
    </connector>
    ....
  </broker>


I am unclear where the "reliable" bit mentioned in docs needs to go.

1) Does it go into serverTransport element's uri attribute?
  e.g. <serverTransport uri="reliable:vm://localhost"/>

2) Or into tcpServerTransport's uri attribute?
  e.g. <tcpServerTransport uri="reliable:vm://localhost"/>

3) Or into networkChannel's uri attribute?
  e.g. <networkChannel uri="reliable:vm://localhost"/>



I did have a little bit of luck with this:

  <broker>
    <connector>
      <serverTransport uri="vm://localhost"/>
    </connector>
    <networkConnector>
        <networkChannel uri="reliable:tcp://localhost"
        reconnectSleepTime="10000" />
    </networkConnector>



With this I was able to:
- put a message in the JMS queue
- stop DB
- have ActiveMQ hit the wall (DB down, no connections)
- restart DB
- have ActiveMQ start acting normally, connecting to DB, etc.


Is this a good solution to my problem?

Thanks,
Otis


--- OG <og...@yahoo.com> wrote:

> Hello,
> 
> I'm getting a NPE from DefaultBroker
>
(./modules/core/src/java/org/activemq/broker/impl/DefaultBroker.java),
> line 579 (in release 3.2.1).
> 
> Line 579:
> transientTopicMCM.sendMessage(client, message);
> 
> So transientTopicMCM must be null.
> 
> 
> I get this errors when I try to put something in the JMS queue. 
> Also,
> I should say that I _am_ having some issues with database connections
> (running out of them), and this is very likely related to this
> problem.
> I was wondering if somebody could take a quick look at the code
> below,
> and tell me if I'm doing something stupid.
> 
> Code and description of DB/connection situation is followed by the
> exception stack trace.
> 
> // static block in my code, executed only once in the JVM
> // is doing this in a static block a bad idea?
>     static {
>         _connectionFactory = new
> ActiveMQConnectionFactory(BROKER_URL);
>        
> _connectionFactory.setBrokerXmlConfig(XML_CONFIGURATION_LOCATION);
>     }
> 
> // called whenever a new message is sent to JMS queue, once for each
> message
>     public Connection createConnection() throws JMSException {
>         Connection connection =
> _connectionFactory.createConnection();
>         connection.start();
>         return connection;
>     }
>     public Session createSession(Connection connection) throws
> JMSException {
>         Session session = connection.createSession(false, ACK_MODE);
>         return session;
>     }
>     public MessageProducer createProducer(Session session, String
> queue) throws JMSException {
>         Destination destination = session.createQueue(queue);
>         MessageProducer producer =
> session.createProducer(destination);
>         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
>         return producer;
>     }
> 
> 
> The code that sends the message in the first place looks like this:
> 
> 
>     Connection connection = null;
>     Session session = null;
>     MessageProducer producer = null;
> 
>     try {
>         // create connection, session, producer
>         connection = jmsAdapter.createConnection();
>         session = jmsAdapter.createSession(connection);
>         producer = jmsAdapter.createProducer(session, queue);
> 
>         // send message
>         jmsAdapter.sendBinaryMessage(session, producer,
> messageContent);
>     } catch (JMSException e) {
>         // log and rethrow
>     } catch (Throwable t) {
>         // log and rethrow
>     }
>     finally {
>         try {
>             // release used JMS resources
>             jmsAdapter.close(connection, session, producer);
>         } catch (JMSException e1) {
>             // log and rethrow
>         }
>     }
> 
> 
> It looks to me like there is something in ActiveMQ that gets
> nulled/messed-up when the connection to the DB fails (e.g. I run out
> of
> DB connections).
> This makes 100% sense - if the DB is out of connections, and my JMS
> queues are stored in the DB, of course ActiveMQ won't be able to get
> a
> connection.
> 
> However, once my DB recovers and there ARE available connections,
> further attempts to get a Connection from ActiveMQConnectionFactory
> with the above code go _connectionFactory.getConnection(), STILL
> fail. 
> It looks as if ActiveMQConnectionFactory, once messed up a bit by the
> lack of DB connections, never tries to get new connections when its
> getConnection() method is called.
> 
> I imagine one way of working around this is to simply create a new
> ActiveMQConnectionFactory every time you need a Connection, but this
> looks like a misuse of the API.
> 
> Any help would be very appreciated, as I'm having problems with this
> on
> a production system right now. :(
> 
> 
> This is the exception stack trace:
> 
> Caused by: javax.jms.JMSException
>         at
>
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
>         at
>
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:37)
>         at
>
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:60)
>         at
>
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1382)
>         at
>
org.activemq.ActiveMQConnection.sendConnectionInfoToBroker(ActiveMQConnection.java:1617)
>         at
> org.activemq.ActiveMQConnection.start(ActiveMQConnection.java:643)
>         at
>
com.simpy.jms.ActiveMqAdapter.createConnection(ActiveMqAdapter.java:139)
>         at
>
com.simpy.jms.JmsQueueService.sendBinaryMessage(JmsQueueService.java:53)
>         ... 33 more
> Caused by: java.lang.NullPointerException
>         at
>
org.activemq.broker.impl.DefaultBroker.doMessageSend(DefaultBroker.java:579)
>         at
>
org.activemq.broker.impl.DefaultBroker.sendMessage(DefaultBroker.java:320)
>         at
>
org.activemq.broker.impl.AdvisorySupport.dispatchToBroker(AdvisorySupport.java:395)
>         at
>
org.activemq.broker.impl.AdvisorySupport.addConnection(AdvisorySupport.java:166)
>         at
>
org.activemq.broker.impl.DefaultBroker.addClient(DefaultBroker.java:235)
>         at
>
org.activemq.broker.impl.BrokerContainerImpl.registerConnection(BrokerContainerImpl.java:316)
>         at
>
org.activemq.broker.impl.BrokerConnectorImpl.registerClient(BrokerConnectorImpl.java:154)
>         at
>
org.activemq.broker.impl.BrokerClientImpl.consumeConnectionInfo(BrokerClientImpl.java:557)
>         at
>
org.activemq.broker.impl.BrokerClientImpl.consume(BrokerClientImpl.java:373)
>         at
>
org.activemq.transport.vm.VmTransportChannel.asyncSend(VmTransportChannel.java:143)
>         at
>
org.activemq.transport.TransportChannelSupport.doAsyncSend(TransportChannelSupport.java:433)
>         at
>
org.activemq.transport.TransportChannelSupport.asyncSendWithReceipt(TransportChannelSupport.java:160)
>         at
>
org.activemq.transport.TransportChannelSupport.send(TransportChannelSupport.java:145)
>         at
>
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1377)
>         ... 37 more
> 
> 
> Thanks,
> Otis
> 
> 








Re: 3.2.1, NPE at DefaultBroker:579

Posted by og...@yahoo.com.
Hello,

After running the code with the network channel set to 'reliable:tcp://localhost', I still get the same error and NPE that I described after ActiveMQ first encounters a situation where the DB has no available connections).

The first time ActiveMQ encounters the problem the stack trace looks like this:

javax.jms.JMSException: Failed to create transaction: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Backend start-up failed: FATAL: connection limit exceeded for non-superusers.)
        at org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
        at org.activemq.store.jdbc.JDBCPersistenceAdapter.beginTransaction(JDBCPersistenceAdapter.java:130)
        at org.activemq.store.jdbc.JDBCPersistenceAdapter.start(JDBCPersistenceAdapter.java:175)
        at org.activemq.broker.impl.DefaultBroker.start(DefaultBroker.java:165)
        at org.activemq.broker.impl.BrokerContainerImpl.start(BrokerContainerImpl.java:159)
        at org.activemq.broker.BrokerContext.getBrokerContainerByName(BrokerContext.java:57)
        at org.activemq.ActiveMQConnectionFactory.getContainer(ActiveMQConnectionFactory.java:838)
        at org.activemq.ActiveMQConnectionFactory.createBrokerConnector(ActiveMQConnectionFactory.java:845)
        at org.activemq.ActiveMQConnectionFactory.createTransportChannel(ActiveMQConnectionFactory.java:815)
        at org.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:608)
        at org.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:598)
        ....
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Backend start-up failed: FATAL: connection limit exceeded for non-superusers.)
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:855)
        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
        at org.activemq.store.jdbc.JDBCPersistenceAdapter.beginTransaction(JDBCPersistenceAdapter.java:125)
        ... 16 more
Caused by: org.postgresql.util.PSQLException: Backend start-up failed: FATAL: connection limit exceeded for non-superusers.
        at 



After this, any call to ActiveMQConnectionFactory's createConnection() method fails with the exception that is included further down.

Any help would be very appreciated!
Thanks,
Otis


----- Original Message ----
From: OG <og...@yahoo.com>
To: activemq-users@geronimo.apache.org
Sent: Mon 16 Jan 2006 05:29:29 PM EST
Subject: Re: 3.2.1, NPE at DefaultBroker:579

Hi,

I found James Strachan's pointer to:
  http://activemq.org/How+can+I+support+auto+reconnection

I've been trying to use the "reliable" configuration without any luck
so far.  I currently have this:

  <broker>
    <connector>
      <serverTransport uri="vm://localhost"/>
    </connector>
    ....
  </broker>


I am unclear where the "reliable" bit mentioned in docs needs to go.

1) Does it go into serverTransport element's uri attribute?
  e.g. <serverTransport uri="reliable:vm://localhost"/>

2) Or into tcpServerTransport's uri attribute?
  e.g. <tcpServerTransport uri="reliable:vm://localhost"/>

3) Or into networkChannel's uri attribute?
  e.g. <networkChannel uri="reliable:vm://localhost"/>



I did have a little bit of luck with this:

  <broker>
    <connector>
      <serverTransport uri="vm://localhost"/>
    </connector>
    <networkConnector>
        <networkChannel uri="reliable:tcp://localhost"
        reconnectSleepTime="10000" />
    </networkConnector>



With this I was able to:
- put a message in the JMS queue
- stop DB
- have ActiveMQ hit the wall (DB down, no connections)
- restart DB
- have ActiveMQ start acting normally, connecting to DB, etc.


Is this a good solution to my problem?

Thanks,
Otis


--- OG <og...@yahoo.com> wrote:

> Hello,
> 
> I'm getting a NPE from DefaultBroker
>
(./modules/core/src/java/org/activemq/broker/impl/DefaultBroker.java),
> line 579 (in release 3.2.1).
> 
> Line 579:
> transientTopicMCM.sendMessage(client, message);
> 
> So transientTopicMCM must be null.
> 
> 
> I get this errors when I try to put something in the JMS queue. 
> Also,
> I should say that I _am_ having some issues with database connections
> (running out of them), and this is very likely related to this
> problem.
> I was wondering if somebody could take a quick look at the code
> below,
> and tell me if I'm doing something stupid.
> 
> Code and description of DB/connection situation is followed by the
> exception stack trace.
> 
> // static block in my code, executed only once in the JVM
> // is doing this in a static block a bad idea?
>     static {
>         _connectionFactory = new
> ActiveMQConnectionFactory(BROKER_URL);
>        
> _connectionFactory.setBrokerXmlConfig(XML_CONFIGURATION_LOCATION);
>     }
> 
> // called whenever a new message is sent to JMS queue, once for each
> message
>     public Connection createConnection() throws JMSException {
>         Connection connection =
> _connectionFactory.createConnection();
>         connection.start();
>         return connection;
>     }
>     public Session createSession(Connection connection) throws
> JMSException {
>         Session session = connection.createSession(false, ACK_MODE);
>         return session;
>     }
>     public MessageProducer createProducer(Session session, String
> queue) throws JMSException {
>         Destination destination = session.createQueue(queue);
>         MessageProducer producer =
> session.createProducer(destination);
>         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
>         return producer;
>     }
> 
> 
> The code that sends the message in the first place looks like this:
> 
> 
>     Connection connection = null;
>     Session session = null;
>     MessageProducer producer = null;
> 
>     try {
>         // create connection, session, producer
>         connection = jmsAdapter.createConnection();
>         session = jmsAdapter.createSession(connection);
>         producer = jmsAdapter.createProducer(session, queue);
> 
>         // send message
>         jmsAdapter.sendBinaryMessage(session, producer,
> messageContent);
>     } catch (JMSException e) {
>         // log and rethrow
>     } catch (Throwable t) {
>         // log and rethrow
>     }
>     finally {
>         try {
>             // release used JMS resources
>             jmsAdapter.close(connection, session, producer);
>         } catch (JMSException e1) {
>             // log and rethrow
>         }
>     }
> 
> 
> It looks to me like there is something in ActiveMQ that gets
> nulled/messed-up when the connection to the DB fails (e.g. I run out
> of
> DB connections).
> This makes 100% sense - if the DB is out of connections, and my JMS
> queues are stored in the DB, of course ActiveMQ won't be able to get
> a
> connection.
> 
> However, once my DB recovers and there ARE available connections,
> further attempts to get a Connection from ActiveMQConnectionFactory
> with the above code go _connectionFactory.getConnection(), STILL
> fail. 
> It looks as if ActiveMQConnectionFactory, once messed up a bit by the
> lack of DB connections, never tries to get new connections when its
> getConnection() method is called.
> 
> I imagine one way of working around this is to simply create a new
> ActiveMQConnectionFactory every time you need a Connection, but this
> looks like a misuse of the API.
> 
> Any help would be very appreciated, as I'm having problems with this
> on
> a production system right now. :(
> 
> 
> This is the exception stack trace:
> 
> Caused by: javax.jms.JMSException
>         at
>
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
>         at
>
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:37)
>         at
>
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:60)
>         at
>
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1382)
>         at
>
org.activemq.ActiveMQConnection.sendConnectionInfoToBroker(ActiveMQConnection.java:1617)
>         at
> org.activemq.ActiveMQConnection.start(ActiveMQConnection.java:643)
>         at
>
com.simpy.jms.ActiveMqAdapter.createConnection(ActiveMqAdapter.java:139)
>         at
>
com.simpy.jms.JmsQueueService.sendBinaryMessage(JmsQueueService.java:53)
>         ... 33 more
> Caused by: java.lang.NullPointerException
>         at
>
org.activemq.broker.impl.DefaultBroker.doMessageSend(DefaultBroker.java:579)
>         at
>
org.activemq.broker.impl.DefaultBroker.sendMessage(DefaultBroker.java:320)
>         at
>
org.activemq.broker.impl.AdvisorySupport.dispatchToBroker(AdvisorySupport.java:395)
>         at
>
org.activemq.broker.impl.AdvisorySupport.addConnection(AdvisorySupport.java:166)
>         at
>
org.activemq.broker.impl.DefaultBroker.addClient(DefaultBroker.java:235)
>         at
>
org.activemq.broker.impl.BrokerContainerImpl.registerConnection(BrokerContainerImpl.java:316)
>         at
>
org.activemq.broker.impl.BrokerConnectorImpl.registerClient(BrokerConnectorImpl.java:154)
>         at
>
org.activemq.broker.impl.BrokerClientImpl.consumeConnectionInfo(BrokerClientImpl.java:557)
>         at
>
org.activemq.broker.impl.BrokerClientImpl.consume(BrokerClientImpl.java:373)
>         at
>
org.activemq.transport.vm.VmTransportChannel.asyncSend(VmTransportChannel.java:143)
>         at
>
org.activemq.transport.TransportChannelSupport.doAsyncSend(TransportChannelSupport.java:433)
>         at
>
org.activemq.transport.TransportChannelSupport.asyncSendWithReceipt(TransportChannelSupport.java:160)
>         at
>
org.activemq.transport.TransportChannelSupport.send(TransportChannelSupport.java:145)
>         at
>
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1377)
>         ... 37 more
> 
> 
> Thanks,
> Otis
> 
> 





Re: 3.2.1, NPE at DefaultBroker:579

Posted by OG <og...@yahoo.com>.
Hi,

I found James Strachan's pointer to:
  http://activemq.org/How+can+I+support+auto+reconnection

I've been trying to use the "reliable" configuration without any luck
so far.  I currently have this:

  <broker>
    <connector>
      <serverTransport uri="vm://localhost"/>
    </connector>
    ....
  </broker>


I am unclear where the "reliable" bit mentioned in docs needs to go.

1) Does it go into serverTransport element's uri attribute?
  e.g. <serverTransport uri="reliable:vm://localhost"/>

2) Or into tcpServerTransport's uri attribute?
  e.g. <tcpServerTransport uri="reliable:vm://localhost"/>

3) Or into networkChannel's uri attribute?
  e.g. <networkChannel uri="reliable:vm://localhost"/>



I did have a little bit of luck with this:

  <broker>
    <connector>
      <serverTransport uri="vm://localhost"/>
    </connector>
    <networkConnector>
        <networkChannel uri="reliable:tcp://localhost"
        reconnectSleepTime="10000" />
    </networkConnector>



With this I was able to:
- put a message in the JMS queue
- stop DB
- have ActiveMQ hit the wall (DB down, no connections)
- restart DB
- have ActiveMQ start acting normally, connecting to DB, etc.


Is this a good solution to my problem?

Thanks,
Otis


--- OG <og...@yahoo.com> wrote:

> Hello,
> 
> I'm getting a NPE from DefaultBroker
>
(./modules/core/src/java/org/activemq/broker/impl/DefaultBroker.java),
> line 579 (in release 3.2.1).
> 
> Line 579:
> transientTopicMCM.sendMessage(client, message);
> 
> So transientTopicMCM must be null.
> 
> 
> I get this errors when I try to put something in the JMS queue. 
> Also,
> I should say that I _am_ having some issues with database connections
> (running out of them), and this is very likely related to this
> problem.
> I was wondering if somebody could take a quick look at the code
> below,
> and tell me if I'm doing something stupid.
> 
> Code and description of DB/connection situation is followed by the
> exception stack trace.
> 
> // static block in my code, executed only once in the JVM
> // is doing this in a static block a bad idea?
>     static {
>         _connectionFactory = new
> ActiveMQConnectionFactory(BROKER_URL);
>        
> _connectionFactory.setBrokerXmlConfig(XML_CONFIGURATION_LOCATION);
>     }
> 
> // called whenever a new message is sent to JMS queue, once for each
> message
>     public Connection createConnection() throws JMSException {
>         Connection connection =
> _connectionFactory.createConnection();
>         connection.start();
>         return connection;
>     }
>     public Session createSession(Connection connection) throws
> JMSException {
>         Session session = connection.createSession(false, ACK_MODE);
>         return session;
>     }
>     public MessageProducer createProducer(Session session, String
> queue) throws JMSException {
>         Destination destination = session.createQueue(queue);
>         MessageProducer producer =
> session.createProducer(destination);
>         producer.setDeliveryMode(DeliveryMode.PERSISTENT);
>         return producer;
>     }
> 
> 
> The code that sends the message in the first place looks like this:
> 
> 
>     Connection connection = null;
>     Session session = null;
>     MessageProducer producer = null;
> 
>     try {
>         // create connection, session, producer
>         connection = jmsAdapter.createConnection();
>         session = jmsAdapter.createSession(connection);
>         producer = jmsAdapter.createProducer(session, queue);
> 
>         // send message
>         jmsAdapter.sendBinaryMessage(session, producer,
> messageContent);
>     } catch (JMSException e) {
>         // log and rethrow
>     } catch (Throwable t) {
>         // log and rethrow
>     }
>     finally {
>         try {
>             // release used JMS resources
>             jmsAdapter.close(connection, session, producer);
>         } catch (JMSException e1) {
>             // log and rethrow
>         }
>     }
> 
> 
> It looks to me like there is something in ActiveMQ that gets
> nulled/messed-up when the connection to the DB fails (e.g. I run out
> of
> DB connections).
> This makes 100% sense - if the DB is out of connections, and my JMS
> queues are stored in the DB, of course ActiveMQ won't be able to get
> a
> connection.
> 
> However, once my DB recovers and there ARE available connections,
> further attempts to get a Connection from ActiveMQConnectionFactory
> with the above code go _connectionFactory.getConnection(), STILL
> fail. 
> It looks as if ActiveMQConnectionFactory, once messed up a bit by the
> lack of DB connections, never tries to get new connections when its
> getConnection() method is called.
> 
> I imagine one way of working around this is to simply create a new
> ActiveMQConnectionFactory every time you need a Connection, but this
> looks like a misuse of the API.
> 
> Any help would be very appreciated, as I'm having problems with this
> on
> a production system right now. :(
> 
> 
> This is the exception stack trace:
> 
> Caused by: javax.jms.JMSException
>         at
>
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
>         at
>
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:37)
>         at
>
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:60)
>         at
>
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1382)
>         at
>
org.activemq.ActiveMQConnection.sendConnectionInfoToBroker(ActiveMQConnection.java:1617)
>         at
> org.activemq.ActiveMQConnection.start(ActiveMQConnection.java:643)
>         at
>
com.simpy.jms.ActiveMqAdapter.createConnection(ActiveMqAdapter.java:139)
>         at
>
com.simpy.jms.JmsQueueService.sendBinaryMessage(JmsQueueService.java:53)
>         ... 33 more
> Caused by: java.lang.NullPointerException
>         at
>
org.activemq.broker.impl.DefaultBroker.doMessageSend(DefaultBroker.java:579)
>         at
>
org.activemq.broker.impl.DefaultBroker.sendMessage(DefaultBroker.java:320)
>         at
>
org.activemq.broker.impl.AdvisorySupport.dispatchToBroker(AdvisorySupport.java:395)
>         at
>
org.activemq.broker.impl.AdvisorySupport.addConnection(AdvisorySupport.java:166)
>         at
>
org.activemq.broker.impl.DefaultBroker.addClient(DefaultBroker.java:235)
>         at
>
org.activemq.broker.impl.BrokerContainerImpl.registerConnection(BrokerContainerImpl.java:316)
>         at
>
org.activemq.broker.impl.BrokerConnectorImpl.registerClient(BrokerConnectorImpl.java:154)
>         at
>
org.activemq.broker.impl.BrokerClientImpl.consumeConnectionInfo(BrokerClientImpl.java:557)
>         at
>
org.activemq.broker.impl.BrokerClientImpl.consume(BrokerClientImpl.java:373)
>         at
>
org.activemq.transport.vm.VmTransportChannel.asyncSend(VmTransportChannel.java:143)
>         at
>
org.activemq.transport.TransportChannelSupport.doAsyncSend(TransportChannelSupport.java:433)
>         at
>
org.activemq.transport.TransportChannelSupport.asyncSendWithReceipt(TransportChannelSupport.java:160)
>         at
>
org.activemq.transport.TransportChannelSupport.send(TransportChannelSupport.java:145)
>         at
>
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1377)
>         ... 37 more
> 
> 
> Thanks,
> Otis
> 
>