Spring Boot /actuator returns 404 not found - spring

I am using spring boot 2.1.4.RELEASE and currently trying to access http://localhost:8080/actuator but i am getting 404 not found. I am not sure what am i doing wrong here. Below is my pom dependencies-
<?xml version="1.0" encoding="UTF-8"?>
<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>com.dir</groupId>
<artifactId>api</artifactId>
<version>2.4.0</version>
<packaging>jar</packaging>
<name>Search</name>
<description>Search</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<distributionManagement>
<repository>
<id>Releases</id>
<name>repo1.releases</name>
<url>http://www.something.com</url>
</repository>
<snapshotRepository>
<id>Snapshots</id>
<name>repo1.com</name>
<url>http://repo1.com/artifactory/Snapshots</url>
</snapshotRepository>
</distributionManagement>
<properties>
<!--These two should be in all ParentPOMs -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Keep this version in sync with the pom's version ignoring "-SNAPSHOT" -->
<applicationVersion>1.0.0</applicationVersion>
<elasticsearch.version>5.2.0</elasticsearch.version>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.7</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>x-pack-transport</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>apache-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- Spring boot actuator to expose metrics endpoint -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Micormeter core dependecy -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>
<!-- Micrometer Prometheus registry -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<environmentVariables>
<version>9.9.9</version>
<basePath>http://sample-basepath.com</basePath>
</environmentVariables>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>
properties file config
management.endpoint.metrics.enabled=true
management.endpoints.web.exposure.include=*
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true
management.endpoint.health.show-details=always
management.endpoint.beans.enabled=true
when i run the application i do see this in console
2019-04-27 00:04:25.406 INFO 32522 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 16 endpoint(s) beneath base path '/actuator'
2019-04-27 00:04:25.534 INFO 32522 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '/myendpoint'

Please check if you have configured server.servlet.contextPath=/myendpoint
If you have done like this please try localhost:8080/{server.servlet.contextPath}/actuator

Spring boot Actuator URL changing through SpringBoot Releases,
Initially we can Access Actuator URL with https://localhost:8080/actuator
in early milestone versions of springboot 2.0.0 the URL is https://localhost:8080/application
Now current springboot version it can be access through https://localhost:8080/actuator

Certain actuator endpoints are disabled, and have to be enabled before you can use them. I was trying to access /actuator/beans, which turns out to be just such an endpoint. According to the docs, all you need is to enable them in your application.properties file:
management.endpoints.web.exposure.include=health,info,beans

As per above answers Try
http://localhost:8080/<server.servlet.context-path>/actuator/
but if it show error so there would be these possible reason is that you not include dependency in you pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

I'm using a spring boot.
I got this simple message from spring boot.😇
Spring Boot /actuator returns 404 not found
here is my application.yml file.
server:
port: 6150
servlet:
context-path: /
management:
server:
port: 6150
endpoints:
web:
base-path: /actuator
exposure:
include: "*"
and then:
http://localhost:6150/actuator
I know this question is quit old and some situation(condition) is different.
I hopefully someone save their time.

I had the same 404 error, even after exactly following Spring documentation. What finally worked for me was deleting actuator dependency and the jar, and adding it again, with a mvn clean install. It worked :)

I had a similar problem, but my issue was that the following application property was set in my project:
management:
endpoints:
web:
base-path: /
Which meant that the actual endpoint for something like:
http://localhost:8080/actuator/beans
was in fact:
http://localhost:8080/beans

I think there is a context path /myendpoint in your application.
Please try with this endpoint
http://localhost:8080/myendpoint/actuator

This was the first result when I googled a similar issue I was having. Unfortunately none of the solutions above worked for me but another source mentioned that I needed to set the management port:
management.server.port=8080
Which allows me to hit
http://localhost:8080/actuator/

Because you misunderstand.
Exposed endpoints are in two ways, please read carefully in the docs. One is exposed to JMX, while the other is exposed to WEB.
Obviously, if you enable the beans endpoint, it only expose to JMX.

If you are getting 401 unauthorised then you should add roll "ACTUATOR" in your token, then only you will be able to hit /actuator endpoints of your application.

It was a version conflict for me which was why the actuator endpoints were not exposed. I removed the version from the pom file for spring-boot-starter-actuator to make it work
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<!--<version>1.5.6.RELEASE</version>-->
</dependency>

For my project, the problem could be resolved by adding the maven-clean-plugin. In the project, I am using the spring-boot-maven-plugin like this:
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<outputDirectory>./out</outputDirectory>
</configuration>
I was not able to view any indicator until using the maven-clean-plugin:
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>./out</directory>
</fileset>
</filesets>
</configuration>

I solved for spring 2.6.x with a bean
#Bean
public HttpTraceRepository httpTraceRepository() {
return new InMemoryHttpTraceRepository();
}
as aware for the project instructions on the link: Spring-Boot-2.2.0-M3-Release-Notes

Related

Springboot not reading Application.yml file when I set spring.active.profile

I have application-dev.yml and application-prod.yml. I have Database props in it. When I set the spring.active.profile to dev and When I am doing a maven clean install, it's throwing me datasource.url not found error. (It's just not reading the yml files.)
But when I create another application.yml file and put the same props, it's reading it and the maven clean install is a success.
How Should I make my application read props from respective env files? (I know how to set profiles in IntelliJ) Below is my POM.
I cannot put an include tag in POM because I want to read yml files according to profiles.
See the image to get an idea of what I am trying to do. You can see the maven tool as well that I am using.
enter image description here
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.askvedicastrologers</groupId>
<artifactId>ask-vedic-astrologers</artifactId>
<version>1.0</version>
<name>AskVedicAstrologers</name>
<description>AskVedicAstrologers project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
</properties>
<!-- <packaging>jar</packaging>-->
<!-- <modules>-->
<!-- <module>../search-engine</module>-->
<!-- <module>../post-engine</module>-->
<!-- </modules>-->
<dependencies>
<!-- <!– Search-Engine module dependency –>-->
<!-- <dependency>-->
<!-- <groupId>com.askvedicastrologers</groupId>-->
<!-- <artifactId>search-engine</artifactId>-->
<!-- <version>0.0.1-SNAPSHOT</version>-->
<!-- </dependency>-->
<!-- <!– Post-Engine module dependency –>-->
<!-- <dependency>-->
<!-- <groupId>com.askvedicastrologers</groupId>-->
<!-- <artifactId>post-engine</artifactId>-->
<!-- <version>0.0.1-SNAPSHOT</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-gateway -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<version>3.1.3</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>8.1.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Use spring.profiles.active=dev instead.
If you have application-dev.yml and application-prod.yml, then you need to have one more application.yml. And on this application.yml file, you need to add
spring:
active:
profile: dev
For prod, config adds prod.
Reference
I think this should solve your issue!
I wonder if this a new bug introduced in new versions. I use to be able to debug and it will pickup the environment variables from the yaml file. Have tried different things like renaming file extention from yml to yaml, clearing cache and rebuild project, setting the active profile, removing the other profiles so there is only one active. None of them work.
As a work-around for the time-being since I really need to debug, I end up setting all the environment variables under Edit Configuration > Environment Variables. I am using IntelliJ IDEA 2022.1.1 (Ultimate Edition)

Spring boot - Eureka - Cannot resolve entry endpoints from provided configuration

I am learning spring boot eureka for registration and discovery. Basically I have a very simple spring boot application(MyApp) that retrieves data from db and display it as json and it is working fine. Now I have created a spring boot project(eureka-server) with the following dependencies:
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>eu.eureka.server</groupId>
<artifactId>eureka-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>eureka-server</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud-services.version>2.1.4.RELEASE</spring-cloud-services.version>
<spring-cloud.version>Hoxton.RC1</spring-cloud.version>
</properties>
<dependencies>
<!-- <dependency> -->
<!-- <groupId>io.pivotal.spring.cloud</groupId> -->
<!-- <artifactId>spring-cloud-services-starter-service-registry</artifactId> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.springframework.cloud</groupId> -->
<!-- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-dependencies</artifactId>
<version>${spring-cloud-services.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
</project>
My application properties for the eureka-server is as follows:
server.port=9092
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
When the project starts in order to access the eureka server dashboard I have to insert a username:user and pwd as d94653bc-e831-461c-936b-556770bf1ae0 which is generated when I start the eureka-server with command mvn spring-boot:run and i am able to login and access the dashboard:
The issue is that when i try to register my previous application(MyApp) to the eureka server with the application.properties as follows:
server.port=9090
eureka.client.serviceUrl.defaultZone=http://user:d94653bc-e831-461c-936b-556770bf1ae0:localhost:9092
The the application is annotated with:
#SpringBootApplication
#EnableDiscoveryClient
public class MyAppApplication {
When i start MyApp project the following error is displayed:
2019-10-29 13:23:11.867 ERROR 8512 --- [ restartedMain] c.n.d.s.r.aws.ConfigClusterResolver : Cannot resolve to any endpoints from provided configuration: {defaultZone=[http://user:d94653bc-e831-461c-936b-556770bf1ae0:localhost:9092/]}
If I add those two config in my application.properties for project MyApp:
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
No error is displayed when i start MyApp project but the project is not registered to the eureka-server dashboard.
Any idea what i am missing here please?
Please note i am running both project on my laptop.
I suspect the defaultURL is wrongly provided. Replace ":" with "#" before localhost
ex: http://user:d94653bc-e831-461c-936b-556770bf1ae0#localhost:9092

Error when deploy Spring Boot application in Google AppEngine + Non Zero Exit 2

I am getting below error when deploying my test maven Spring Boot REST app in GAE -
[ERROR] Failed to execute goal com.google.cloud.tools:appengine-maven-plugin:2.0.0-rc5:deploy (default-cli) on project PublicLibrary: App Engine application deployment failed: com.google.cloud.tools.appengine.operations.cloudsdk.process.ProcessHandlerException: com.google.cloud.tools.appengine.AppEngineException: Non zero exit: 2 -> [Help 1]
App.yaml looks like
runtime: java
env: flex
runtime_config:
jdk: openjdk8
env_variables:
SPRING_PROFILES_ACTIVE: "gcp"
handlers:
- url: /.*
script: this field is required, but ignored
manual_scaling:
instances: 1
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.publiclibrary</groupId>
<artifactId>PublicLibrary</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>PublicLibrary</name>
<description>Demo project for Spring data relationship</description>
<properties>
<java.version>1.8</java.version>
</properties>
<profiles>
<profile>
<id>cloud-gcp</id>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.0.0-rc5</version>
<configuration>
<deploy.projectId>libraryapi-03312019</deploy.projectId>
<deploy.version>1.0</deploy.version>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>25.0-jre</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I would appreciate any help.
Check the official Springboot sample of Google Cloud Platform to see what you might be doing different.
For example, I see that in the <properties> section it requires <maven.compiler.source> and <maven.compiler.target>:
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source> <!-- REQUIRED -->
<maven.compiler.target>${java.version}</maven.compiler.target> <!-- REQUIRED -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<appengine.maven.plugin>1.3.2</appengine.maven.plugin>
</properties>
Note that you are using version 2.0.0-rc5 for the appengine-maven-plugin so if you add it in the properties like above you should use the same version as in the plugin section:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.maven.plugin}</version>
</plugin>
Thanks. I followed the sample app and add the differences to my pom.xml. That alone didn't fix the issue. Additionally, I added legacy health checks that to app.yaml that allowed to deploy the app (which took quite some time) -
health_check:
enable_health_check: True
check_interval_sec: 5
timeout_sec: 4
unhealthy_threshold: 2
healthy_threshold: 2
But after deployment when I try to access the app as https://< project-id>:appspot.com I get below error -
Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.
UPDATE
I added the resources section to app.yaml as in GAE Java is known to consume high memory as identified in this article
resources:
cpu: 2
memory_gb: 2.3
disk_size_gb: 10
volumes:
- name: ramdisk1
volume_type: tmpfs
size_gb: 0.5

configuring HTTP endpoint to shutdown a spring boot web application

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
With the 1.5 version of spring boot , i think there is no sure shutdown mechanism.
You can see check this link and follow how to properly shutdown with jmx or http, https://github.com/corentin59/spring-boot-graceful-shutdown in your application.
good Luck
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.

microservices spring cloud, security, oauth2, Netflix OSS #EnableOAuth2Resource not exist in spring security 1.1

I use this tutorial http://callistaenterprise.se/blogg/teknik/2015/04/27/building-microservices-part-3-secure-APIs-with-OAuth/ to create organized webservices project based on Netflix OSS by using the following technologies spring cloud, boot, security, oauth2.
I'm using spring security 1.1 and I see annotation #EnableOAuth2Resource not exist in the spring security 1.1 what I should do?
Maven Dependencies
<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>auctionblox</groupId>
<artifactId>auth-microservice</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.RELEASE</version>
</parent>
<properties>
<!-- Stand-alone RESTFul application for testing only -->
<start-class>io.pivotal.microservices.services.Main</start-class>
</properties>
<dependencies>
<dependency>
<!-- Setup Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!--<dependency>-->
<!--<!– Setup Spring MVC & REST, use Embedded Tomcat –>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-web</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<!-- Setup Spring Data common components -->
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<!-- Testing starter -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<!-- Setup Spring Data JPA Repository support -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.0.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<!-- Eureka service registration -->
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<!-- Spring Cloud starter -->
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<!-- In-memory database for testing/demos -->
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
use #EnableResourceServer instead of #EnableOAuth2Resource
With Spring Boot 1.2 we had to use Spring Cloud Security for the #EnableOAuth2Resource annotation. While, with Spring Boot 1.3 the Spring Cloud dependency can be removed and the annotation replaced with #EnableResourceServer annotation from Spring Security OAuth2.
For more details: https://spring.io/blog/2015/11/30/migrating-oauth2-apps-from-spring-boot-1-2-to-1-3#resource-server

Resources