java - Spring Boot 构建良好但抛出 javax.naming.NameNotFoundException : remaining name: env/jmx/runtime when running

标签 java spring gradle spring-boot

我有一个现有的应用程序,可以通过 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 Boot 构建良好但抛出 javax.naming.NameNotFoundException : remaining name: env/jmx/runtime when running,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33179662/

相关文章:

java - 带有 Java 和 Kotlin 文件、kapt 或 annotationProcessor 的 Android 项目?

java - ReplaceChild() 时 org.w3c.dom.DOMException 没有详细消息

java - 无法让所有UI组件出现在RelativeLayout中

java - 正则表达式命令未正确执行

java - 导入java.util.*后使用entrySet()函数时找不到符号

java - 在没有 DispatcherServlet 的情况下配置 Spring REST Controller

java - 需要访问存储库的测试方法

安卓 "INSTALL_PARSE_FAILED_NO_CERTIFICATES"

java - swagger-ui 未找到 HTTP 请求的映射

Android 库 - 使用 Gradle 将多个变体发布到本地 Maven 存储库