Cannot locate webjars with SpringBoot application running on WebSphere - java

I have been trying to host Spring Boot application on WebSphere server.
Versions :
SpringBoot 2.1.6.RELEASE
WebSphere Liberty 19.0.0.6 with JavaEE 8
webjars-locator 0.36
The app was successfuly deployed on standalone Tomcat 9.0.22 and webjars could be resolved there. However for WebSphere I receive an error when trying to access webjars from html page :
2019-08-05 10:43:11.839 DEBUG 1 --- [ecutor-thread-6] o.s.web.servlet.DispatcherServlet : GET "/appcontext/webjars/jquery/jquery.min.js", parameters={}
2019-08-05 10:43:11.845 DEBUG 1 --- [ecutor-thread-6] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/webjars/"]
2019-08-05 10:43:11.849 DEBUG 1 --- [ecutor-thread-6] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found
2019-08-05 10:43:11.849 DEBUG 1 --- [ecutor-thread-6] o.s.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND
And the webjars pattern was successfuly mapped by Spring :
2019-08-05 10:43:09.039 DEBUG 1 --- [ecutor-thread-6] o.s.w.s.handler.SimpleUrlHandlerMapping : Patterns [/webjars/**, /**] in 'resourceHandlerMapping'

The solution for this is to add classloading entry, with useJarUrls attribute set to true, to WebSphere server.xml file :
<server description="myServer">
<featureManager>
<feature>servlet-3.0</feature>
</featureManager>
<classloading useJarUrls="true"/> <!-- this line was added -->
<httpEndpoint httpPort="9080" httpsPort="9443" host="*" id="defaultHttpEndpoint"/>
</server>
This IBM support issue was particulary helpful in solving this problem.

Related

Tomcat failing to initialize multiple spring boot applications

Use case: We are trying to host dev and test environment of our spring boot application on an aws instance. Config used is Ubuntu 20.04, tomcat 9.0.7 and open jdk 11.
We have configured profiles for specific environments and properties files for each profile (viz. Dev, Test, Prod).
Virtual hosts have been added to tomcats server.xml file as below.
<Host name="devbty.transp.in" appBase="webappbackend" unpackWARs="true" autoDeploy="true">
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="dev_bty_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Host name="testbty.transp.in" appBase="webappbackendtest" unpackWARs="true" autoDeploy="true">
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="test_bty_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
Appbase directories are created in /opt/tomcat/ directory. After deployment tomcat initializes only one(dev) app and the second one(test) is extracted from the WAR and present inside the appbase directory but not initialized. After hitting the respective URL's the output is as below.
Dev
Test
Dev is accessible whereas test is not.
The logs too show similar story. Here's a snippet from the catalina.out.
:: Spring Boot :: (v2.7.6)
2023-02-17 07:39:59.644 INFO 19257 --- [ main] in.bilty.Application : Starting Application using Java 11.0.17 on ip-20-0-2-81 with PID 19257 (/opt/tomcat/webappbackend/ROOT/WEB-INF/classes started by root in /)
2023-02-17 07:39:59.656 INFO 19257 --- [ main] in.bilty.Application : The following 1 profile is active: "Dev"
2023-02-17 07:40:01.860 INFO 19257 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-02-17 07:40:02.065 INFO 19257 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 188 ms. Found 14 JPA repository interfaces.
17-Feb-2023 07:40:02.929 INFO [main] org.apache.catalina.core.ApplicationContext.log Initializing Spring embedded WebApplicationContext
2023-02-17 07:40:02.929 INFO 19257 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initi
It however finds 2 applications on the classpath
17-Feb-2023 07:39:58.354 INFO [main] org.apache.catalina.core.ApplicationContext.log 2 Spring WebApplicationInitializers detected on classpath
It says that the app is deployed which is correct as the WAR file is extracted and content is present in the appbase directory.
17-Feb-2023 07:40:12.931 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/opt/tomcat/webappbackendtest/ROOT.war]
17-Feb-2023 07:40:15.800 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
17-Feb-2023 07:40:15.812 INFO [main] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath
17-Feb-2023 07:40:15.852 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/opt/tomcat/webappbackendtest/ROOT.war] has finished in [2,921] ms
Not able to debug why only one app is deployed and not the other and no specific error message present in the logs. What can be missing?

Spring Boot 2.1.18 doesn't map actuator endpoints, no endpoints logged as mapped

I'm migrating Spring Boot 1.4.1 -> 2.1.18
It seems to be working (this is a Kafka app, the logs look good).
But I cannot make the actuator serve any endpoints no matter what.
It always looks like this:
http://127.0.0.1:8081/health or http://127.0.0.1:8081/actuator/health or http://127.0.0.1:8081/actuator/info or http://127.0.0.1:8081/info or whatever it's always the response:
{"error":"invalid token","message":"Failed to obtain token from request. 'Authorization' header field must be set.","path":"/health","status":401,"timestamp":"2022-08-23T01:45:07.124Z"}
In the logs it looks like this (the endpoint I try to invoke changes of course, but the logs show the same behavior):
2022-08-22T17:03:12.313Z DEBUG --- [http-nio-8081-exec-6] o.a.c.h.Http11InputBuffer : Received [GET /health HTTP/1.1
Host: 100.97.249.239:8081
User-Agent: kube-probe/1.19
Accept-Encoding: gzip
Connection: close
]
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.a.c.a.AuthenticatorBase : Security checking request GET /health
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.a.c.r.RealmBase : No applicable constraints defined
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.a.c.a.AuthenticatorBase : Not subject to any constraint
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.s.s.w.FilterChainProxy : /health at position 1 of 14 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.s.s.w.FilterChainProxy : /health at position 2 of 14 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.s.s.w.FilterChainProxy : /health at position 3 of 14 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.s.s.w.FilterChainProxy : /health at position 4 of 14 in additional filter chain; firing Filter: 'AuthExceptionHandlerFilter'
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.s.s.w.FilterChainProxy : /health at position 5 of 14 in additional filter chain; firing Filter: 'KeycloakPreAuthActionsFilter'
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.s.s.w.h.w.HstsHeaderWriter : Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher#62a657b0
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.a.c.h.Http11Processor : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper#38ddeb43:org.apache.tomcat.util.net.NioChannel#2efea784:java.nio.channels.SocketChannel[connected local=/100.97.249.239:8081 remote=/172.16.23.76:39510]], Status in: [OPEN_READ], State out: [CLOSED]
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.a.t.u.t.LimitLatch : Counting down[http-nio-8081-exec-6] latch=8
2022-08-22T17:03:12.314Z DEBUG --- [http-nio-8081-exec-6] o.a.t.u.n.NioEndpoint : Calling [org.apache.tomcat.util.net.NioEndpoint#2ceceb98].closeSocket([org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper#38ddeb43:org.apache.tomcat.util.net.NioChannel#2efea784:java.nio.channels.SocketChannel[connected local=/100.97.249.239:8081 remote=/172.16.23.76:39510]])
2022-08-22T17:03:12.403Z DEBUG --- [http-nio-8080-ClientPoller] o.a.t.u.n.NioEndpoint : timeout completed: keys processed=0; now=1661187792403; nextExpiration=1661187792402; keyCount=0; hasEvents=false; eval=false
2022-08-22T17:03:12.595Z DEBUG --- [http-nio-8081-exec-7] o.a.c.h.Http11InputBuffer : Before fill(): [true], parsingRequestLine: [true], parsingRequestLinePhase: [0], parsingRequestLineStart: [0], byteBuffer.position() [0]
2022-08-22T17:03:12.595Z DEBUG --- [http-nio-8081-exec-7] o.a.t.u.n.SocketWrapperBase : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper#212bc591:org.apache.tomcat.util.net.NioChannel#3d2834f8:java.nio.channels.SocketChannel[connected local=/100.97.249.239:8081 remote=/100.98.123.19:49114]], Read from buffer: [0]
2022-08-22T17:03:12.595Z DEBUG --- [http-nio-8081-exec-7] o.a.t.u.n.NioEndpoint : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper#212bc591:org.apache.tomcat.util.net.NioChannel#3d2834f8:java.nio.channels.SocketChannel[connected local=/100.97.249.239:8081 remote=/100.98.123.19:49114]], Read direct from socket: [293]
I even don't have the default endpoints like health or info working.
I tried different configs and basically all approaches I found on the Internet.
I also see that my configs are read by Spring Boot in the logs.
From these logs I think it's not a security problem, and HTTP 401 is a Spring Boot thing to avoid showing HTTP 404 to an unauthorized user.
But I don't see any lines showing mapped word from WebMvcEndpointHandlerMapping unlike in the logs examples of which I found.
I really suspect that no endpoint mappings really happening. I found these lines in the logs:
Did not match:
- #ConditionalOnEnabledResourceChain did not find class org.webjars.WebJarAssetLocator (OnEnabledResourceChainCondition)
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#beanNameViewResolver:
Did not match:
- #ConditionalOnMissingBean (types: org.springframework.web.servlet.view.BeanNameViewResolver; SearchStrategy: all) found beans of type 'org.springframework.web.servlet.view.BeanNameViewResolver' beanNameViewResolver (OnBeanCondition)
WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#localeResolver:
Did not match:
- #ConditionalOnProperty (spring.mvc.locale) did not find property 'locale' (OnPropertyCondition)
...
Tomcat started on port(s): 8080 (http) with context path ''
...
Exposing 16 endpoint(s) beneath base path '/actuator'
### NOTHING ABOUT WHAT ENDPOINTS
...
o.s.w.s.m.m.a.RequestMappingHandlerMapping : 1 mappings in 'requestMappingHandlerMapping'
...
Tomcat started on port(s): 8081 (http) with context path ''
Where could I look at?
What else can I try?
Pretty desperate at this point...
My application.yaml:
management:
server:
port: 8081
security:
enabled: false
endpoint:
health:
enabled: true
prometheus:
enabled: true
metrics:
enabled: true
endpoints:
web:
exposure:
include: "*"
metrics:
export:
prometheus:
enabled: true
my pom.xml has
<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>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<scope>runtime</scope>
</dependency>
401 actually meant the permission problem, and I couldn't get rid of it for a while, but after getting rid of the legacy libraries I was able to expose the endpoint with this:
public class CustomSecurityConfig extends WebSecurityConfigurerAdapter {
#Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll()
.antMatchers("/**").hasRole("USER")
.and()
.httpBasic();
}
This is probably my own problem due to the dependency hell I ended up, but I hope it'll help someone sometime.

Spring Boot 2.4.5 and Java 11 of module system question

In my example above I had spring.boot.starter.web on the classpath and the app failed to start. If I add org.apache.tomcat.embed.core then the application starts successfully.
When I configured module-info.java this way
requires spring.boot;
requires spring.boot.autoconfigure;
requires spring.web;
requires spring.boot.starter.web;
2021-05-20 10:56:09.501 INFO 17112 --- [ main] com.example.police.PoliceApplication : Starting PoliceApplication using Java 11 on zhaozhiguang-pc with PID 17112 (D:\item\police\target\classes started by zhaozhiguang in D:\item\police)
2021-05-20 10:56:09.501 INFO 17112 --- [ main] com.example.police.PoliceApplication : No active profile set, falling back to default profiles: default
2021-05-20 10:56:10.565 INFO 17112 --- [ main] com.example.police.PoliceApplication : Started PoliceApplication in 1.435 seconds (JVM running for 3.153)
Process finished with exit code 0
My guess is that Tomcat didn't boot
or
requires spring.boot;
requires spring.boot.autoconfigure;
requires spring.web;
requires org.apache.tomcat.embed.core;
This one worked
2021-05-20 10:57:48.097 INFO 13740 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-05-20 10:57:48.334 INFO 13740 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2021-05-20 10:57:48.381 INFO 13740 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-05-20 10:57:48.396 INFO 13740 --- [ main] com.example.police.PoliceApplication : Started PoliceApplication in 2.001 seconds (JVM running for 3.202)
2021-05-20 10:57:48.846 INFO 13740 --- [)-192.168.1.107] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-05-20 10:57:48.846 INFO 13740 --- [)-192.168.1.107] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2021-05-20 10:57:48.847 INFO 13740 --- [)-192.168.1.107] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
why?
spring.boot.starter.web depend on org.apache.tomcat.embed.core ?
One of the main features of Spring Boot is auto-configuration, which means that it configures a feature if it's available.
However, with Java modules, "available" is not just determined by the jar being on the classpath, but also by access being granted with the requires statement.
Without the requires statement, Spring Boot's auto-configuration cannot see Tomcat, so it doesn't even attempt to configure it.
Result: Silently ignores that feature.

Property Source not located by Config Server (JDBC Backend) even after providing application name and URI in bootstrap.properties

I am setting up a Configuration manager using Spring cloud config, I'm having an issue where the Client is not picking up the property source (Hosted HTTPS Server URI) when I deploy the application to a Docker container on Azure, works when the same code is running on Localhost which picks the same URI, thoughts on how to proceed ?
I have provided all the required parameters including the app name and the SERVER URI along with the active profile (dev) and label (1.0) in the bootstrap.properties, I also tried disabling security by setting management.security.enabled to false thinking it is a Security issue, but nothing seems to locate the property source. (Worst case is the HTTPS server URI seems to be located when the client is running locally), It is only when the code is containerized using Docker and deployed to Azure, it is showing this behavior. Any help greatly appreciated !
P.S - Working on latest snapshots of SpringBoot 2.1.3 and latest snapshot of Spring Cloud starter 2.1.1, No problems with any of the dependencies I have added.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<org.apache.commons.version>3.5</org.apache.commons.version>
<java.version>1.8</java.version>
<lombok.version>1.16.12</lombok.version>
<apt.version>1.1.3</apt.version>
<querydsl.version>4.1.4</querydsl.version>
<log4j-api.version>2.6</log4j-api.version>
</properties>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
bootstrap.properties
spring.cloud.config.uri=example.org
spring.application.name=MyApp
spring.profiles.active=dev
spring.cloud.config.profile=dev
spring.cloud.config.label=1.0
application.properties
management.endpoints.web.exposure.include=*
Expected when running on Localhost
2019-04-03 14:48:42.499 INFO 50217 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : example.org
2019-04-03 14:48:43.961 INFO 50217 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=MyApp, profiles=[dev], label=1.0, version=null, state=null
2019-04-03 14:48:43.961 INFO 50217 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='MyApp-dev'}]}
2019-04-03 14:48:43.965 INFO 50217 --- [ main] c.s.c.backroom.claims.ClaimsApplication : The following profiles are active: dev
2019-04-03 14:48:44.985 INFO 50217 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-04-03 14:48:45.135 INFO 50217 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 138ms. Found 17 repository interfaces.
2019-04-03 14:48:45.929 INFO 50217 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=1f523ae6-9bf7-3733-ae13-ea87a67e1564
201
Actual Result when running on Docker container on Azure
2019-04-03T17:35:03.470926214Z 2019-04-03 17:35:03.470 INFO 8 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : example.org
2019-04-03T17:35:09.723760869Z 2019-04-03 17:35:09.723 WARN 8 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: Could not extract response: no suitable HttpMessageConverter found for response type [class org.springframework.cloud.config.environment.Environment] and content type [text/html;charset=ISO-8859-1]
2019-04-03T17:35:09.752928427Z 2019-04-03 17:35:09.752 INFO 8 --- [ main] c.s.c.backroom.claims.ClaimsApplication : The following profiles are active: dev
2019-04-03T17:35:19.974721803Z 2019-04-03 17:35:19.971 INFO 8 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.

Spring boot application actuator end points get registered and requests still fail

I have a Spring boot app with the following startup code. The Actuator end points get mapped and the beans get removed. I see the actuator end points registered and then the beans removed. Going by the SO thread, the messages are harmless. But when I try to reach any actuator end point, I am getting error. I am not sure what I should further look into to get actuators working. I am attaching all the log snippets that I was referring.
I have the project setup with maven:
Maven Spring Actuator section
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
Java startup code
#EnableAutoConfiguration(exclude = { MetricFilterAutoConfiguration.class, MetricRepositoryAutoConfiguration.class, MessageSourceAutoConfiguration.class })
#EnableConfigurationProperties({ MyAppProperties.class })
#SpringBootApplication
public class MyApp{
private static final Logger LOG = LoggerFactory.getLogger(MyApp.class);
public static void main(String[] args) throws UnknownHostException {
SpringApplication app = new SpringApplication(MyApp.class);
Environment env = app.run(args).getEnvironment();
LOG.info("\n----------------------------------------------------------\n\t" +
"Application '{}' is running! Access URLs:\n\t" +
"Local: \t\thttp://localhost:{}\n\t" +
"External: \thttp://{}:{}\n----------------------------------------------------------",
env.getProperty("spring.application.name"),
env.getProperty("server.port"),
InetAddress.getLocalHost().getHostAddress(),
env.getProperty("server.port"));
}
}
The actuator starts the endpoints as per the log in DEBUG mode:
2017-03-17 11:19:29.378 INFO 17855 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/info || /info.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-03-17 11:19:29.379 DEBUG 17855 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : 1 request handler methods found on class org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint: {public void org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException={[],methods=[GET],produces=[application/octet-stream]}}
2017-03-17 11:19:29.379 INFO 17855 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/heapdump || /heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto public void org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException
2017-03-17 11:19:29.380 DEBUG 17855 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : 1 request handler methods found on class org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter: {public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()={[],methods=[GET],produces=[application/json]}}
2017-03-17 11:19:29.380 INFO 17855 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-03-17 11:19:29.384 DEBUG 17855 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : 2 request handler methods found on class org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint: {public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)={[/{name:.*}],methods=[GET],produces=[application/json]}, public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()={[],methods=[GET],produces=[application/json]}}
2017-03-17 11:19:29.384 INFO 17855 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2017-03-17 11:19:29.384 INFO 17855 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-03-17 11:19:29.384 DEBUG 17855 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : 1 request handler methods found on class org.springframework.cloud.context.restart.RestartMvcEndpoint: {public java.lang.Object org.springframework.cloud.context.restart.RestartMvcEndpoint.invoke()={[],methods=[POST]}}
2017-03-17 11:19:29.384 INFO 17855 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/restart || /restart.json],methods=[POST]}" onto public java.lang.Object org.springframework.cloud.context.restart.RestartMvcEndpoint.invoke()
2017-03-17 11:19:29.386 INFO 17855 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2017-03-17 11:19:29.386 DEBUG 17855 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Finished creating instance of bean 'endpointHandlerMapping'
2017-03-17 11:19:29.386 DEBUG 17855 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : Autowiring by type from bean name 'org.springframework.boot.actuate.autoconfigure.EndpointWebMvcChildContextConfiguration$EndpointHandlerMappingConfiguration' to bean named 'mvcEndpoints'
Eventually I see in the logs that the beans are removed:
2017-03-17 11:19:29.415 DEBUG 17855 --- [ main] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'endpointHandlerMapping': no URL paths identified
2017-03-17 11:19:29.415 DEBUG 17855 --- [ main] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'mvcEndpoints': no URL paths identified
2017-03-17 11:19:29.415 DEBUG 17855 --- [ main] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'environmentMvcEndpoint': no URL paths identified
2017-03-17 11:19:29.415 DEBUG 17855 --- [ main] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'heapdumpMvcEndpoint': no URL paths identified
2017-03-17 11:19:29.415 DEBUG 17855 --- [ main] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'healthMvcEndpoint': no URL paths identified
2017-03-17 11:19:29.415 DEBUG 17855 --- [ main] o.s.w.s.h.BeanNameUrlHandlerMapping : Rejected bean name 'metricsMvcEndpoint': no URL paths identified
When I make a request to /info or /health to reach the info and health, I am directed to the whitelabel error page because there are no handlers found.
After debugging the dispatcher servlet I see that there are 7 handlers and I expected to find a mapping for the /info in BeanNameUrlHandlerMapping.
org.springframework.web.servlet.handler.SimpleUrlHandlerMapping
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping
org.springframework.web.servlet.handler.SimpleUrlHandlerMapping
org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport$EmptyHandlerMapping
org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport$EmptyHandlerMapping
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WelcomePageHandlerMapping
Since the very first Mapping in the list is SimpleUrlHandlerMapping, it immediately returns "no handler mapping" which takes me to error page. I tried checking if the order matters and peeked into the BeanNameUrlHandlerMapping to see if it returns a handler mapping and it did not return any. So I suspect the debug message which removed the beans earlier is a culprit that caused the issue.
Can someone advise if there is anything I need to look into particularly.
According to the getting started guide : Building a RESTful Web Service with Spring Boot Actuator you should use the spring-boot-starter-actuator starter :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
instead of the spring-boot-actuator dependency.
Note also that according to the Spring Boot reference :
Information returned by HealthIndicators is often somewhat sensitive in nature. For example, you probably don’t want to publish details of your database server to the world. For this reason, by default, only the health status is exposed over an unauthenticated HTTP connection. If you are happy for complete health information to always be exposed you can set endpoints.health.sensitive to false.
management.security.enabled=false
management.endpoints.web.exposure.include=*
I had the similar issue and setting the above properties resolved it.
Update: I had this problem for version 1.5.9 . With the latest version 2.0.2, it works without these properties. In fact "management.security.enabled" has been deprecated in 2.0.2.

Categories