json end point request to config server getting 404 when the json file is hosted at external location - spring.cloud.config.server.native.searchLocations
When the json files are not present in config server classpath but hosted in an external location by using spring.cloud.config.server.native.searchLocations property and activating native profile, the request for the json endpoint is getting 404.
Do we need to have the json files always with the config server classpath?
@kevincmanning
referencing https://github.com/spring-cloud/spring-cloud-config/commit/57bcd734d11007b250f4c4aa0b0332f709bd2d13 what i understand is the json file needs to be named as follows {name}-{profiles}.json or access a label defined in the json using the URI /{label}/{name}-{profiles}.json
DEBUG LOGs from config server,
Scenario when json file in classpath : file name test_classpath.json
2015-08-10 15:40:26.827 DEBUG 5972 --- [ XNIO-2 task-1] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/test_classpath.json] 2015-08-10 15:40:26.830 DEBUG 5972 --- [ XNIO-2 task-1] o.s.b.a.e.mvc.EndpointHandlerMapping : Looking up handler method for path /test_classpath.json 2015-08-10 15:40:26.831 DEBUG 5972 --- [ XNIO-2 task-1] o.s.b.a.e.mvc.EndpointHandlerMapping : Did not find handler method for [/test_classpath.json] 2015-08-10 15:40:26.832 DEBUG 5972 --- [ XNIO-2 task-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /test_classpath.json 2015-08-10 15:40:26.837 DEBUG 5972 --- [ XNIO-2 task-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/test_classpath.json] 2015-08-10 15:40:26.837 DEBUG 5972 --- [ XNIO-2 task-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Matching patterns for request [/test_classpath.json] are [/**] 2015-08-10 15:40:26.838 DEBUG 5972 --- [ XNIO-2 task-1] o.s.w.s.handler.SimpleUrlHandlerMapping : URI Template variables for request [/test_classpath.json] are {} 2015-08-10 15:40:26.840 DEBUG 5972 --- [ XNIO-2 task-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapping [/test_classpath.json] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@5b23c1f6]]] and 1 interceptor 2015-08-10 15:40:26.842 DEBUG 5972 --- [ XNIO-2 task-1] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/test_classpath.json] is: -1 2015-08-10 15:40:26.917 DEBUG 5972 --- [ XNIO-2 task-1] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling 2015-08-10 15:40:26.918 DEBUG 5972 --- [ XNIO-2 task-1] o.s.web.servlet.DispatcherServlet : Successfully completed request 2015-08-10 15:40:26.919 DEBUG 5972 --- [ XNIO-2 task-1] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'discoveryClientConfigServiceBootstrapConfiguration'
@deepzGitHub config server doesn't serve raw json from the classpath. It looks for spring boot config files (*.yml or *.properties).
@spencergibb Thanks for the info. I think I set over expectation on the json endpoint :smile: Closing this issue.
@deepzGitHub NP. The json and properties endpoints just format the data config server already knows about into those formats.
@deepzGitHub Sorry for the late response. Just now had time to check my email. The JSON endpoint was just another access point I added so that the existing property sources could be natively parsed by JavaScript consumers. Sorry if it set some bad expectations. Maybe I should have added better documentation to clarify.
@kevincmanning It's absolutely a great feature, which will solve many open issues which I had while starting with config-server. Really a good thought!!! On Aug 10, 2015 9:06 PM, "kevincmanning" [email protected] wrote:
@deepzGitHub https://github.com/deepzGitHub Sorry for the late response. Just now had time to check my email. The JSON endpoint was just another access point I added so that the existing property sources could be natively parsed by JavaScript consumers. Sorry if it set some bad expectations. Maybe I should have added better documentation to clarify.
— Reply to this email directly or view it on GitHub https://github.com/spring-cloud/spring-cloud-config/issues/208#issuecomment-129675733 .
@kevincmanning I have one more question In my below example, yml is having a list inside list (states and nextPossibleStates) but in json the inner list is getting converted to a Map
flow:
flowName: add
states:
- api: /api
nextPossibleStates:
- 1
- 2
- 3
- api: /api2
nextPossibleStates:
- 1
- 2
- 3
JSON end point response, each item in nextPossibleStates got converted to key value "0" : "1"
{
"flow":{
"states":[
{
"api":"/api",
"nextPossibleStates":{
"0":1,
"1":2,
"2":3
}
},
{
"api":"/api2",
"nextPossibleStates":{
"0":1,
"1":2,
"2":3
}
}
],
"flowName":"add"
}
}
Thoughts?
@kevincmanning do you see the above behavior as an issue?
@deepzGitHub please open a separate issue if you think there is a bug in how the json is rendered.
@deepzGitHub If that is a problem, I don't think it's with the rendering of the JSON, appears to be with the parsing of the yml, right? If the yml were parsed into a List, it would have returned an array. However, because it was parsed as a Map, Jackson (I think that's the underlying dependency) mapped it to an object instead.