NSXConnectionManager is not a regular scripting object but a scripting singleton, so you can't instantiate it with new
So instead of:
var myNSXConnectionManager = new NSXConnectionManager(); var connection = myNSXConnectionManager.findConnectionByName("connname");
you should use something like:
var connection = NSXConnectionManager.findConnectionByName("connname");
var newNSXConn = NSXConnectionManager.findConnectionByName("nsx_conn_name");
and also with the Endpoint Id, same result:
[2017-11-07 12:24:58.278] [E] Cannot create NSXConnection object : java.lang.NullPointerException
[2017-11-07 12:24:58.287] [E] Workflow execution stack:
item: 'Create NSX connection Object/item1', state: 'failed', business state: 'null', exception: 'Cannot create NSXConnection object : java.lang.NullPointerException'
workflow: 'Create NSX connection Object' (d98ff4c6-d0d0-4fa0-9bdb-8360c8bec6d8)
| 'attribute': name=NSXConnection type=NSX:Connection value=__NULL__
| 'attribute': name=NSXConn type=NSX:Connection value=__NULL__
| 'attribute': name=def type=NSX:Connection value=dunes://service.dunes.ch/CustomSDKObject?id='2b1959ad-01a3-4573-a699-e0f2e724fb00'&dunesName='NSX:Connection'
| 'no inputs'
| 'no outputs'
*** End of execution stack.
Edit: Just as I was writing the above, I have found the source of the error! It was my mistake, in the scriptable task I still had an output parameter of the type NSX:Connection, that did not get a value assigned. Removing the output parameter also resulted in no more NPE error.