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.
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?
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
You might want to double-check your Blueprint JSON document. I've seen cases where hidden characters can cause problems with JSON validation.
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.
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