Announcement Announcement Module
No announcement yet.
No MBeanServer found in tests using RAD / Websphere Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • No MBeanServer found in tests using RAD / Websphere

    To control some Spring beans on runtime I enabled RMI using <context:mbean-export /> in the context. Via annotations I configured a Spring bean for RMI. When running Websphere the beans were added to the MBean server and everything works perfectly.

    However, when I now run my JUnit tests, all tests fail because the application context cannot be created. This is caused because the RMI exporter cannot find a server to export the beans to. See error trace below.
    Even though the test run independently with Maven, somehow the JVM knows I'm using Websphere and is complaining the Websphere MBean server cannot be found. Logically, because it's a test and a server is not needed.

    I tried to create an MBean server by adding <bean id="mbeanServer" class=" FactoryBean"/> to my test-context, but this didn't work. It wants the Websphere MBean server.

    I need a configuration which works both in Websphere and when running tests. Tests use an additional test-context to configure missing or dummy services which are used by the project. I had a look at the Spring code and saw it uses to determine the MBean server.
    Any ideas how I can get the test-context working with RMI enabled?
    How do I 'fool' the ManagementFactory to return the MBean server which I configure in my test-context?

    Error trace:
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'mbeanExporter': Cannot create inner bean '(inner bean)' of type [ erFactoryBean] while setting bean property 'server'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)#2': Invocation of init method failed; nested exception is org.springframework.jmx.MBeanServerNotFoundExcepti on: Could not access WebSphere's AdminServiceFactory.getMBeanFactory/getMBeanServer method; nested exception is java.lang.NullPointerException
    at nitionValueResolver.resolveInnerBean(BeanDefinitio
    at nitionValueResolver.resolveValueIfNecessary(BeanDe
    at AutowireCapableBeanFactory.applyPropertyValues(Abs
    at AutowireCapableBeanFactory.populateBean(AbstractAu
    at AutowireCapableBeanFactory.doCreateBean(AbstractAu
    at AutowireCapableBeanFactory$
    at AutowireCapableBeanFactory.createBean(AbstractAuto
    at BeanFactory$1.getObject( 64)
    at ingletonBeanRegistry.getSingleton(DefaultSingleton
    at BeanFactory.doGetBean( )
    at BeanFactory.getBean(
    at BeanFactory.getBean(
    at istableBeanFactory.preInstantiateSingletons(Defaul
    at ationContext.finishBeanFactoryInitialization(Abstr
    at ationContext.refresh(AbstractApplicationContext.ja va:381)
    at enericContextLoader.loadContext(AbstractGenericCon
    at enericContextLoader.loadContext(AbstractGenericCon
    at org.springframework.test.context.TestContext.loadA pplicationContext(
    at org.springframework.test.context.TestContext.getAp plicationContext(

  • #2
    Hi Joost,

    What's the log output if you set the log level for org.springframework.jmx to DEBUG?

    - Sam


    • #3
      Use plattform mbean server

      <bean id="mbeanServer"
      		factory-method="getPlatformMBeanServer" />