[jira] [Commented] (AMQ-5161) NullPointerException during async startup
[ https://issues.apache.org/jira/browse/AMQ-5161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13998577#comment-13998577 ] Nate M commented on AMQ-5161: - If I'm reading it correctly (for which there is a high probability that I'm not), the current check to see if the broker has started in the VMTransportFactory's lookupBroker method are bypassed during async startup, because as Timothy mentioned, the broker is registered just as the broker startup, and before initialization of key references, begins. Consequently, the incoming VM transport will not wait for the specified period of time nor wait until the broker is started to proceed with initiating the connection. broker = registry.lookup(brokerName); if (broker == null && waitForStart > 0) { final long expiry = System.currentTimeMillis() + waitForStart; while ((broker == null || !broker.isStarted()) && expiry > System.currentTimeMillis()) { It appears that perhaps 1) the broker registration in the registry should somehow be postponed until the end of the async startup, 2) the required broker references should be initialized before the async startup begins a version of which is done in James' workaround, or 3) the broker.isStarted() check can always be required in the lookupBroker method, not just when the broker can't yet be found in the registry. Incidentally, I saw a comment on an old ticket saying, "Brokers agains start synchronously by default, which is needed for vm transport embedded case" (https://issues.apache.org/jira/browse/AMQ-3696). > NullPointerException during async startup > - > > Key: AMQ-5161 > URL: https://issues.apache.org/jira/browse/AMQ-5161 > Project: ActiveMQ > Issue Type: Bug > Components: Broker >Affects Versions: 5.9.1 >Reporter: james > Attachments: QueueService2Test.java > > > I'm using an embedded broker with asynchronous startup enabled. My setup > worked using 5.9.0. When i upgraded to 5.9.1, i started getting this > exception on startup: > {noformat} > javax.jms.JMSException: java.lang.NullPointerException > at > org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:54) > at > org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1408) > at > org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1513) > at > org.apache.activemq.ActiveMQConnection.setClientID(ActiveMQConnection.java:417) > at <...internal system startup stack trace...> > Caused by: java.lang.NullPointerException > at > org.apache.activemq.broker.jmx.ManagedRegionBroker.addConnection(ManagedRegionBroker.java:232) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.advisory.AdvisoryBroker.addConnection(AdvisoryBroker.java:91) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.MutableBrokerFilter.addConnection(MutableBrokerFilter.java:97) > at > org.apache.activemq.broker.TransportConnection.processAddConnection(TransportConnection.java:759) > at org.apache.activemq.command.ConnectionInfo.visit(ConnectionInfo.java:139) > at > org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:291) > at > org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:145) > at > org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:116) > at > org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:50) > at > org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:247) > at > org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:133) > at > org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:48) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) > at java.lang.Thread.run(Thread.java:662) > {noformat} -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (AMQ-5161) NullPointerException during async startup
[ https://issues.apache.org/jira/browse/AMQ-5161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13994548#comment-13994548 ] james commented on AMQ-5161: There was actually already a race condition on async startup, as i reported in the related issue, it just got worse in 5.9.1. i don't think there is necessarily a need for an isStarted loop. the connector already does something to that affect _after_ it gets a valid handle to the broker. the gist of the problem is that there are a few "key" broker references which _must_ be initialized before the asynchronous startup part proceeds (i.e. before the start() method call returns). if you look at the workaround i posted, you can see which references need to be initialized before the start method returns. > NullPointerException during async startup > - > > Key: AMQ-5161 > URL: https://issues.apache.org/jira/browse/AMQ-5161 > Project: ActiveMQ > Issue Type: Bug > Components: Broker >Affects Versions: 5.9.1 >Reporter: james > Attachments: QueueService2Test.java > > > I'm using an embedded broker with asynchronous startup enabled. My setup > worked using 5.9.0. When i upgraded to 5.9.1, i started getting this > exception on startup: > {noformat} > javax.jms.JMSException: java.lang.NullPointerException > at > org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:54) > at > org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1408) > at > org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1513) > at > org.apache.activemq.ActiveMQConnection.setClientID(ActiveMQConnection.java:417) > at <...internal system startup stack trace...> > Caused by: java.lang.NullPointerException > at > org.apache.activemq.broker.jmx.ManagedRegionBroker.addConnection(ManagedRegionBroker.java:232) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.advisory.AdvisoryBroker.addConnection(AdvisoryBroker.java:91) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.MutableBrokerFilter.addConnection(MutableBrokerFilter.java:97) > at > org.apache.activemq.broker.TransportConnection.processAddConnection(TransportConnection.java:759) > at org.apache.activemq.command.ConnectionInfo.visit(ConnectionInfo.java:139) > at > org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:291) > at > org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:145) > at > org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:116) > at > org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:50) > at > org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:247) > at > org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:133) > at > org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:48) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) > at java.lang.Thread.run(Thread.java:662) > {noformat} -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (AMQ-5161) NullPointerException during async startup
[ https://issues.apache.org/jira/browse/AMQ-5161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13994526#comment-13994526 ] Timothy Bish commented on AMQ-5161: --- One way to start is to try and find the commit that broke what was apparently working before. You could try using the git bisect command to run the your test code on each commit between 5.9.0 and 5.9.1 to see where things broke. If you look into the BrokerServer.java code at the start method and various aspect of the async option it should give you some insights into how things work there. The main issue seems to be that the broker is getting registered in the BrokerRegistry prior to having become fully started which allows your VM based transport to get ahead of the starting broker. > NullPointerException during async startup > - > > Key: AMQ-5161 > URL: https://issues.apache.org/jira/browse/AMQ-5161 > Project: ActiveMQ > Issue Type: Bug > Components: Broker >Affects Versions: 5.9.1 >Reporter: james > Attachments: QueueService2Test.java > > > I'm using an embedded broker with asynchronous startup enabled. My setup > worked using 5.9.0. When i upgraded to 5.9.1, i started getting this > exception on startup: > {noformat} > javax.jms.JMSException: java.lang.NullPointerException > at > org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:54) > at > org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1408) > at > org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1513) > at > org.apache.activemq.ActiveMQConnection.setClientID(ActiveMQConnection.java:417) > at <...internal system startup stack trace...> > Caused by: java.lang.NullPointerException > at > org.apache.activemq.broker.jmx.ManagedRegionBroker.addConnection(ManagedRegionBroker.java:232) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.advisory.AdvisoryBroker.addConnection(AdvisoryBroker.java:91) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.MutableBrokerFilter.addConnection(MutableBrokerFilter.java:97) > at > org.apache.activemq.broker.TransportConnection.processAddConnection(TransportConnection.java:759) > at org.apache.activemq.command.ConnectionInfo.visit(ConnectionInfo.java:139) > at > org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:291) > at > org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:145) > at > org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:116) > at > org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:50) > at > org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:247) > at > org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:133) > at > org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:48) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) > at java.lang.Thread.run(Thread.java:662) > {noformat} -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (AMQ-5161) NullPointerException during async startup
[ https://issues.apache.org/jira/browse/AMQ-5161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13994484#comment-13994484 ] Nathaniel Mar commented on AMQ-5161: I'm brand new to ActiveMQ, but am interested in contributing, so I decided to take a stab at this ticket. It seems that there may be a bit of a race condition when using the async start option on an embedded broker. I ran the provided unit test, and noticed that the NPE did not appear when I added a short delay between starting the broker and then initiating the connection to the broker. Specifically, what happens is that the main thread attempts to connect to the broker before the broker start up thread has completed (i.e. the broker has set its broker service instance). I haven't diffed the 5.9 and 5.9.1 versions so I'm not sure what could have caused this to become a new issue. As mentioned, I don't know much about the internal workings of ActiveMQ. However, as a suggestion, if the above is an accurate explanation of this issue, perhaps one possible fix would be to the TransportConnection class to wait until the broker has fully started to initiate the connection -- something along the lines of adding a "while (!broker.getBrokerService().isStarted()) " with that method already provided by the library. Any thoughts? > NullPointerException during async startup > - > > Key: AMQ-5161 > URL: https://issues.apache.org/jira/browse/AMQ-5161 > Project: ActiveMQ > Issue Type: Bug > Components: Broker >Affects Versions: 5.9.1 >Reporter: james > Attachments: QueueService2Test.java > > > I'm using an embedded broker with asynchronous startup enabled. My setup > worked using 5.9.0. When i upgraded to 5.9.1, i started getting this > exception on startup: > {noformat} > javax.jms.JMSException: java.lang.NullPointerException > at > org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:54) > at > org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1408) > at > org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1513) > at > org.apache.activemq.ActiveMQConnection.setClientID(ActiveMQConnection.java:417) > at <...internal system startup stack trace...> > Caused by: java.lang.NullPointerException > at > org.apache.activemq.broker.jmx.ManagedRegionBroker.addConnection(ManagedRegionBroker.java:232) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.advisory.AdvisoryBroker.addConnection(AdvisoryBroker.java:91) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.MutableBrokerFilter.addConnection(MutableBrokerFilter.java:97) > at > org.apache.activemq.broker.TransportConnection.processAddConnection(TransportConnection.java:759) > at org.apache.activemq.command.ConnectionInfo.visit(ConnectionInfo.java:139) > at > org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:291) > at > org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:145) > at > org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:116) > at > org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:50) > at > org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:247) > at > org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:133) > at > org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:48) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) > at java.lang.Thread.run(Thread.java:662) > {noformat} -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (AMQ-5161) NullPointerException during async startup
[ https://issues.apache.org/jira/browse/AMQ-5161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13989907#comment-13989907 ] Timothy Bish commented on AMQ-5161: --- If you can provide a unit test that reproduces that would be helpful. > NullPointerException during async startup > - > > Key: AMQ-5161 > URL: https://issues.apache.org/jira/browse/AMQ-5161 > Project: ActiveMQ > Issue Type: Bug > Components: Broker >Affects Versions: 5.9.1 >Reporter: james > > I'm using an embedded broker with asynchronous startup enabled. My setup > worked using 5.9.0. When i upgraded to 5.9.1, i started getting this > exception on startup: > {noformat} > javax.jms.JMSException: java.lang.NullPointerException > at > org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:54) > at > org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1408) > at > org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1513) > at > org.apache.activemq.ActiveMQConnection.setClientID(ActiveMQConnection.java:417) > at <...internal system startup stack trace...> > Caused by: java.lang.NullPointerException > at > org.apache.activemq.broker.jmx.ManagedRegionBroker.addConnection(ManagedRegionBroker.java:232) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.advisory.AdvisoryBroker.addConnection(AdvisoryBroker.java:91) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.MutableBrokerFilter.addConnection(MutableBrokerFilter.java:97) > at > org.apache.activemq.broker.TransportConnection.processAddConnection(TransportConnection.java:759) > at org.apache.activemq.command.ConnectionInfo.visit(ConnectionInfo.java:139) > at > org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:291) > at > org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:145) > at > org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:116) > at > org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:50) > at > org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:247) > at > org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:133) > at > org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:48) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) > at java.lang.Thread.run(Thread.java:662) > {noformat} -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (AMQ-5161) NullPointerException during async startup
[ https://issues.apache.org/jira/browse/AMQ-5161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13980227#comment-13980227 ] james commented on AMQ-5161: This is the workaround i have found which seems to get it to work: {noformat} BrokerService _broker.setStartAsync(true); org.apache.activemq.broker.Broker tmpBroker = _broker.getBroker(); org.apache.activemq.broker.Broker tmpRegBroker = _broker.getRegionBroker(); ((org.apache.activemq.broker.jmx.ManagedRegionBroker)tmpRegBroker).setContextBroker(tmpBroker); _broker.start(); {noformat} > NullPointerException during async startup > - > > Key: AMQ-5161 > URL: https://issues.apache.org/jira/browse/AMQ-5161 > Project: ActiveMQ > Issue Type: Bug > Components: Broker >Affects Versions: 5.9.1 >Reporter: james > > I'm using an embedded broker with asynchronous startup enabled. My setup > worked using 5.9.0. When i upgraded to 5.9.1, i started getting this > exception on startup: > {noformat} > javax.jms.JMSException: java.lang.NullPointerException > at > org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:54) > at > org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1408) > at > org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1513) > at > org.apache.activemq.ActiveMQConnection.setClientID(ActiveMQConnection.java:417) > at <...internal system startup stack trace...> > Caused by: java.lang.NullPointerException > at > org.apache.activemq.broker.jmx.ManagedRegionBroker.addConnection(ManagedRegionBroker.java:232) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.advisory.AdvisoryBroker.addConnection(AdvisoryBroker.java:91) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:92) > at > org.apache.activemq.broker.MutableBrokerFilter.addConnection(MutableBrokerFilter.java:97) > at > org.apache.activemq.broker.TransportConnection.processAddConnection(TransportConnection.java:759) > at org.apache.activemq.command.ConnectionInfo.visit(ConnectionInfo.java:139) > at > org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:291) > at > org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:145) > at > org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:116) > at > org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:50) > at > org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:247) > at > org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:133) > at > org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:48) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) > at java.lang.Thread.run(Thread.java:662) > {noformat} -- This message was sent by Atlassian JIRA (v6.2#6252)