Reputation: 2789
I have a Spring Boot application that is deployed to an external Tomcat container (not using the embedded container), and am trying to get the actuator set up. The problem is that the management.port
in application.properties
does not seem to be honored by Tomcat. When I run Spring Boot with embedded Tomcat it works just fine.
For example, having the following set in application.properties
:
management.port=9010
Working endpoints for embedded container
http://localhost:9010/health
Non-working endpoints for external container running on port 8080
http://localhost:9010/health
http://localhost:8080/health
http://localhost:9010/<appName>/health
http://localhost:8080/<appName>/health
Is there a special configuration I need in the Tomcat container to expose a Spring Boot actuator end point?
I've tried setting an environment variable of MANAGEMENT_PORT
. Most (almost all) of the documentation available is using the embedded Tomcat, so tracking down this issue has proved to be challenging.
The third comment on this answer provided some possible insight: https://stackoverflow.com/a/28689853/2601060, which points to a GitHub file indicating that if the management port is not set, it will be the same as the server port.
Upvotes: 10
Views: 9950
Reputation: 11
I had same issue in my local environement ,
:) hope it helps someone one day..
Upvotes: 1
Reputation: 159
If you remove the management.server.port
from your configuration, the actuator will be deployed under the servlet context path in external Tomcat.
http://<--domain-->/<--servlet-context-->/actuator/health
Unless the management port has been configured to expose endpoints by using a different HTTP port, management.endpoints.web.base-path is relative to server.servlet.context-path (Servlet web applications) or spring.webflux.base-path (reactive web applications). If management.server.port is configured, management.endpoints.web.base-path is relative to management.server.base-path.
Upvotes: 0
Reputation: 25874
What Java version are you running Tomcat7 under?
N.B. This is all speculation - I haven't been able to verify this yet
If it's Java6
(and I'm guessing it is because I'm getting a similar issue), I suspect it's related to the following message:
INFO: JSR 356 WebSocket (Java WebSocket 1.1) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocket JARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available.
I can only hazard a guess, that Spring Boot use's JSR356 to tell the Web App Container to "in addition to listening to the default port for the main app, also listen on port X
for actuator endpoints"... and this isn't available running under Java6
... I'm probably wrong.
If anyone could confirm/deny this behaviour, I'll update this response.
After setting Tomcat to use Java8
, and removing the socket jars (tomcat7-websocket.jar
& websocket-api.jar
jars), I get the following message from Spring:
o.s.b.a.a.EndpointWebMvcAutoConfiguration : Could not start embedded management container on different port (management endpoints are still available through JMX)
In the meantime, @DecipherX's workaround (i.e. don't set management.port=9010
) will expose your actuator endpoints through the default port.
Upvotes: 0
Reputation: 54
We cannot specify an additional port with an external Tomcat container. Here is why : https://github.com/spring-projects/spring-boot/issues/552
The only way is to extend the endpoints using a context path, say "/management" and apply security on it.
Upvotes: 4
Reputation: 132
Yes, if your application.properties is having property called "management.port: 9001" and "server.port: 9000". Then your application end-points will deploy on port 9000 and actuator end-points will deployed on port 9001.
So its up to us. We can mention both properties with same port, application will works correctly.
Upvotes: 0