[ 
https://issues.apache.org/jira/browse/AMQ-5161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17795092#comment-17795092
 ] 

Matt Pavlovich edited comment on AMQ-5161 at 12/10/23 5:48 PM:
---------------------------------------------------------------

I don't think this is a bug per-say. The embedded config wiring seems off-- 
perhaps there could be an improvement, but this is a NPE b/c of initialization 
of the BrokerService.

The line throwing the NPE is b/c the 'contextBroker' isn't set.. that needs to 
be the core broker in the broker chain (not a broker plugin, etc)

https://github.com/apache/activemq/blob/activemq-5.16.7/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java#L231C1-L231C77

{noformat}
    @Override
    public void addConnection(ConnectionContext context, ConnectionInfo info) 
throws Exception {
        super.addConnection(context, info);
        this.contextBroker.getBrokerService().incrementCurrentConnections();    
 // <--------    Line 231
        this.contextBroker.getBrokerService().incrementTotalConnections();
    }
{noformat}

Try settings 'useJmx=true'

This block of code in the BrokerService handles the init properly

{noformat}
        if (isUseJmx()) {
            if (getManagementContext().isCreateConnector() && 
!getManagementContext().isConnectorStarted()) {
                // try to restart management context
                // typical for slaves that use the same ports as master
                managementContext.stop();
                startManagementContext();
            }
            ManagedRegionBroker managedBroker = (ManagedRegionBroker) 
regionBroker;
            managedBroker.setContextBroker(broker);
            adminView.setBroker(managedBroker);
        }
{noformat}


was (Author: mattrpav):
I don't think this is a bug per-say. The embedded config wiring seems off-- 
perhaps there could be an improvement, but this is a NPE b/c of initialization 
of the BrokerService.

The line throwing the NPE is b/c the 'contextBroker' isn't set.. that needs to 
be the core broker in the broker chain (not a broker plugin, etc)

https://github.com/apache/activemq/blob/activemq-5.16.7/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java#L231C1-L231C77

{noformat}
    @Override
    public void addConnection(ConnectionContext context, ConnectionInfo info) 
throws Exception {
        super.addConnection(context, info);
        this.contextBroker.getBrokerService().incrementCurrentConnections();    
 // <--------    Line 231
        this.contextBroker.getBrokerService().incrementTotalConnections();
    }
{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
>            Assignee: Matt Pavlovich
>            Priority: Major
>         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
(v8.20.10#820010)

Reply via email to