You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Endre Stølsvik <Ap...@Stolsvik.com> on 2006/11/20 10:16:26 UTC

AMQ JMX: register MBeans locally w/o starting MBeans server

Hi!

I'm trying to get ActiveMQ to register to the JVM's (1.6 rc) built-in 
"JMX server", w/o specifying the -D options to forcibly start the MBean 
server.

When I fire up jconsole (or jps), I can see the different java 
processing running on my box: the Eclipse instance, the JConsole itself, 
and my application, this w/o enabling any -Dcom.sun.management.jmxremote 
switches on any of them.
   I can for each of them go in and check MBeans for "JMImplementation", 
"com.sun.management", "java.lang" and "java.util.logging".
   (However, connecting "locally" to a JVM obviously starts up a remote 
JMX server nonetheless - which JConsole then connects to).

This is what I get:
   1) Using the config fragment A, not providing -D switches, I cannot 
get the ActiveMQ instance to register its MBeans (I can't get them up in 
the JConsole). There are a bunch of exceptions like X in the log, 
appearing while starting up, and while "working" (It seems to retry 
hooking up, or something).

   2) Using the same unmodified config fragment, but now providing the 
-Dcom.sun.management.jmxremote* bunch of switches, I do get the active 
mq MBeans up in the console along with the default stash.

   3) Using the same fragment, without -D options, but with 
createMBeanServer="true" doesn't help as opposed to 1) (gives same result).

   4) Using the same fragment A, but now with both 
createMBeanServer="true" and createConnector="true", gives me TWO 
"JMX'es" on the application JVM (AND invariably gives the Y exception): 
one of them is the same as '1' above, and the other one is apparently 
implemented using mx4j - obviously missing both the "java.lang" and 
"java.util.logging" MBean sets.
   (Btw, mx4j is now in version 3.0.1, as opposed to 2.1.1 as shipped 
with ActiveMQ (it is just the next release, though!)).


What I'd like, is to get '1' working "as '2'": not specifying any -D 
options to forcibly start the JMX server, but still be able to connect 
to it "locally" as you can with the default standard MBeans, and have 
ActiveMQ's MBeans available there along with the standard stuff. Is this 
impossible? If so, why, and can it be fixt by coding?


.. Additionally, it seems like if I hit the debugger (pause the entire 
application), the system goes down rather hard, and ends up going into a 
rather thight loop in the Producer giving the Z Exception.

Regards,
Endre

A:
<amq:broker id="PicorgMQ-id" brokerName="PicorgMQ"
     useJmx="true" persistent="true">
   <amq:managementContext>
     <amq:managementContext useMBeanServer="true"
       createMBeanServer="false"
       createConnector="false"
       jmxDomainName="picorg.messageQueue" />
   </amq:managementContext>
   ...
</amq:broker>


X:
14563 [ActiveMQ Transport: tcp:///127.0.0.1:5689] WARN 
org.apache.activemq.broker.jmx.ManagedRegionBroker  - Failed to register 
MBean: 
picorg.messageQueue:BrokerName=PicorgMQ,Type=Subscription,persistentMode=Non-Durable,destinationType=Topic,destinationName=topic_//ActiveMQ.Advisory.TempQueue_topic_//ActiveMQ.Advisory.TempTopic,clientId=ID_endrehome-5687-1164011376081-4_0,consumerId=ID_endrehome-5687-1164011376081-3_1_-1_1
14563 [ActiveMQ Transport: tcp:///127.0.0.1:5689] DEBUG 
org.apache.activemq.broker.jmx.ManagedRegionBroker  - Failure reason: 
java.lang.NullPointerException
java.lang.NullPointerException
	at 
org.apache.activemq.broker.jmx.ManagedRegionBroker.registerSubscription(ManagedRegionBroker.java:302)
	at 
org.apache.activemq.broker.jmx.ManagedRegionBroker.registerSubscription(ManagedRegionBroker.java:211)
	at 
org.apache.activemq.broker.jmx.ManagedTopicRegion.createSubscription(ManagedTopicRegion.java:45)
	at 
org.apache.activemq.broker.region.AbstractRegion.addConsumer(AbstractRegion.java:201)
	at 
org.apache.activemq.broker.region.TopicRegion.addConsumer(TopicRegion.java:110)
	at 
org.apache.activemq.broker.region.RegionBroker.addConsumer(RegionBroker.java:331)
	at 
org.apache.activemq.broker.BrokerFilter.addConsumer(BrokerFilter.java:86)
	at 
org.apache.activemq.advisory.AdvisoryBroker.addConsumer(AdvisoryBroker.java:78)
	at 
org.apache.activemq.broker.BrokerFilter.addConsumer(BrokerFilter.java:86)
	at 
org.apache.activemq.broker.MutableBrokerFilter.addConsumer(MutableBrokerFilter.java:96)
	at 
org.apache.activemq.broker.TransportConnection.processAddConsumer(TransportConnection.java:568)
	at org.apache.activemq.command.ConsumerInfo.visit(ConsumerInfo.java:313)
	at 
org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:284)
	at 
org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:177)
	at 
org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:65)
	at 
org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:133)
	at 
org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:122)
	at 
org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:84)
	at 
org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:137)
	at java.lang.Thread.run(Thread.java:619)

Y:
5781 [main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory  - 
Invoking BeanPostProcessors before initialization of bean 'PicorgMQ-id'
5781 [main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory  - 
Invoking afterPropertiesSet() on bean with name 'PicorgMQ-id'
5922 [main] DEBUG org.apache.activemq.broker.jmx.ManagementContext  - 
Failed to create local registry
java.rmi.server.ExportException: internal error: ObjID already in use
	at sun.rmi.transport.ObjectTable.putTarget(ObjectTable.java:169)
	at sun.rmi.transport.Transport.exportObject(Transport.java:74)
	at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:229)
	at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:393)
	at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:129)
	at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:190)
	at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:92)
	at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:78)
	at java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:186)
	at 
org.apache.activemq.broker.jmx.ManagementContext.createConnector(ManagementContext.java:382)
	at 
org.apache.activemq.broker.jmx.ManagementContext.findMBeanServer(ManagementContext.java:301)
	at 
org.apache.activemq.broker.jmx.ManagementContext.getMBeanServer(ManagementContext.java:154)
	at 
org.apache.activemq.broker.jmx.ManagementContext.start(ManagementContext.java:78)
	at org.apache.activemq.broker.BrokerService.start(BrokerService.java:391)
	at 
org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:47)
	at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
	at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)
	at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)
	at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
...

Z:
522640 [ENDRE:TESTING:Consumer] DEBUG com.picorg.experiment.mq.Producer 
  - Starting consumption!
522640 [ENDRE:TESTING:Consumer] ERROR com.picorg.experiment.mq.Producer 
  - Got Exception while consuming.
org.apache.activemq.ConnectionFailedException: The JMS connection has 
failed: Channel was inactive for too long.
	at 
org.apache.activemq.ActiveMQConnection.checkClosedOrFailed(ActiveMQConnection.java:1230)
	at 
org.apache.activemq.ActiveMQConnection.createSession(ActiveMQConnection.java:273)
	at com.picorg.experiment.mq.Consumer.consumeMessage(Consumer.java:82)
	at com.picorg.experiment.mq.Consumer$1.run(Consumer.java:60)
	at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.activemq.transport.InactivityIOException: Channel 
was inactive for too long.
	at 
org.apache.activemq.transport.InactivityMonitor.readCheck(InactivityMonitor.java:101)
	at 
org.apache.activemq.transport.InactivityMonitor.access$000(InactivityMonitor.java:35)
	at 
org.apache.activemq.transport.InactivityMonitor$1.run(InactivityMonitor.java:51)
	at 
edu.emory.mathcs.backport.java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:431)
	at 
edu.emory.mathcs.backport.java.util.concurrent.FutureTask.runAndReset(FutureTask.java:198)
	at 
edu.emory.mathcs.backport.java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:189)
	at 
edu.emory.mathcs.backport.java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:213)
	at 
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
	at 
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
	... 1 more

Re: AMQ JMX: register MBeans locally w/o starting MBeans server

Posted by Endre Stølsvik <Ap...@Stolsvik.com>.
Endre Stølsvik wrote:
> Hi!

...
>   1) Using the config fragment A, not providing -D switches, I cannot 
...
>   2) Using the same unmodified config fragment, but now providing the 
...
>   3) Using the same fragment, without -D options, but with 
...
>   4) Using the same fragment A, but now with both 
...

There's also an interesting #5:

If I just take away the entire amq:managementContext element, AND rip 
away the mx4j jar, I get the two following exceptions: ClassNotFound for 
mx4j (which is obvious), but also java.rmi.server.ExportException while 
something is being "RMI exported" (even though the instantiation of the 
mx4j NamingService obviously didn't work out).

This somewhat puzzles me: shouldn't a java 1.5+ installation have its 
own MBean server thingy, and ActiveMQ should use that - and what is that 
"ObjID already in use" that "sun.rmi.transport.ObjectTable.putTarget" 
throws? Is it that one tries to inject the MBeans server (which didn't 
go through, ref the first exception), and this isn't allowed since it's 
already there?

I'd still like ActiveMQ just to install itself in the local MBeans 
thingy, both with or w/o remote JMX set up in the JVM, and be happy!

Log lines w/ Exceptions:

6000 [main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory  - 
Invoking BeanPostProcessors before initialization of bean 'PicorgMQ-id'
6000 [main] DEBUG 
org.springframework.beans.factory.support.DefaultListableBeanFactory  - 
Invoking afterPropertiesSet() on bean with name 'PicorgMQ-id'
6109 [main] DEBUG org.apache.activemq.broker.jmx.ManagementContext  - 
Failed to create local registry
java.lang.ClassNotFoundException: mx4j.tools.naming.NamingService
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:169)
	at 
org.apache.activemq.broker.jmx.ManagementContext.createConnector(ManagementContext.java:386)
	at 
org.apache.activemq.broker.jmx.ManagementContext.createMBeanServer(ManagementContext.java:367)
	at 
org.apache.activemq.broker.jmx.ManagementContext.findMBeanServer(ManagementContext.java:297)
	at 
org.apache.activemq.broker.jmx.ManagementContext.getMBeanServer(ManagementContext.java:154)
	at 
org.apache.activemq.broker.jmx.ManagementContext.start(ManagementContext.java:78)
	at org.apache.activemq.broker.BrokerService.start(BrokerService.java:391)
	at 
org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:47)
	at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
	at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)
	at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)
	at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
	at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
	at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
	at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
	at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:290)
	at 
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
	at 
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
	at 
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
	at 
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:68)
	at com.picorg.Picorg.newApplicationContext(Picorg.java:184)
	at com.picorg.Picorg.main(Picorg.java:83)


6125 [main] DEBUG org.apache.activemq.broker.jmx.ManagementContext  - 
Failed to create local registry
java.rmi.server.ExportException: internal error: ObjID already in use
	at sun.rmi.transport.ObjectTable.putTarget(ObjectTable.java:169)
	at sun.rmi.transport.Transport.exportObject(Transport.java:74)
	at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:229)
	at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:393)
	at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:129)
	at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:190)
	at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:92)
	at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:78)
	at java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:186)
	at 
org.apache.activemq.broker.jmx.ManagementContext.createConnector(ManagementContext.java:382)
	at 
org.apache.activemq.broker.jmx.ManagementContext.findMBeanServer(ManagementContext.java:301)
	at 
org.apache.activemq.broker.jmx.ManagementContext.getMBeanServer(ManagementContext.java:154)
	at 
org.apache.activemq.broker.jmx.ManagementContext.start(ManagementContext.java:78)
	at org.apache.activemq.broker.BrokerService.start(BrokerService.java:391)
	at 
org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:47)
	at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
	at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)
	at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)
	at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
	at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
	at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
	at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
	at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:290)
	at 
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
	at 
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
	at 
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
	at 
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:68)
	at com.picorg.Picorg.newApplicationContext(Picorg.java:184)
	at com.picorg.Picorg.main(Picorg.java:83)

6156 [main] INFO org.apache.activemq.broker.BrokerService  - ActiveMQ 
null JMS Message Broker (PicorgMQ) is starting
6156 [main] INFO org.apache.activemq.broker.BrokerService  - For help or 
more information please see: http://incubator.apache.org/activemq/
6625 [JMX connector] INFO 
org.apache.activemq.broker.jmx.ManagementContext  - JMX consoles can 
connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi

Regards,
Endre.