一个Tomcat下部署多个项目异常:org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean 的解决方法
内容简介
在测试服务器上Tomcat下部署两个Spring boot项目,总是一个能启动成功,另一个启动不成功。这两个war包单独部署均能正常启动。
查看日志:启动时报出 org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean 的异常。
本文主要说明这个问题的解决方法(我的情况用下面的方法能解决)。
异常信息(部分)
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
ERROR 10-28 11:43:21(SpringApplication.java:845): Application run failed
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.cloud.context.environment.EnvironmentManager@6ae2c860] with key 'environmentManager'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:625)
at org.springframework.jmx.export.MBeanExporter.lambda$registerBeans$2(MBeanExporter.java:551)
at org.springframework.jmx.export.MBeanExporter$$Lambda$1330/227855367.accept(Unknown Source)
at java.util.HashMap.forEach(HashMap.java:1280)
at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:551)
at org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:434)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:776)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:330)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:157)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:137)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5156)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1101)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1786)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.management.InstanceAlreadyExistsException: org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
at org.springframework.jmx.support.MBeanRegistrationSupport.doRegister(MBeanRegistrationSupport.java:137)
at org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:679)
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:615)
... 28 more
解决方法
在两个项目的application.properties文件中,添加下面的定义:
spring.jmx.default-domain=xxx
注意,两个项目的xxx不能是一样的,如下图:

详细的解释可参考下面的文章:
https://blog.csdn.net/slx3320612540/article/details/87910372
一个Tomcat下部署多个项目异常:org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean 的解决方法的更多相关文章
- 一个tomcat下部署多个项目或一个服务器部署多个tomcat
最近需要把两个项目同时部署到服务器上,于是研究了一下,页借鉴了很多别人的方法,把过程记录下来,以儆效尤. 目录: 1,一个tomcat下同时部署两个项目(多个项目可以参考) 1.1项目都放在webap ...
- 一个tomcat同时部署多个项目
一个tomcat同时部署多个项目 1. 注意事项: 1. 每一个service的端口号不能产生冲突 2. service的name属性的值可以重复 name="Catalina" ...
- log4j和web.xml配置webAppRootKey 的问题(一个tomcat下部署多个应用)
转自:http://blog.csdn.net/arvin_qx/article/details/6829873 在tomcat下部署两个或多个项目时,web.xml文件中最好定义webAppRoot ...
- 一个Tomcat下部署两个,甚至多个项目
是的這是我粘過來的 Tomcat目录下的结构如图: 第一步:Tomcat默认空间webapps,中已经存在一个项目了,此时要增加一个项目运行可以将原本webapps目录copa一份, 改名为webap ...
- 一个tomcat下部署不同端口多个应用
通过配置tmcat的server.xml来实现多端口多应用: <?xml version='1.0' encoding='utf-8'?> <Server port="80 ...
- 一个tomcat上部署多个项目,并通过不同端口号访问不同的项目
原文:http://www.cnblogs.com/kismetv/p/7228274.html#title3-1 现在以部署两个项目为例: 第一步:修改tomcat下的server.xml文件 配置 ...
- 两个域名同时访问一个tomcat下的两个项目
两个域名,分别映射一个TOMCAT底下,两个应用. 分三个步骤完成. 1.域名与IP的解析,此步骤在万网等机构完成. 2.APACHE的httpd.conf的配置 <VirtualHost *: ...
- Tomcat下部署多个项目
转载地址:http://blog.csdn.net/philosophyatmath/article/details/30246631 同一端口号的多个项目部署 添加: <Context ...
- 一个tomcat中部署多个项目
在各自的项目web.xml中添加 <context-param> <param-name>webAppRootKey</param-name> <param- ...
随机推荐
- SSM学习系列
Spring+SpringMVC+MyBatis Spring+SpringMVC+MyBatis深入学习及搭建(一)——MyBatis的基础知识 Spring+SpringMVC+MyBatis深入 ...
- JVM 配置常用参数和常用 GC 调优策略
链接:https://juejin.im/post/5c94a123f265da610916081f JVM 配置常用参数 堆参数 回收器参数 如上表所示,目前主要有串行.并行和并发三种,对于大内 ...
- setdefault函数的用法及理解
setdefault函数的用法及理解 dict.setdefault(key, default=None) 功能:如果键不存在于字典中,将会添加该键并将default的值设为该键的默认值,如果键存在于 ...
- Python列表添加元素
Python列表添加元素 1.appent() 在列表尾部添加一个元素 >>>my_list.append("append方法") >>>my_ ...
- 【实战经验】--Xilinx--IPcore--PLL生成
用途: PLL用于产生自己想要的时钟,可以倍频有可以分频,通常倍频. 生成: 1.打开ISE—— Project —— New source,选择IP(CORE Generator & Arc ...
- jupyter notebook在 mac 使用
1. 查看当前 conda 所拥有的环境列表 conda env list 2. 选择要进入的环境 source activate your_env_name 3. 启动 jupyter jupyte ...
- ASP.NET MVC 页面静态化操作的思路
本文主要讲述了在asp.net mvc中,页面静态化的几种思路和方法.对于网站来说,生成纯html静态页面除了有利于seo外,还可以减轻网站的负载能力和提高网站性能.在asp.net mvc中,视图的 ...
- 一个非常有趣的爬虫小练习带ocr识别的
有个小的想法,想找一找 形近字 .百度一搜索,百度文库有一个,收费4元.而且我觉得字数不是太多.想自己弄一个,于是找到了 这个网站 http://www.fantiz5.com/xingjinzi/ ...
- 科普帖:Linux操作系统
使用计算机必然会接触操作系统,现代操作系统已经发展的十分成熟,一般用户都可以很轻松的使用计算机.然而,对于要利用计算机进行专业开发和应用的用户来说,需要更加深入地理解操作系统的原理和运行机制,这样才能 ...
- C#与.net 入门
C# 语言和 .NET Framework 介绍 https://docs.microsoft.com/zh-cn/dotnet/csharp/getting-started/introduction ...