3
votes

I am trying to enable the actuator endpoints on the same port as the application port (specified in the application.properties file by the server.port=8080) but for some reason, it does not work. When I run the application, I can get back the response from the application but not from the actuator endpoints. I can see the logs mention the endpoints being exposed beneath base path '/actuator' as shown in the screenshot below. But when I try to hit the actuator URL, it gives a 404.

URL, not working:

However, if I specify a separate port in application.properties for the actuator endpoints with the property (management.server.port=9000) then it works fine.

URL, that's working:

The only difference is about the port number but from what I read in the spring documentation, the actuator endpoints should by default be enabled on the application port if we don't specify the management.server.port. Can someone please explain what am I missing here?enter image description here PS: The application run logs are exactly the same with or without specifying the management.server.port, hence, this one screenshot is without specifying the management port. Also, I tried giving the same port number for both the property (server.port and management.server.port) but the same problem occurs. The application works on that port but the actuator endpoints do not. I am using the spring-boot version 2.0.6

These are the contents of my application.properties file:

camel.springboot.main-run-controller=true
camel.springboot.name=AppName
camel.rest.data-format-property.prettyPrint=false
camel.component.servlet.mapping.context-path=/*

server.port=8080
management.server.port=9000

management.endpoint.health.show-details=always
management.endpoint.beans.enabled=true

logging.level.org.springframework = INFO
logging.level.org.apache.camel.spring.boot = INFO
logging.level.org.apache.camel.impl = DEBUG

Here are the dependencies in pom.xml:

<dependencies>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-undertow</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-servlet-starter</artifactId>
        </dependency>
</dependencies>
3
Could you please add your full application.properties file or even a github link?dgebert
and spring boot versionLebecca
And your dependencies from pom.xml/gradle.build fileChris
@dgebert added the application.properties fileAbhishek Mishra
i think the (8080) "side effect" might be caused by camel.component.servlet.mapping.context-path=/* , have you tried the (simple) workaround, setting : management.server.port=8080 (resp. ${server.port})?xerx593

3 Answers

1
votes

Regarding the Spring Boot Actuator documentation

Exposing management endpoints by using the default HTTP port is a sensible choice for cloud-based deployments. If, however, your application runs inside your own data center, you may prefer to expose endpoints by using a different HTTP port.

it serves the Actuator using the default HTTP port (which is 8080). I did a quick check and could confirm this with Spring Boot 2.1.X and 2.2.X.

Try to remove the management.port from your config and if this does not work then the problem might come from an additional (custom) configuration in your application.

1
votes

Remove management.server.port=9000, this property overrides server.port=8080.

0
votes

Please set the below in application.properties file

management.endpoints.enabled-by-default=true 

management.endpoints.web.exposure.include=*