Junit XML to json format in Jroovy with XmlSlurper - json

I am trying to write a bridge function to convert XML data to the Json format below are the data I have
the sample xml file is
<testsuites> <testsuite tests="4" failures="4" errors="0" name="AT">
<testcase name="#1 notificate › v1 › announcement › announcement.feature/#TEST CASE: Notification: Send an announcement: Send an announcement using the minimum requirements"/>
<testcase name="#2 notifiivate › v1 › announcement › announcement.feature/#TEST CASE: Notification: Send an ant"/>
<testcase name="#1 No tests found in features/tests/auth/auth.POST.js">
<failure/>
</testcase>
<testcase name="#2 versioninfo › versioninfo › versioninfo.feature/#TEST CASE: CDP ADMIN: Get version info: Get the version of the CDP service">
<failure>
name: AssertionError
message: Rejected promise returned by test
values:
</failure>
</testcase>
<testcase name="#3 projects › edit_entitlement › edit_entitlement.feature/#TEST CASE: CDP ADMIN: Edit Entitlement: Attempt to edit an entitlement_id to be a negative number">
<failure>
---
name: AssertionError
message: Rejected promise returned by test
values:
...
</failure>
</testcase>
</testsuite>
</testsuites>
I am trying to write a function in groovy to get the below json format
{
testsuites{
"testsuite": {
"tests": "4",
"failures": "4",
"errors": "0",
"name": "AT-cdpServer.Default",
"testcase": [
{
"name": "#1 notificate › v1 › announcement › Send an announcement: Send an announcement using the minimum requirements"
},
{
"name": "#2 notifiivate › v1 › announcement › announcement.feature/#TEST CASE: Notification: Send an ant"
},
{
"name": "#1 No tests found in features/tests/auth/auth.POST.js",
"failure": []
},
{
"name": "#2 versioninfo › versioninfo › versioninfo.feature/#TEST CASE: CDP ADMIN: Get version info: Get the version of the CDP service",
"failure": "---\n name: AssertionError\n message: Rejected promise returned by test\n values: {\"Rejected promise returned by test. Reason:\":\"Error {\\n message: 'no schema with key or ref \\\"/versioninfo.get.200\\\"',\\n}\"}\n at: Ajv.validate (node_modules/ajv/lib/ajv.js:95:19)\n ..."
},
{
"name": "#3 projects › edit_entitlement › edit_entitlement.feature/#TEST CASE: CDP ADMIN: Edit Entitlement: Attempt to edit an entitlement_id to be a negative number",
"failure": "---\n name: AssertionError\n message: Rejected promise returned by test\n values: {\"Rejected promise returned by test. Reason:\":\"TypeError {\\n message: 'Only absolute URLs are supported',\\n}\"}\n ..."
},
]
}
}}
}
Appreciate any inputs in the right direction , thank you
So far I have this, it reads all the data, but the structure is off
def toJsonBuilder(xml){
def xmlToJson = build(new XmlSlurper().parseText(xml))
new groovy.json.JsonBuilder(xmlToJson)
}
def build(node){
if (node instanceof String){
return // ignore strings...
}
def map = [(node.name()): node.collect]
if (!node.attributes().isEmpty()) {
map.put(node.name(),node.attributes().collectEntries{it})
}
if (!node.children().isEmpty() && !(node.children().getAt(0) instanceof String)) {
map.put(node.children().name, node.children().collect{build(it)}.findAll{it != null})
} else if (node.text() != ''){
map.put(node.name(), node.text())
}
map
}

Related

Design Automation fails with : failedInstructions

I am trying to run a Revit plugin on Design Automation. Workitem fails with failedInstructions error. In the logs I can find "Error details: The system cannot find the file specified." Does that refer to the Revit file? Or the AppBundle? The input file is from BIM 360, the workitem contains a link and the header to download the Revit file and it seems like there are no issues there. I have also debugged the plugin locally using DesignAutomationHandler and that seems to work fine. Not sure what's missing.
[05/20/2022 20:39:12] Job information:
"CommandLine":[
"\"$(engine.path)/revitcoreconsole.exe /i $(args[rvtFile].path) /al $(appbundles[Revit2ProtoExporter].path)\""
]
"Settings":{
"dasreportfaileduploadoptional": {
"value": "true",
"isEnvironmentVariable": true
}
}
"Id":"bc24e48e8f7548fe9262db12a7556055"
"ActivityId":"WDQIfAV8PqNa9XSKPmv6MDu3xAtLGfXI.Revit2ProtoExporterActivity+OV"
"Engine.Id":"Autodesk.Revit_2022!84"
"Apps": [
"App.Id":"WDQIfAV8PqNa9XSKPmv6MDu3xAtLGfXI.Revit2ProtoExporter!72"
]
"BoundArguments":{
"rvtFile": {
"localName": "rac_basic_sample_project.rvt",
"url": "https://developer.api.autodesk.com/Masked:kRW0jj8ZUtU7QNO0DXCukH2NDJ4=",
"headers": {
"authorization": "Masked:IlrS8QJ3oW3Igi6Oe34QAwULA1Q="
}
},
"params": {
"localName": "params.json",
"url": "data:application/json,{'ViewName': {3D}}"
},
"result": {
"localName": "result.avr",
"url": "https://staging-appliedvrabs-pa.sandbox.googleapis.com/Masked:kQfE75mPkbGJwltY96k4UwHYNNY=",
"headers": {
"authorization": "Masked:GbZcVdSF7CkXGH0+4kYm/FaeCao="
},
"verb": "put"
},
"onProgress": {
"ondemand": true,
"url": "https://wlnr5sjl3a.execute-api.us-east-1.amazonaws.com/Masked:UK/Z3b5X3xUWxXiH6C9r9i9UlRU=",
"headers": {
"Content-Type": "application/json",
"x-das-authorize": "awssigv4(us-east-1)",
"x-ads-token-data": "{\"access_token\":{\"client_id\":\"WDQIfAV8PqNa9XSKPmv6MDu3xAtLGfXI\"},\"scope\":\"code:all data:write data:read bucket:create bucket:delete\",\"expires_in\":3599,\"client_id\":\"WDQIfAV8PqNa9XSKPmv6MDu3xAtLGfXI\"}",
"x-ads-gateway-secret": "Masked:F6VCvje5cIP0zOGCxgARjmSopQI="
},
"verb": "put"
}
}
"Quotas":{
"limitProcessingTimeSec": 10800,
"limitTotalUncompressedAppsSizeInMB": 5000
}
[05/20/2022 20:39:13] Starting work item bc24e48e8f7548fe9262db12a7556055
[05/20/2022 20:39:13] Start download phase.
[05/20/2022 20:39:13] Start downloading input: verb - 'GET', url - 'https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/47f2a6e6-4349-4a9e-b066-14019b2d95ff.rvt'
[05/20/2022 20:39:13] Embedded resource [{'ViewName': {3D}}] is saved as file: T:\Aces\Jobs\bc24e48e8f7548fe9262db12a7556055\params.json.
[05/20/2022 20:39:14] End downloading file. Source=https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/47f2a6e6-4349-4a9e-b066-14019b2d95ff.rvt,LocalFile=T:\Aces\Jobs\bc24e48e8f7548fe9262db12a7556055\rac_basic_sample_project.rvt,BytesDownloaded=18739200,Duration=1107ms
[05/20/2022 20:39:14] End download phase successfully.
[05/20/2022 20:39:16] Start preparing script and command line parameters.
[05/20/2022 20:39:16] Command line: []
[05/20/2022 20:39:16] Identified standalone application at T:\Aces\AcesRoot\22.0\coreEngine\Exe/revitcoreconsole.exe /i T:\Aces\Jobs\bc24e48e8f7548fe9262db12a7556055\rac_basic_sample_project.rvt /al T:\Aces\Applications\53f4ce6d27cb3f9b8d6727a1bc6e1b36.WDQIfAV8PqNa9XSKPmv6MDu3xAtLGfXI.Revit2ProtoExporter[72].package.
[05/20/2022 20:39:16] End preparing script and command line parameters.
[05/20/2022 20:39:16] Start script phase.
[05/20/2022 20:39:16] Start application 53f4ce6d27cb3f9b8d6727a1bc6e1b36.WDQIfAV8PqNa9XSKPmv6MDu3xAtLGfXI.Revit2ProtoExporter[72].package standard output dump.
[05/20/2022 20:39:16] command line:'"T:\Aces\AcesRoot\22.0\coreEngine\Exe/revitcoreconsole.exe /i T:\Aces\Jobs\bc24e48e8f7548fe9262db12a7556055\rac_basic_sample_project.rvt /al T:\Aces\Applications\53f4ce6d27cb3f9b8d6727a1bc6e1b36.WDQIfAV8PqNa9XSKPmv6MDu3xAtLGfXI.Revit2ProtoExporter[72].package" /isolate HKEY_CURRENT_USER\SOFTWARE\AppDataLow\Software\Autodesk\CoreUser\WorkItem_bc24e48e8f7548fe9262db12a7556055 T:\Aces\Jobs\bc24e48e8f7548fe9262db12a7556055\userdata'
[05/20/2022 20:39:16] CreateProcess fails [ErrorCode:2]
[05/20/2022 20:39:16] Error details: The system cannot find the file specified.
[05/20/2022 20:39:17] End application 53f4ce6d27cb3f9b8d6727a1bc6e1b36.WDQIfAV8PqNa9XSKPmv6MDu3xAtLGfXI.Revit2ProtoExporter[72].package standard output dump.
[05/20/2022 20:39:17] Error: Application 53f4ce6d27cb3f9b8d6727a1bc6e1b36.WDQIfAV8PqNa9XSKPmv6MDu3xAtLGfXI.Revit2ProtoExporter[72].package exits with code 2 which indicates an error.
[05/20/2022 20:39:17] End script phase.
[05/20/2022 20:39:17] Error: An unexpected error happened during phase CoreEngineExecution of job.
[05/20/2022 20:39:17] Job finished with result FailedExecution
[05/20/2022 20:39:17] Job Status:
{
"status": "failedInstructions",
"reportUrl": "https://dasprod-store.s3.amazonaws.com/workItem/WDQIfAV8PqNa9XSKPmv6MDu3xAtLGfXI/bc24e48e8f7548fe9262db12a7556055/report.txt?X-Amz-Expires=48600&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEDUaCXVzLWVhc3QtMSJHMEUCIQD6%2F06ilWih8Y%2FlExEFSRdV29%2BkhzC9dnUiSRgrowI%2F3AIgWW0dFM7mesUZ9r%2Fay0jRdYM5WS5WLaKE70dUdIJ6pdIqmwIIHRADGgwyMjA0NzMxNTIzMTAiDBvJL%2Faj9DnxZRlQoir4AawLQ9ux77C8%2FCXfmKxVn52VplNguYCnlxSoCU6fZcEcXIJzLByNiYn%2Fh4cNZ7Pi%2B5yD%2FBQz9E%2FK7YxddYqRWn6%2FTJlT79dVYoCvigOP4sYClYT7Khqxpnlzdq%2FFKSPrhwVCeBJNBLLdgFXJywVasJqb95nXz%2FEb4zl1459EB7f1L%2BmMpiCi%2BpQgtXmybqC6YIoZAzRlQFGqOsdi%2FrpucSRTFz85uzXKe95ycI3u6AkjB9qIeFus%2FoGuSHCWmIYCLuFxv6N4paqXsf%2FGL4k0eaxlT8vvqc4BOfVSoKkSDP3asDWUTPBctRHllVn4JVYESTux805TB4i8MNDqn5QGOpoBFkJEETYYcw40DufOBaHwnASy1zn6lcSt3K3yDjzYZCJFrrO6sT0YT3Q0poH1W4Pn74YAHb0MFay8WspSghCNcUc5JrL1j1aqDchne8nCLu2tRJQXwIQD6ddJ7AXMnNVfrd12y%2FZlj1gjJxjKXsEK6syt2xg5LDmmMe%2F1iu40qxVq%2Bv3%2BjmsR05Fz52T3oIyuWYNjqojdudPwFA%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIATGVJZKM3ITCDHE4L/20220520/us-east-1/s3/aws4_request&X-Amz-Date=20220520T203912Z&X-Amz-SignedHeaders=host&X-Amz-Signature=9b56fe0c0ac8fd968acdbb72ba073ab1041f3946e929d23d88ad885149bdbf66",
"stats": {
"timeQueued": "2022-05-20T20:39:12.695924Z",
"timeDownloadStarted": "2022-05-20T20:39:12.957438Z",
"timeInstructionsStarted": "2022-05-20T20:39:16.3503525Z",
"timeInstructionsEnded": "2022-05-20T20:39:17.5424815Z",
"bytesDownloaded": 18739218
},
"id": "bc24e48e8f7548fe9262db12a7556055"
}
Here is the activity definition:
url = '{0}/activities/{1}/versions'.format(self._das_api_root,
self.get_activity_name())
headers = self._get_request_headers()
data = {}
data['commandLine'] = [
'"$(engine.path)/revitcoreconsole.exe '
'/i $(args[rvtFile].path) '
'/al $(appbundles[' + self.get_app_bundle_name() + '].path)"'
]
data['parameters'] = {}
data['parameters']['rvtFile'] = {}
data['parameters']['rvtFile']['zip'] = False
data['parameters']['rvtFile']['ondemand'] = False
data['parameters']['rvtFile']['verb'] = 'get'
data['parameters']['rvtFile']['description'] = 'Input'
data['parameters']['rvtFile']['required'] = True
data['parameters']['params'] = {}
data['parameters']['params']['localName'] = 'params.json'
data['parameters']['params']['verb'] = 'get'
data['parameters']['params']['required'] = True
data['parameters']['result'] = {}
data['parameters']['result']['zip'] = False
data['parameters']['result']['ondemand'] = False
data['parameters']['result']['verb'] = 'put'
data['parameters']['result']['description'] = 'Result'
data['parameters']['result']['required'] = True
data['parameters']['result']['localName'] = 'result.avr'
data['engine'] = 'Autodesk.Revit+2022'
data['appbundles'] = [self.get_app_bundle()]
data['description'] = 'Export Geometry'
# Attempt to update the Activity.
response = requests.post(url, json=data, headers=headers)
And here is the workitem definition:
url = '{0}/workitems'.format(self._das_api_root)
headers = self._get_request_headers()
data = {}
data['activityId'] = self._activity_id
data['arguments'] = {}
data['arguments']['rvtFile'] = {}
data['arguments']['rvtFile']['url'] = download_url
data['arguments']['rvtFile']['localName'] = revit_file_name
data['arguments']['rvtFile']['headers'] = download_header
data['arguments']['params'] = {}
data['arguments']['params']['url'] = "data:application/json,{{'ViewName': {0}}}".format(view_name)
data['arguments']['result'] = {}
data['arguments']['result']['verb'] = 'put'
data['arguments']['result']['url'] = upload_url
data['arguments']['result']['headers'] = upload_header
response = self._http_client.request(url, 'POST', json.dumps(data), headers = headers)
By having a closer look at the report above, the problem is at the command line.
"T:\Aces\AcesRoot\22.0\coreEngine\Exe/revitcoreconsole.exe /i T:\Aces\Jobs\bc24e48e8f7548fe9262db12a7556055\rac_basic_sample_project.rvt /al T:\Aces\Applications\53f4ce6d27cb3f9b8d6727a1bc6e1b36.WDQIfAV8PqNa9XSKPmv6MDu3xAtLGfXI.Revit2ProtoExporter[72].package" cannot be identified as an executable, so it complained "Error details: The system cannot find the file specified."
The correct way to define command line, e.g.
"commandLine": [ "$(engine.path)\\\\revitcoreconsole.exe /i \"$(args[rvtFile].path)\" /al \"$(appbundles[RVTIOExportTestPackage2019].path)\"" ]
See the quotes around $(args[rvtFile].path)and $(appbundles[RVTIOExportTestPackage2019].path)

Ansible access JSON object with dynamic key and special character

I have an Ansible script that performs API call and stores the JSON result in a variable. The JSON result from the API call is in the following format:
{
"result": {
"Object::18": {
"message": "object message"
},
message: "hello"
}
}
In this case the key Object::18 is dynamically generated from the ID given as argument in the Ansible script:
$ ansible-playbook test.yaml --extra-var='id=18'
How do I get the JSON value for key result.Object::{{id}}.message in this case? Please find below a sample Ansible script:
- name: Get API object
hosts: localhost
vars:
object_id: '{{ id }}'
# Sample JSON result returned by the API call
# Object::<id> (the key "Object::<id>" depends on the ID given as argument for the ansible script)
# For example, if run using --extra-vars "id=18", it will be Object::18. If id=19 then Object::19
sample_json_result:
{
"result": {
"Object::18": {
"message": "object message"
},
message: "hello"
}
}
tasks:
- debug:
# How to get result.Object::<id>.message???
# For example 1: --extra-vars "id=18", result.Object::18.message
# Example 2: --extra-vars "id=19", result.Object::19.message
msg: '{{ sample_json_result.result }}'
# The following does NOT work
#msg: '{{ sample_json_result.result.Object\:\:{{id}}.message }}'
Thank you and please let me know if you have any further questions.
EDIT:
For those who are interested, solution as suggested by Zeitounator
- name: Get API object
hosts: localhost
vars:
object_id: '{{ id }}'
# Sample JSON result returned by the API call
# Object::<id> (the key "Object::<id>" depends on the ID given as argument for the ansible script)
# For example, if run using --extra-vars "id=18", it will be Object::18. If id=19 then Object::19
sample_json_result:
{
"result": {
"Object::18": {
"message": "object message"
},
message: "hello"
}
}
tasks:
- debug:
msg: '{{ sample_json_result.result["Object::" ~ id].message }}'

Google Stackdriver Error Reporting not picking up errors

Logs with severity “ERROR” is not identified by Error and Reporting tool. Application logs are being directed at Google Stackdriver Logging using fluentd agent and some of these are third party java components.
{
insertId: "14sf3lvg3ccncgh"
jsonPayload: {
class: "o.a.w.MarkupContainer"
message: "Unable to find component with id 'search2' in [Form [Component id = form]]
Expected: 'form:search2'.
Found with similar names: 'form:search'
at org.apache.wicket.markup.MarkupStream.throwMarkupException(MarkupStream.java:526) ~[wicket-core-6.22.0.jar:6.22.0]
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1438) ~[wicket-core-6.22.0.jar:6.22.0]
at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1557) ~[wicket-core-6.22.0.jar:6.22.0]
at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1532) ~[wicket-core-6.22.0.jar:6.22.0]
at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1487) ~[wicket-core-6.22.0.jar:6.22.0]"
milsec: "576"
reportLocation: {…}
serviceContext: {…}
tag: "test.gui"
thread: "[ajp-apr-8009-exec-5]"
}
labels: {…}
logName: "projects/myservice/logs/test.gui"
receiveTimestamp: "2017-08-29T15:20:16.847782870Z"
resource: {…}
severity: "ERROR"
timestamp: "2017-08-29T15:20:11Z"
}
Using the following configuration allows for my application logs to be forwarded correctly to Googles Stackdriver logging and all entries are correctly identified.
<source>
#type tail
path /var/log/test/test_gui/test_gui.log
pos_file /var/lib/google-fluentd/pos/test_gui-multiline.pos
read_from_head true
tag test.gui
format multiline
time_format %Y-%m-%d %H:%M:%S
format_firstline /\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2},\d{1,3}\s(?<severity>\S*)/
format1 /^(?<time>\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}),(?<milsec>\d{1,3})\s(?<severity>\S*)\s(?<class>\S*)\s(?<thread>\[\S*\])\s(?<message>.*)/
</source>
However for severity ERROR, Error Reporting never noticed these entries.
The output was identified as textPayLoad, I used the following filter, which ensured output was jsonPayload
<filter test.gui>
#type record_transformer
<record>
serviceContext {"service": "test.gui", "version": "1"}
reportLocation {"filePath": "test_gui.log", "lineNumber": "unknown", "functionName": "unknown"}
tag ${tag}
</record>
</filter>
Still the error jsonPayload is being ignored.
If I replace the message using the filter, then suddenly Error Reporting is working
<filter test.gui>
#type record_transformer
<record>
serviceContext {"service": "test.gui", "version": "1"}
reportLocation {"filePath": "test_gui.log", "lineNumber": "unknown",
"functionName": "unknown"}
message "java.lang.TestError: msg
at com.example.TestClass.test (TestClass.java:51)
at com.example.AnotherClass (AnotherClass.java:25)"
tag ${tag}
</record>
</filter>
How can I force Error Reporting to pick these error entries as my next step would be to implement some form of alerting.
Third parties did not produce correct Java Stack trace. I needed the reportLocation, but this needs to be in context.
I changed the following line:
reportLocation {"filePath": "test_gui.log", "lineNumber": "unknown", "functionName": "unknown"}
to
context { "reportLocation" : {"filePath": "test_gui.log", "lineNumber": 1, "functionName": "unknown"} }
which ensured that the logs are now picked up by Stackdriver Error Reporting.
This is the final version of my filter:
<filter test.gui>
#type record_transformer
<record>
serviceContext {"service": "test.gui", "version": "1"}
context { "reportLocation" : {"filePath": "test_gui.log", "lineNumber": 1, "functionName": "unknown"} }
tag ${tag}
</record>
</filter>

Can't set Bucket Lifecycle Configuration

Doing this (aws-sdk ruby gem):
s3_client.put_bucket_lifecycle_configuration({
bucket: bucket,
lifecycle_configuration: {
rules: [
{
id: "clean-temporary",
status: "Disabled", # required, accepts Enabled, Disabled
prefix: "temporary",
filter: {
prefix: "temporary",
},
expiration: {
days: 1,
},
},
],
},
})
I got an error: Aws::S3::Errors::BadRequest: [!]
According to Release Notes, my version (11) support it:
S3 bucket lifecycle API has been added. Note that currently it only supports object expiration.
What am I doing wrong?
UPD:
Tried the s3cmd, didn't help:
⇒ s3cmd -c s3cfg setlifecycle lifecycle_configuration.xml s3://my-new-bucket
ERROR: S3 error: 405 (MethodNotAllowed)
⇒ cat lifecycle_configuration.xml
<?xml version="1.0" encoding="UTF-8"?>
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>test</ID><Status>Enabled</Status><Expiration><Days>1</Days></Expiration><Prefix></Prefix></Rule></LifecycleConfiguration>
Found a workaround:
s3cmd -c s3cfg setlifecycle lifecycle_configuration.xml s3://my-new-bucket --signature-v2
probably aws-sdk gem is not compatible with this feature.

Orion / Proton subscription: java.lang.NullPointerException parsing an event from Orion

My Proton instance fails with a java.lang.NullPointerException whenever an event is sent by Orion
this is the Proton log:
proton_1 | 01-Jul-2016 09:46:03.117 INFO [http-nio-8080-exec-1] com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader.readFrom started event message body reader
proton_1 | 01-Jul-2016 09:46:03.125 INFO [http-nio-8080-exec-1] com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader.readFrom Event: ApeContextUpdate
proton_1 | 01-Jul-2016 09:46:03.126 SEVERE [http-nio-8080-exec-1] com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader.readFrom Could not parse XML NGSI event java.lang.NullPointerException, reason: null
proton_1 | last attribute name: null last value: null
proton_1 | 01-Jul-2016 09:46:03.130 INFO [http-nio-8080-exec-1] com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader.readFrom finished event message body reader
proton_1 | 01-Jul-2016 09:46:03.131 INFO [http-nio-8080-exec-1] com.ibm.hrl.proton.webapp.resources.EventResource.submitNewEvent starting submitNewEvent
proton_1 | 01-Jul-2016 09:46:03.132 SEVERE [http-nio-8080-exec-1] com.ibm.hrl.proton.webapp.resources.EventResource.submitNewEvent Could not send event, reason: java.lang.NullPointerException, message: null
I've read the Appendix of the User guide and double checked the event name and the attributes list.
This is an xml sent by orion:
POST /ProtonOnWebServer/rest/events HTTP/1.1
User-Agent: orion/0.28.0 libcurl/7.19.7
Host: localhost:8080
Accept: application/xml, application/json
Content-length: 772
Content-type: application/xml
<notifyContextRequest>
<subscriptionId>57762eb9982959644644f9ee</subscriptionId>
<originator>localhost</originator>
<contextResponseList>
<contextElementResponse>
<contextElement>
<entityId type="Ape" isPattern="false">
<id>u1</id>
</entityId>
<contextAttributeList>
<contextAttribute>
<name>carsharing</name>
<type>urn:x-ogc:def:trs:IDAS:1.0:ISO8601</type>
<contextValue>2016-07-01T11:01:06</contextValue>
</contextAttribute>
</contextAttributeList>
</contextElement>
<statusCode>
<code>200</code>
<reasonPhrase>OK</reasonPhrase>
</statusCode>
</contextElementResponse>
</contextResponseList>
</notifyContextRequest>
This is the definition of the Proton project (BTW this is the project copied from
the server filesystem because also the rest api fails with a
NullPointerException)
{
"epn": {
"events": [
{
"name": "ApeContextUpdate",
"createdDate": "Fri Jul 01 2016",
"attributes": [
{
"name": "entityId",
"type": "String",
"dimension": "0"
},
{
"name": "entityType",
"type": "String",
"dimension": "0"
},
{
"name": "carsharing",
"type": "Date",
"dimension": "0"
}
]
}
],
"epas": [],
"contexts": {
"temporal": [],
"segmentation": [],
"composite": []
},
"consumers": [],
"producers": [],
"name": "t0"
}
}
and this is my docker-compose file:
mongo:
image: mongo:2.6
command: --smallfiles --quiet
proton:
image: fiware/proactivetechnologyonline
ports:
- "8080:8080"
orion:
image: fiware/orion:0.28
links:
- mongo
- proton
command: -dbhost mongo --silent
ports:
- "1026:1026"
I'm using Orion 0.28 (the last one that supports XML notifications) and the latest Proton
UPDATE 1 - catalina.log
07-Jul-2016 07:52:39.914 INFO [http-nio-8080-exec-1] com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader.readFrom started event message body reader
07-Jul-2016 07:52:39.924 INFO [http-nio-8080-exec-1] com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader.readFrom Event: ApeContextUpdate
07-Jul-2016 07:52:39.924 SEVERE [http-nio-8080-exec-1] com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader.readFrom Could not parse XML NGSI event java.lang.NullPointerException, reason: null
last attribute name: null last value: null
07-Jul-2016 07:52:39.928 INFO [http-nio-8080-exec-1] com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader.readFrom finished event message body reader
07-Jul-2016 07:52:39.929 INFO [http-nio-8080-exec-1] com.ibm.hrl.proton.webapp.resources.EventResource.submitNewEvent starting submitNewEvent
07-Jul-2016 07:52:39.929 SEVERE [http-nio-8080-exec-1] com.ibm.hrl.proton.webapp.resources.EventResource.submitNewEvent Could not send event, reason: java.lang.NullPointerException, message: null
The problem seems to be that your Proton instance is not actually configured with your project's JSON definition file, therefore when sending the POST of any type you will always get NullPointerException since no such event can be found in Proton's metadata.
Please try to configure your instance's admin interface, as described here:
http://proactive-technology-online.readthedocs.io/en/latest/Proton-InstallationAndAdminGuide/index.html (Setup Apache Tomcat for management part)
And then run the following query:
GET //<ip of the machine running Proton>:8080/ProtonOnWebServerAdmin/resources/definitions.
This should return the all the project definitions this instance have...
And then if you see this in the list, you can retrieve your specific project's definition by running:
GET /<ip of the machine running Proton>:8080/resources/definitions/{definition_name}.
I think this will either return nothing, or will be empty.
You can update the definitions by using RESTful interface as described here: http://forge.fiware.org/plugins/mediawiki/wiki/fiware/index.php/Complex_Event_Processing_Open_RESTful_API_Specification (under the Managing Definitions Repository part)