AGonzalez
AGonzalez

Reputation: 133

Null Pointer Exception on CEP event

I'm sending a REST post request to Proton CEP from Context Broker (both in localhost) but when it receives the event can not read the xml. This is the catalina log:

may 20, 2015 9:38:52 AM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
INFORMACIÓN: started event message body reader
may 20, 2015 9:38:52 AM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
INFORMACIÓN: Event: TripContextUpdate
may 20, 2015 9:38:52 AM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
GRAVE: Could not parse XML NGSI event java.lang.NullPointerException, reason: null
 last attribute name: null last value: null
may 20, 2015 9:38:52 AM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
INFORMACIÓN: finished event message body reader
may 20, 2015 9:38:52 AM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent
INFORMACIÓN: starting submitNewEvent
may 20, 2015 9:38:52 AM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent
GRAVE: Could not send event, reason: java.lang.NullPointerException, message: null

When I send it a REST post in JSON format the response is:

may 20, 2015 10:23:57 AM com.ibm.hrl.proton.webapp.providers.EventJSONMessageReader readFrom
INFORMACIÓN: started event message body reader
may 20, 2015 10:23:57 AM com.ibm.hrl.proton.webapp.providers.EventJSONMessageReader readFrom
GRAVE: Could not parse json event org.apache.wink.json4j.JSONException: The key [Name] was not in the map, reason: The key [Name] was not in the map

Upvotes: 1

Views: 455

Answers (1)

duxan
duxan

Reputation: 124

I hope that you have resolved this issue, but since I had similar problems, I'll write down my case:

Second error means that either you are not sending a payload with POST or you are not including a defined event Name. From the docs for JSON payload it should be something like

{"Name":"TrafficReport", "volume":"1000"}

For me however, this didn't work, and I got error similar to yours for NGSI XML Could not parse json event java.lang.NullPointerException, reason: null.

Than I started debugging the running instance to which I was POSTing: GET: localhost:8080/ProtonOnWebServerAdmin/resources/instances/ProtonOnWebServer GET: localhost:8080/ProtonOnWebServerAdmin/resources/definitions

... and it turned out I have exported an app from Authoring Tool that had spaces and dots in the name, so name and URL didn't match: [{name: "/opt/repositories/tomcat10/ReactiFI v0.1.json", url: "/ProtonOnWebServerAdmin/resources/definitions/ReactiFI v0"}]

It seems definition was there and engine started with it, but no mappings existed for parser to work on.

I recommend no dots, spaces or special chars in definition names :).

Hope it helps!

Upvotes: 2

Related Questions