首页 文章

Orion / Proton订阅:解析Orion中的事件的java.lang.NullPointerException

提问于
浏览
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项目的定义(BTW这是从服务器文件系统复制的项目,因为其余的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

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

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(在Managing Definitions Repository部分下)

相关问题