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

XML data collection with JSON handler fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 16.0.3
    • Fix Version/s: 16.0.4
    • Component/s: Data Collection - XML
    • Security Level: Default (Default Security Scheme)
    • Labels:
      None

      Description

      If you configure an XML using the AbstractJsonCollection handler and the data collection with XPath expression doesn't returns with a value, the whole data collection stops for the node with the following error message:

      2015-09-20 00:49:15,892 ERROR [Collectd-Thread-19-of-50] o.o.n.c.CollectableService: Can't collect XML data because No value for xpath: statistics/traffic/forward/bytes
      org.opennms.netmgt.collection.api.CollectionException: Can't collect XML data because No value for xpath: statistics/traffic/forward/bytes
      	at org.opennms.protocols.xml.collector.XmlCollector.collect(XmlCollector.java:170) ~[org.opennms.protocols.xml-16.0.3.jar:?]
      	at org.opennms.netmgt.collectd.CollectionSpecification.collect(CollectionSpecification.java:274) ~[opennms-services-16.0.3.jar:?]
      	at org.opennms.netmgt.collectd.CollectableService.doCollection(CollectableService.java:395) ~[opennms-services-16.0.3.jar:?]
      	at org.opennms.netmgt.collectd.CollectableService.doRun(CollectableService.java:329) [opennms-services-16.0.3.jar:?]
      	at org.opennms.netmgt.collectd.CollectableService.access$200(CollectableService.java:70) [opennms-services-16.0.3.jar:?]
      	at org.opennms.netmgt.collectd.CollectableService$1.run(CollectableService.java:307) [opennms-services-16.0.3.jar:?]
      	at org.opennms.core.logging.Logging.withPrefix(Logging.java:70) [org.opennms.core.logging-16.0.3.jar:?]
      	at org.opennms.netmgt.collectd.CollectableService.run(CollectableService.java:296) [opennms-services-16.0.3.jar:?]
      	at org.opennms.netmgt.scheduler.LegacyScheduler$1.run(LegacyScheduler.java:209) [opennms-services-16.0.3.jar:?]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_60]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_60]
      	at org.opennms.core.concurrent.LogPreservingThreadFactory$3.run(LogPreservingThreadFactory.java:124) [opennms-util-16.0.3.jar:?]
      	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_60]
      Caused by: org.opennms.netmgt.collection.api.CollectionException: No value for xpath: statistics/traffic/forward/bytes
      	at org.opennms.protocols.xml.collector.AbstractXmlCollectionHandler.collect(AbstractXmlCollectionHandler.java:196) ~[org.opennms.protocols.xml-16.0.3.jar:?]
      	at org.opennms.protocols.xml.collector.XmlCollector.collect(XmlCollector.java:168) ~[org.opennms.protocols.xml-16.0.3.jar:?]
      	... 12 more
      Caused by: org.apache.commons.jxpath.JXPathNotFoundException: No value for xpath: statistics/traffic/forward/bytes
      	at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue(JXPathContextReferenceImpl.java:383) ~[commons-jxpath-1.3.jar:1.3]
      	at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue(JXPathContextReferenceImpl.java:313) ~[commons-jxpath-1.3.jar:1.3]
      	at org.opennms.protocols.json.collector.AbstractJsonCollectionHandler.fillCollectionSet(AbstractJsonCollectionHandler.java:106) ~[org.opennms.protocols.xml-16.0.3.jar:?]
      	at org.opennms.protocols.json.collector.DefaultJsonCollectionHandler.fillCollectionSet(DefaultJsonCollectionHandler.java:54) ~[org.opennms.protocols.xml-16.0.3.jar:?]
      	at org.opennms.protocols.xml.collector.AbstractXmlCollectionHandler.collect(AbstractXmlCollectionHandler.java:189) ~[org.opennms.protocols.xml-16.0.3.jar:?]
      	at org.opennms.protocols.xml.collector.XmlCollector.collect(XmlCollector.java:168) ~[org.opennms.protocols.xml-16.0.3.jar:?]
      	... 12 more
      

      The check for the null obj should be in a try catch block. The if statement in line 107 is too late, NPE happens in 106.

      See:
      https://github.com/OpenNMS/opennms/blob/opennms-16.0.3-1/protocols/xml/src/main/java/org/opennms/protocols/json/collector/AbstractJsonCollectionHandler.java#L106

        Attachments

          Activity

            People

            • Assignee:
              agalue Alejandro Galue
              Reporter:
              indigo Ronny Trommer
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: