rundeck / rundeck-api-java-client

Java client for the Rundeck REST API
http://rundeck.github.com/rundeck-api-java-client
Apache License 2.0
13 stars 17 forks source link

java api; getExecutionState NullPointerException whhen parsing XML response #20

Closed insee-ab closed 8 years ago

insee-ab commented 9 years ago

Hi We use

When we use the method getExecutionState we have a NullPointerException when the rundeck-api-java-client parses the Xml response which contents at the top level a "result" element

<result success='true' apiversion='12'><executionState id='27'><executionId>27</executionId><serverNode>W100024302</serverNode><executionState>SUCCEEDED</executionState><completed>true</completed><targetNodes><nodes><node name='W100024302'></node></nodes></targetNodes><allNodes><nodes><node name='W100024302'></node></nodes></allNodes><stepCount>1</stepCount><updateTime>2015-02-26T16:14:29Z</updateTime><startTime>2015-02-26T16:14:28Z</startTime><endTime>2015-02-26T16:14:29Z</endTime><steps><step stepctx='1' id='1'><parameterStates></parameterStates><nodeStep>true</nodeStep><executionState>SUCCEEDED</executionState><startTime>2015-02-26T16:14:28Z</startTime><updateTime>2015-02-26T16:14:28Z</updateTime><endTime>2015-02-26T16:14:29Z</endTime><nodeStates><nodeState name='W100024302'><executionState>SUCCEEDED</executionState><startTime>2015-02-26T16:14:29Z</startTime><updateTime>2015-02-26T16:14:29Z</updateTime><endTime>2015-02-26T16:14:29Z</endTime></nodeState></nodeStates></step></steps><nodes><node name='W100024302'><steps><step><stepctx>1</stepctx><executionState>SUCCEEDED</executionState></step></steps></node></nodes></executionState></result>

The StrackTrace:

Exception in thread "main" java.lang.NullPointerException
    at org.rundeck.api.parser.ExecutionStateParser.parseXmlNode(ExecutionStateParser.java:33)
    at org.rundeck.api.parser.ExecutionStateParser.parseXmlNode(ExecutionStateParser.java:14)

When we explore the error, it seems that the rundeck-api-java-client uses a rootelement "" (rootXpath() returns "") and so the parsed node is null, then NullPointeException

When we create a RundeckClient with version 10 (rootXpath() returns "result"), all is OK, no Exception.

A bug in rundeck-api-java-client ?

Thanks !

gschueler commented 9 years ago

Sounds like this fix wasn't complete: https://github.com/rundeck/rundeck-api-java-client/pull/17/commits

workaround would be to stick with client version 10, or update to rundeck 2.4

gschueler commented 9 years ago

fyi: http://rundeck.org/docs/history/version-2.4.0.html#compatibility-notes