Announcement Announcement Module
Collapse
No announcement yet.
No MBeanServer found in tests using RAD / Websphere Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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="org.springframework.jmx.support.MBeanServer 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 java.lang.management.ManagementFactory 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 [org.springframework.jmx.support.WebSphereMBeanServ 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 org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveInnerBean(BeanDefinitio nValueResolver.java:230)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:122)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1244)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1008)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:470)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Access Controller.java:214)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:217)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:429)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:729)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:381)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:96)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:44)
    at org.springframework.test.context.TestContext.loadA pplicationContext(TestContext.java:173)
    at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:199)

  • #2
    Hi Joost,

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

    - Sam

    Comment

    Working...
    X