Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-7243

XML collector in JSON mode assumes all element content is String

    Details

      Description

      Trying to collect data from the following JSON-RPC response:

      {"jsonrpc": "2.0", "result": [{"connectionLimitLowMarkPerc": 90, "totalNumberOfConnections": 0, "connectionLimit": 0, "connectionLimitLowMark": 0}], "id": 1}
      

      With the following xml-group:

          <xml-group name="natStats" resource-type="node" resource-xpath="/result">
              <xml-object name="ariNatTotalConx"     type="GAUGE" xpath="totalNumberOfConnections" />
              <xml-object name="ariNatConnLimit"     type="GAUGE"  xpath="connectionLimit" />
          </xml-group>
      

      I get the following exception stack trace:

      2014-12-08 13:38:12,896 WARN  [Collectd-Thread-7-of-50] o.o.n.c.CollectableService: run: failed collection for 4/64.146.64.212/Arista-eAPI/example1
      2014-12-08 13:38:12,896 ERROR [Collectd-Thread-7-of-50] o.o.n.c.CollectableService: Can't collect XML data because java.lang.Integer cannot be cast to java.lang.String
      org.opennms.netmgt.collection.api.CollectionException: Can't collect XML data because java.lang.Integer cannot be cast to java.lang.String
      	at org.opennms.protocols.xml.collector.XmlCollector.collect(XmlCollector.java:170) ~[org.opennms.protocols.xml-14.0.1-SNAPSHOT.jar:?]
      	at org.opennms.netmgt.collectd.CollectionSpecification.collect(CollectionSpecification.java:274) ~[opennms-services-14.0.1-SNAPSHOT.jar:?]
      	at org.opennms.netmgt.collectd.CollectableService.doCollection(CollectableService.java:388) ~[opennms-services-14.0.1-SNAPSHOT.jar:?]
      	at org.opennms.netmgt.collectd.CollectableService.doRun(CollectableService.java:322) [opennms-services-14.0.1-SNAPSHOT.jar:?]
      	at org.opennms.netmgt.collectd.CollectableService.access$000(CollectableService.java:70) [opennms-services-14.0.1-SNAPSHOT.jar:?]
      	at org.opennms.netmgt.collectd.CollectableService$1.run(CollectableService.java:300) [opennms-services-14.0.1-SNAPSHOT.jar:?]
      	at org.opennms.core.logging.Logging.withPrefix(Logging.java:66) [org.opennms.core.logging-14.0.1-SNAPSHOT.jar:?]
      	at org.opennms.netmgt.collectd.CollectableService.run(CollectableService.java:296) [opennms-services-14.0.1-SNAPSHOT.jar:?]
      	at org.opennms.netmgt.scheduler.LegacyScheduler$1.run(LegacyScheduler.java:209) [opennms-services-14.0.1-SNAPSHOT.jar:?]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_71]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_71]
      	at org.opennms.core.concurrent.LogPreservingThreadFactory$3.run(LogPreservingThreadFactory.java:124) [opennms-util-14.0.1-SNAPSHOT.jar:?]
      	at java.lang.Thread.run(Thread.java:745) [?:1.7.0_71]
      Caused by: org.opennms.netmgt.collection.api.CollectionException: java.lang.Integer cannot be cast to java.lang.String
      	at org.opennms.protocols.xml.collector.AbstractXmlCollectionHandler.collect(AbstractXmlCollectionHandler.java:201) ~[org.opennms.protocols.xml-14.0.1-SNAPSHOT.jar:?]
      	at org.opennms.protocols.xml.collector.XmlCollector.collect(XmlCollector.java:168) ~[org.opennms.protocols.xml-14.0.1-SNAPSHOT.jar:?]
      	... 12 more
      Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
      	at org.opennms.protocols.json.collector.AbstractJsonCollectionHandler.fillCollectionSet(AbstractJsonCollectionHandler.java:101) ~[org.opennms.protocols.xml-14.0.1-SNAPSHOT.jar:?]
      	at org.opennms.protocols.json.collector.DefaultJsonCollectionHandler.fillCollectionSet(DefaultJsonCollectionHandler.java:54) ~[org.opennms.protocols.xml-14.0.1-SNAPSHOT.jar:?]
      	at org.opennms.protocols.xml.collector.AbstractXmlCollectionHandler.collect(AbstractXmlCollectionHandler.java:194) ~[org.opennms.protocols.xml-14.0.1-SNAPSHOT.jar:?]
      	at org.opennms.protocols.xml.collector.XmlCollector.collect(XmlCollector.java:168) ~[org.opennms.protocols.xml-14.0.1-SNAPSHOT.jar:?]
      	... 12 more
      

        Attachments

          Activity

            People

            • Assignee:
              agalue Alejandro Galue
              Reporter:
              jeffg Jeff Gehlbach
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: