0

According to this post, by having the spring-boot-actuator dependency in pom.xml, I could benefits from the actuator endpoints. However, I observed it breaks my existing my spring application (It is not a spring-boot application).

I added the following to my dependency in pom.xml

      <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
            <version>1.2.5.RELEASE</version>
       </dependency>

Thats it. I did not make any changes to application yet. I started the container using maven-t7-plugin. Now my application endpoint http://localhost:8010/mycontext/foo is returning 404. I commented out the above dependency in pom.xml. Now my application returns 200 OK for the above request.

Kindly help troubleshoot me as what is going wrong. I could not find any obvious reasons.

Thanks

Community
  • 1
  • 1
brain storm
  • 25,842
  • 54
  • 187
  • 349
  • It shouldn't change the context, rather maybe it somehow expects your page to be in other place? Maybe it enables spring boot web. Show us some code. – ACV Sep 03 '15 at 20:52
  • I suspect actuator won't function very well with it not being a spring-boot application. – spencergibb Sep 03 '15 at 20:53
  • @ACV. I tried on our production code. I can't share it here. But it is straightforward to test it. meanwhile I will put some simple code here – brain storm Sep 03 '15 at 21:31
  • @spencergibb: is it possible it breaks existing application just by having dependency in it? – brain storm Sep 03 '15 at 21:41
  • @brain storm, what is the actual value for foo ? – ACV Sep 03 '15 at 21:54
  • Unless you're component scanning the actuator's packages, just adding it as a dependency to a non-Boot app should have no effect. As ACV said, I think you're going to have to show some code – Andy Wilkinson Sep 03 '15 at 22:00
  • @AndyWilkinson: I suppose the problem is from `maven-t7-plugin` – brain storm Sep 03 '15 at 22:46

1 Answers1

0

When I looked at the spring logs in console, I noticed the following: WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/mycontext/foo] in DispatcherServlet with name 'DispatcherServlet'.

Since I have configured DispatcherServlet in my Spring application, I cannot use auto-configure of spring-boot-actuator.

Once I excluded that dependency, my application works as expected.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-actuator</artifactId>
    <version>1.2.5.RELEASE</version>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId> 
            <artifactId>spring-boot-autoconfigure</artifactId>
        </exclusion>
    </exclusions>
</dependency>
Karl Richter
  • 6,271
  • 17
  • 57
  • 120
brain storm
  • 25,842
  • 54
  • 187
  • 349