Spring Boot drive port when deployed to an external Tomcat container

I have a Spring boot application that deploys to an external Tomcat container (without using the built-in container), and I'm trying to configure the drive. The problem is that management.port in application.properties does not seem to be respected by Tomcat. When I launch Spring Boot with built-in Tomcat, it works fine.

For example, having the following set in application.properties :

management.port=9010

Working endpoints for an integrated container

  • http://localhost:9010/health

Broken endpoints for an 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 any special configuration I need in the Tomcat container to open the endpoint of the Spring prefix?

I tried to set the environment variable MANAGEMENT_PORT . Most (almost all) of the documentation available has an integrated Tomcat, so tracking this issue has proven difficult.

The third comment on this answer provided some insight: https://stackoverflow.com/a/166269/2126 , which points to a GitHub file indicating that if the management port is not installed, it will be the same as the server port.

+6
source share
4 answers

We cannot specify an additional port with an external Tomcat container. Here's why: https://github.com/spring-projects/spring-boot/issues/552

The only way is to extend the endpoints using the context path, say, "/ management" and apply protection to it.

+3
source

Yes, if your application.properties has a property called "management.port: 9001" and "server.port: 9000". Then your application endpoints will be deployed on port 9000, and the actuator endpoints will be deployed on port 9001.

So, this is up to us. We can mention both properties with the same port, the application will work correctly.

0
source

In which version of Java are you using Tomcat7 under?

NB These are all assumptions - I have not been able to verify this yet

If it is Java6 (and I assume this is due to the fact that I am getting a similar problem), I suspect that this is due to the following message:

INFO: JSR 356 support for WebSocket (Java WebSocket 1.1) is not available when running on Java 6. To suppress this message, launch Tomcat on Java 7, delete WebSocket JAR files from $ CATALINA_HOME / lib, or add WebSocket JARs for tomcat.util.scan.DefaultJarScanner .jarsToSkip property in $ CATALINA_BASE / conf / catalina.properties. Please note that the obsolete Tomcat 7 WebSocket API will be available.

I can only fear that Spring Download JSR356 to tell the web application container "in addition to listening to the default port for the main application, and also listening to port X for the actuator endpoints" ... and this does not work under Java6 .. . Maybe I'm wrong.

If someone can confirm / reject this behavior, I will update this answer.

After installing Tomcat to use Java8 and removing socket boxes ( tomcat7-websocket.jar and websocket-api.jar jars), I get the following message from Spring :

osba.EndpointWebMvcAutoConfiguration: Could not start the built-in management container on another port (management endpoints are still accessible via JMX)

At the same time, the @DecipherX workaround (i.e., not setting management.port=9010 ) will output the endpoints of your actuator through the default port.

0
source

To make actuator endpoints for spring deployment of a military boot application on an external tomcat: 1) remove control. * Configurations from application.properties

2) Your working url will be http: // localhost: 8080 // health

0
source

Source: https://habr.com/ru/post/985609/


All Articles