4
votes

I have an existing application that is building fine via gradle but when I run it through the embedded tomcat server, I get the following Exception. Any idea on how to resolve?

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mbeanExporter' defined in class path resource [org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.jmx.export.annotation.AnnotationMBeanExporter]: Factory method 'mbeanExporter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mbeanServer' defined in class path resource [org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.management.MBeanServer]: Factory method 'mbeanServer' threw exception; nested exception is org.springframework.jmx.MBeanServerNotFoundException: Failed to retrieve WebLogic MBeanServer from JNDI; nested exception is javax.naming.NameNotFoundException: remaining name: env/jmx/runtime at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:687) at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) at org.springframework.boot.SpringApplication.run(SpringApplication.java:967) at org.springframework.boot.SpringApplication.run(SpringApplication.java:956) at com.avada.main.Application.main(Application.java:15)

4

4 Answers

10
votes

I had the same problem and had it fixed by excluding the JmxAutoConfiguration class from the Spring Boot config.

@SpringBootApplication(exclude = JmxAutoConfiguration.class)
public class Application {...}

It seemed like Spring was trying to create a bean (mbeanExporter) detected in the weblogic api library, and this bean needed the env/jmx/runtime JNDI.

5
votes

You can skip loaded configuration of Spring Boot by adding the following line:

@EnableAutoConfiguration(exclude = { JmxAutoConfiguration.class, EndpointMBeanExportAutoConfiguration.class})

The container in new version of Spring Boot (current: 1.5.4) try to load other beans inside application server jar so you need to add the exclusion (like: EndpointMBeanExportAutoConfiguration) of this setup.

2
votes

The MBean exporter think it's running on Weblogic:

Failed to retrieve WebLogic MBeanServer from JNDI

That can only happen if weblogic.management.Helper on the classpath. You need to remove that class from the classpath. If you're not sure where that class could be, running Tomcat with -verbose:class will tell you.

2
votes

For me what worked was to place the exclude on:

@EnableAutoConfiguration(exclude = JmxAutoConfiguration.class)