Failed to query actuator with error: Key contexts is missing in the map #1501
-
I am getting the above error in my project after the contract is loaded even though I have the management endpoint enabled and the actuator. If I run the application and call the actuator mapping end point its working correctly. But when I run the contract tests alone the error comes and it does not show the endpoint that is in controller but not in contract. Is there any configuration I am missing any pointers will be helpful. Following is the part of log in the test run OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended 2024-12-27T11:24:26.734+05:30 INFO 7396 --- [demo] [o-auto-1-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet' Request to http://localhost:54985 at 2024-12-27 11:24:27.384 This is my project Actuator Response: {"contexts":{"demo":{"mappings":{"dispatcherServlets":{"dispatcherServlet":[{"predicate":"{ [/error], produces [text/html]}","handler":"org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)","details":{"handlerMethod":{"className":"org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController","name":"errorHtml","descriptor":"(Ljakarta/servlet/http/HttpServletRequest;Ljakarta/servlet/http/HttpServletResponse;)Lorg/springframework/web/servlet/ModelAndView;"},"requestMappingConditions":{"consumes":[],"headers":[],"methods":[],"params":[],"patterns":["/error"],"produces":[{"mediaType":"text/html","negated":false}]}}},{"predicate":"{GET [/items/check]}","handler":"com.example.demo.controller.ItemController#getItemsCheck()","details":{"handlerMethod":{"className":"com.example.demo.controller.ItemController","name":"getItemsCheck","descriptor":"()Ljava/util/List;"},"requestMappingConditions":{"consumes":[],"headers":[],"methods":["GET"],"params":[],"patterns":["/items/check"],"produces":[]}}},{"predicate":"{POST [/items]}","handler":"com.example.demo.controller.ItemController#addItem(NewItem)","details":{"handlerMethod":{"className":"com.example.demo.controller.ItemController","name":"addItem","descriptor":"(Lcom/example/demo/model/NewItem;)Lcom/example/demo/model/Item;"},"requestMappingConditions":{"consumes":[],"headers":[],"methods":["POST"],"params":[],"patterns":["/items"],"produces":[]}}},{"predicate":"{ [/error]}","handler":"org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest)","details":{"handlerMethod":{"className":"org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController","name":"error","descriptor":"(Ljakarta/servlet/http/HttpServletRequest;)Lorg/springframework/http/ResponseEntity;"},"requestMappingConditions":{"consumes":[],"headers":[],"methods":[],"params":[],"patterns":["/error"],"produces":[]}}},{"predicate":"{GET [/items]}","handler":"com.example.demo.controller.ItemController#getItems()","details":{"handlerMethod":{"className":"com.example.demo.controller.ItemController","name":"getItems","descriptor":"()Ljava/util/List;"},"requestMappingConditions":{"consumes":[],"headers":[],"methods":["GET"],"params":[],"patterns":["/items"],"produces":[]}}},{"predicate":"/webjars/","handler":"ResourceHttpRequestHandler [classpath [META-INF/resources/webjars/]]"},{"predicate":"/","handler":"ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]"}]},"servletFilters":[{"urlPatternMappings":["/"],"servletNameMappings":[],"name":"requestContextFilter","className":"org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter"},{"urlPatternMappings":["/"],"servletNameMappings":[],"name":"webMvcObservationFilter","className":"org.springframework.web.filter.ServerHttpObservationFilter"},{"urlPatternMappings":["/"],"servletNameMappings":[],"name":"Tomcat WebSocket (JSR356) Filter","className":"org.apache.tomcat.websocket.server.WsFilter"},{"urlPatternMappings":["/"],"servletNameMappings":[],"name":"characterEncodingFilter","className":"org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter"},{"urlPatternMappings":["/*"],"servletNameMappings":[],"name":"formContentFilter","className":"org.springframework.boot.web.servlet.filter.OrderedFormContentFilter"}],"servlets":[{"mappings":["/"],"name":"dispatcherServlet","className":"org.springframework.web.servlet.DispatcherServlet"}]}}}} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
hello @prateekkarmakar , thanks for the details. Looks like this may be similar to #1495 . We will try to use the setup that you have shared above and get back to you. |
Beta Was this translation helpful? Give feedback.
-
hello @prateekkarmakar , we had a look at your sample project that you have shared. Here is what we noticed.
Since you are using the port number obtained through Can you please either remove the |
Beta Was this translation helpful? Give feedback.
hello @prateekkarmakar , we had a look at your sample project that you have shared. Here is what we noticed.
ConractTest
class is annotated with@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
. So the port that you receive via@LocalServerPort
which populatesprivate int port
will be random.application.yaml
the server port is set to9000
and management server port is set to9001
.Since you are using the port number obtained through
@LocalServerPort
annotation to construct the actuator endpoint URL in"http://localhost:"+port+"/actuator/mappings"
, this URL may be invalid and that is why you are seeing the error.Can you please either remov…