1

每当 Orion 发送事件时,我的 Proton 实例都会失败并出现 java.lang.NullPointerException

这是质子日志:

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

我已阅读用户指南的附录并仔细检查了事件名称和属性列表。

这是 Orion 发送的 xml:

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>

这是 Proton 项目的定义(顺便说一句,这是从服务器文件系统复制的项目,因为其余 api 也因 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"
}
}

这是我的 docker-compose 文件:

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"

我正在使用 Orion 0.28(支持 XML 通知的最后一个)和最新的 Proton

更新 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
4

1 回答 1

1

问题似乎是您的 Proton 实例实际上并未使用项目的 JSON 定义文件进行配置,因此在发送任何类型的 POST 时,您总是会收到 NullPointerException,因为在 Proton 的元数据中找不到此类事件。

请尝试配置您的实例的管理界面,如下所述:http: //proactive-technology-online.readthedocs.io/en/latest/Proton-InstallationAndAdminGuide/index.html(为管理部分设置 Apache Tomcat)

然后运行以下查询: GET //<ip of the machine running Proton>:8080/ProtonOnWebServerAdmin/resources/definitions. 这应该返回此实例具有的所有项目定义......然后,如果您在列表中看到它,您可以通过运行检索特定项目的定义 GET /<ip of the machine running Proton>:8080/resources/definitions/{definition_name}:我认为这要么什么都不返回,要么是空的。

您可以使用 RESTful 接口更新定义,如下所述:http: //forge.fiware.org/plugins/mediawiki/wiki/fiware/index.php/Complex_Event_Processing_Open_RESTful_API_Specification(在管理定义存储库部分下)

于 2016-07-04T14:27:25.583 回答