I have a Spring boot application running. Referring https://stackoverflow.com/a/36275797/6038386 to gracefully shut down the server, I included all changes in my pom.xml and application.properties.
Problem is when I am running spring boot server on one terminal (It starts successfully as expected) and try to shut it down using command: curl -X POST localhost:8000/shutdown
on another terminal, server still keeps running. It is not shutting down. On my local, I don't see any logs or exception when i hit this shutdown command.
**
Can someone please help me to figure out, what is missing in my configuration.
**
Note: When I tried to shut down the server using Jenkins job having same command (and running jenkins server had same pom and properties as my local), i got following exception: {"timestamp":1515145896307,"status":500,"error":"Internal Server Error","exception":"java.lang.NoClassDefFoundError","message":"org/springframework/boot/actuate/endpoint/ShutdownEndpoint$1","path":"/shutdown"}
My pom.xml is as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.samples</groupId>
<artifactId>AllergiesConditions</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<!-- Generic properties -->
<java.version>1.7</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
</dependency>
<!-- Exclude Spring Boot's Default Logging -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
</dependencies>
<build>
<finalName>AllergiesConditions</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
my application.properties includes following lines:
server.port=8000
endpoints.shutdown.sensitive=false
endpoints.shutdown.enabled=true
Answering my own question:
Actually it was a silly mistake. I was just copy pasting the stuff from https://stackoverflow.com/a/36275797/6038386 without actually understanding it.
I had included server.contextPath=/AllergiesConditions
in my application.properties
So now command to shutdown would become: curl -X POST localhost:8080/AllergiesConditions/shutdown
Another mistake I did was that, I didn't post my full application.properties in question's description, so actually no one could help.