Spring Boot构建正常,但抛出javax.naming.NameNotFoundException:剩余名称:运行时的env / jmx / runtime
作者:互联网
我有一个现有的应用程序通过gradle构建正常但是当我通过嵌入式tomcat服务器运行时,我得到以下异常.有关如何解决的任何想法?
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)
解决方法:
我遇到了同样的问题,并通过从Spring Boot配置中排除JmxAutoConfiguration类来修复它.
@SpringBootApplication(exclude = JmxAutoConfiguration.class)
public class Application {...}
看起来Spring试图创建一个在weblogic api库中检测到的bean(mbeanExporter),这个bean需要env / jmx / runtime JNDI.
标签:java,spring,gradle,spring-boot-2 来源: https://codeday.me/bug/20190717/1488799.html