Pro Spring Integration: Failed to find MBeans Instance
Joshua Smith
Ranch Hand
Joined: Aug 22, 2005
Posts: 192
posted
0
Pro Spring Integration Authors-
(and/or others doing JMX with Spring Integration)
I received your book this week and it came just in time! I'm actively architecting a Spring Integration application at work and your book is filling in some of the pieces that are not covered in other reference materials. Thanks!
I started with this example:
prospringintegration_src/monitoring/src/main/java/com/apress/prospringintegration/jmx/JmxNotificationListener.java
Then I did the following:
Added my own class (FileToRecordSplitter.java) to the same package as the JMX enabled example class (BasicMBean.java).
Added the @Component, @ManagedResource and @ManagedOperation to FileToRecordSplitter.java
Added the NotificationPublisher to FileToRecordSplitter.java
Added the jmx:notification-listening-channel-adapter and the elements necessary to support my splitter to notification-listener.xml.
Added the spring-integration-file dependency to the pom.xml
Finally, I executed JmxNotifcationListener.java and received a "Failed to find MBean instance" error message. Why am I receiving this error message?
Below is the error message and the things that I added to your example. Everything else is exactly as it came from the examples.
Added to pom.xml
----------------
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-file</artifactId>
</dependency>
Error Message
-------------
INFO : org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@36b8bef7: startup date [Sat Apr 23 12:12:47 EDT 2011]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [jmx/notification-listener.xml]
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Overriding bean definition for bean 'fileToRecordSplitter': replacing [Generic bean: class [com.apress.prospringintegration.jmx.FileToRecordSplitter]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [/Users/josh/Documents/ProjectsCommon/SpringIntegration/ProSpringIntegrationSourceCodeFromApress/prospringintegration_src/monitoring/target/classes/com/apress/prospringintegration/jmx/FileToRecordSplitter.class]] with [Generic bean: class [org.springframework.integration.config.ConsumerEndpointFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
INFO : org.springframework.integration.config.xml.DefaultConfiguringBeanFactoryPostProcessor - No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
INFO : org.springframework.integration.config.xml.DefaultConfiguringBeanFactoryPostProcessor - No bean named 'taskScheduler' has been explicitly defined. Therefore, a default ThreadPoolTaskScheduler will be created.
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@70d05c13: defining beans [mbeanExporter,mbeanServer,basicMBean,fileToRecordSplitter,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.integration.internalDefaultConfiguringBeanFactoryPostProcessor,notification,org.springframework.integration.jmx.NotificationListeningMessageProducer#0,org.springframework.integration.jmx.NotificationListeningMessageProducer#1,org.springframework.integration.stream.CharacterStreamWritingMessageHandler#0,org.springframework.integration.config.ConsumerEndpointFactoryBean#0,org.springframework.scheduling.support.PeriodicTrigger#0,org.springframework.integration.context.defaultPollerMetadata,fileChannel,org.springframework.integration.file.config.FileListFilterFactoryBean#0,org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean#0,fileChannel.adapter,org.springframework.integration.config.SplitterFactoryBean#0,nullChannel,errorChannel,_org.springframework.integration.errorLogger,taskScheduler]; root of factory hierarchy
INFO : org.springframework.jmx.export.annotation.AnnotationMBeanExporter - Registering beans for JMX exposure on startup
INFO : org.springframework.jmx.export.annotation.AnnotationMBeanExporter - Bean with name 'basicMBean' has been autodetected for JMX exposure
INFO : org.springframework.jmx.export.annotation.AnnotationMBeanExporter - Located managed bean 'basicMBean': registering with JMX server as MBean [com.apress.prospringintegration.jmx:name=basicMBean,type=BasicMBean]
INFO : org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler - Initializing ExecutorService 'taskScheduler'
INFO : org.springframework.context.support.DefaultLifecycleProcessor - Starting beans in phase -2147483648
INFO : org.springframework.integration.endpoint.EventDrivenConsumer - started fileToRecordSplitter
INFO : org.springframework.integration.endpoint.EventDrivenConsumer - started org.springframework.integration.config.ConsumerEndpointFactoryBean#0
INFO : org.springframework.integration.endpoint.EventDrivenConsumer - started _org.springframework.integration.errorLogger
INFO : org.springframework.context.support.DefaultLifecycleProcessor - Starting beans in phase 0
INFO : org.springframework.integration.jmx.NotificationListeningMessageProducer - started org.springframework.integration.jmx.NotificationListeningMessageProducer#0
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@70d05c13: defining beans [mbeanExporter,mbeanServer,basicMBean,fileToRecordSplitter,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.integration.internalDefaultConfiguringBeanFactoryPostProcessor,notification,org.springframework.integration.jmx.NotificationListeningMessageProducer#0,org.springframework.integration.jmx.NotificationListeningMessageProducer#1,org.springframework.integration.stream.CharacterStreamWritingMessageHandler#0,org.springframework.integration.config.ConsumerEndpointFactoryBean#0,org.springframework.scheduling.support.PeriodicTrigger#0,org.springframework.integration.context.defaultPollerMetadata,fileChannel,org.springframework.integration.file.config.FileListFilterFactoryBean#0,org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean#0,fileChannel.adapter,org.springframework.integration.config.SplitterFactoryBean#0,nullChannel,errorChannel,_org.springframework.integration.errorLogger,taskScheduler]; root of factory hierarchy
INFO : org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler - Shutting down ExecutorService 'taskScheduler'
INFO : org.springframework.jmx.export.annotation.AnnotationMBeanExporter - Unregistering JMX-exposed beans on shutdown
Exception in thread "main" org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.integration.jmx.NotificationListeningMessageProducer#1'; nested exception is java.lang.IllegalStateException: Failed to find MBean instance.
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:169)
at org.springframework.context.support.DefaultLifecycleProcessor.access$1(DefaultLifecycleProcessor.java:154)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:335)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:143)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:108)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:908)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:428)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.apress.prospringintegration.jmx.JmxNotificationListener.main(JmxNotificationListener.java:23)
Caused by: java.lang.IllegalStateException: Failed to find MBean instance.
at org.springframework.integration.jmx.NotificationListeningMessageProducer.doStart(NotificationListeningMessageProducer.java:121)
at org.springframework.integration.endpoint.AbstractEndpoint.start(AbstractEndpoint.java:84)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:166)
... 9 more
Caused by: javax.management.InstanceNotFoundException: com.apress.prospringintegration.jmx:name=fileToRecordSplitter,type=FileToRecordSplitter
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1094)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.addNotificationListener(DefaultMBeanServerInterceptor.java:1190)
at com.sun.jmx.mbeanserver.JmxMBeanServer.addNotificationListener(JmxMBeanServer.java:799)
at org.springframework.integration.jmx.NotificationListeningMessageProducer.doStart(NotificationListeningMessageProducer.java:118)
... 11 more
The reason that I wouldn't expect it to need the extra text specified in the annotation is that the class being monitored in the example doesn't have any extra text.
Can you run jconsole, which comes with the JDK, and connect to the process that is running, then click the MBeans link tab on the far right and see a section on the left with that MBean?
If you have <<jdk-install-path>>/bin in your path you can start it up with just "jconsole" on the command line.
Mark
subject: Pro Spring Integration: Failed to find MBeans Instance