Currently when the spring.jmx.default-domain
isn't explicitly set and deploying 2 applications to the same server an exception is thrown.
Would it make sense to use the spring.application.name
as part of the spring.jmx.default-domain
in case the latter isn't explicitly set but the first is? This could also apply to the DEFAULT_JMX_NAME
that is used in the SpringApplicationAdminJmxAutoConfiguration
.
Comment From: snicoll
@mdeinum thanks for creating the issue. As I've asked you in another issue, could you please add the reference to the SO thread that made you create this? More context is always interesting.
See http://stackoverflow.com/questions/37133369/2-spring-boot-applications-deployed-in-same-server
Comment From: philwebb
We're cleaning out the issue tracker and closing issues that we've not seen much demand to fix. Feel free to comment with additional justifications if you feel that this one should not have been closed.
Comment From: shawnz
This is a simple change that would fix a basic and common use case which is currently broken by default (multiple Spring apps in one Tomcat instance). Please reconsider addressing this issue!
Comment From: wilkinsona
Thanks for sharing your opinion, @shawnz. Unfortunately, we still haven't seen sufficient demand for this issue to warrant making a change.
Comment From: imtiazShakil
I'm also facing exactly same issue.
Deploying multiple spring boot application in a Tomcat server is never possible with current approach (without explicitly setting spring.jmx.default-domain
to unique value per app).
So I also prefer @mdeinum proposal.
Comment From: Avinashachu007
I'm not alone here. Everyone here is experiencing the same issue as me, when deploying multiple spring apps on Tomcat. I Wonder, how this basic issue is still existing in a framework like Spring boot
Comment From: Diegovictorbr
I also experienced this issue while deploying two Spring Boot WAR applications that connected to the same database inside the same Tomcat 9.x container and needed to change spring.jmx.default-domain in my application.properties file.
Comment From: wilkinsona
This is much less of a problem in 2.2 as JMX is no longer enabled by default. If you choose to enable JMX and are deploying multiple applications to the same Tomcat instance, the default domain should also be configured to avoid clashes.
Comment From: shawnz
That solution is just fine for my use cases.
Thank you for all the hard work.
Comment From: crmiguez
Hi everyone. I put spring.jmx.default-domain=Application.class on application.properties, is it correct? If not, is it necessary to add the name of package or something specific? Thanks in advance! 😅
Comment From: crmiguez
https://stackoverflow.com/questions/63069433/spring-boot-how-to-configure-jmx-default-domain
Comment From: crmiguez
@snicoll I see that before, but I need to fix it in terms of application.properties file, and I have only Windows and Intellij. Could you please put an example? Thanks so much.
Comment From: shawnz
You can set it to whatever you want as long as it's unique for each application.