Created 12-16-2016 02:30 PM
I am using chef recipes to set up Ambari, I post in this recipes a blueprint into Ambari Server.
When I do it locally it works fine, but when I apply the chef recipes on a real machine, I get an error 500 when posting the blueprints, like this:
[2016-12-16T15:21:43+01:00] ERROR: Server returned error 500 for http://myambariserver:8080/api/v1/blueprints/bpp
I don't think there is a problem with the blueprint since it is posted without problems locally, any idea when Ambari answers code 500?
The server is accessible via web and respond to GET requests, the agents can register in the server successfully.
Created 12-16-2016 02:41 PM
As you are getting "error 500" so definitely you will get a comlete stackTrace in the "/var/log/ambari-server/ambari-server.log" can you please share the complete stackTrace. That you receive as soon as you Post the blueprint?
Created 12-16-2016 02:51 PM
You are right, there is an error trace in the log, as follows:
16 Dec 2016 15:47:27,880 ERROR [ambari-client-thread-28] ContainerResponse:419 - The RuntimeException could not be mapped to a response, re-throwing to the HTTP container com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2 at com.google.gson.Gson.fromJson(Gson.java:806) at com.google.gson.Gson.fromJson(Gson.java:761) at org.apache.ambari.server.api.GsonJsonProvider.readFrom(GsonJsonProvider.java:60) at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:490) at com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$EntityInjectable.getValue(EntityParamDispatchProvider.java:123) at com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues(InjectableValuesProvider.java:86) at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.java:153) at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:203) at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)... at com.google.gson.Gson.fromJson(Gson.java:795) ... 87 more 16 Dec 2016 15:47:27,882 WARN [ambari-client-thread-28] ServletHandler:561 - Error Processing URI: /api/v1/blueprints/test - (com.google.gson.JsonSyntaxException) java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2 16 Dec 2016 15:47:27,882 WARN [ambari-client-thread-28] ServletHandler:561 - Error Processing URI: /api/v1/blueprints/test - (com.google.gson.JsonSyntaxException) java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2
I am not sure if there is a problem with the Json (I don't believe so) or with the URI. This time I was sending the blueprint using Postman to /api/v1/blueprints/test
Created 12-16-2016 05:53 PM
That's most likely a bad blueprint. Have you tried your blueprint in an online JSON validator like http://jsonlint.com/?
Can you attach your blueprint to this question so we can look at it?
Created 12-20-2016 10:19 PM
@Jose Luis Navarro Vicente, The URL you're POST-ing to looks fine. @Jonathan Hurley's reply is correct, this is almost certainly an error with your Blueprint.
You might want to double-check your Blueprint JSON document. I've seen cases where hidden characters can cause problems with JSON validation.
Created 01-24-2017 12:18 AM
I'm seeing the same problem with (the latest) Ambari 2.4.2. I've checked my JSON for parse errors on JSLint and it comes up clean. I've tried simply using the examples at https://cwiki.apache.org/confluence/display/AMBARI/Blueprints, which is referenced by the latest 2.4.2 documentation. I've also tried using the CloudBreak examples from here, which contain a slightly different structure - http://sequenceiq.com/cloudbreak-docs/latest/blueprints/. I've tried to use a freshly exported blueprint from an existing functional cluster that also fails with the same error.
Is there a definitive version specific JSON Schema that could be used to determine the appropriate structure? Is anyone else able to register a template in Ambari 2.4.2. If so I would love to see what it looks like.
Created 02-03-2017 08:44 PM
I've opened a bug for this.
https://issues.apache.org/jira/browse/AMBARI-19869
UPDATE:
Don't set header: Content-Type: application/json Don't wrap your blueprint json in quotes.
Created 08-29-2017 02:54 AM
This tool might help: JSON Formatter
Created 08-29-2017 01:32 PM
Did you happen to try the notes I mentioned from above? My problem was my POST even though I had valid JSON.
Don't set header: Content-Type: application/json
Don't wrap your blueprint json in quotes.
POST with Content-Type: text/plain
Created 08-03-2018 05:09 AM
POST with Content-Type: text/plain
Helped in my case
Thanks