VMware Cloud Community
Czernobog
Expert
Expert
Jump to solution

vRO 7.3 + NSX 1.1.0 failed to create connection manager

I need to choose one of the configured NSX Endpoints, depending on an input parameter.

For that I wanted to use the NSXConnectionManager.findConnectionByName(<|>?String_name) method, but I get a null pointer exception early on, when creating a new NSXConnectionManager:

var myNSXConnectionManager = new NSXConnectionManager();

exception: 'Cannot create NSXConnection object : java.lang.NullPointerException'

What is the correct way to create a new connection manager instance? Do I have to pass a value?

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

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");

View solution in original post

Reply
0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

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");

Reply
0 Kudos
Czernobog
Expert
Expert
Jump to solution

Tried this:

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.

Reply
0 Kudos