system.opcua.callMethod cannot be cast to class

Hi. I'm trying to work with an OPC-UA server. On the OPC Browser I have the following configuration:

opc_browser

Then, I'm running the following code on a onStartup event:

def runAction(self):
	output = system.opcua.callMethod(
		"OPC_Pedidos",
		"nsu=intercambio_pedidos_SCADA;i=1",
		"nsu=intercambio_pedidos_SCADA;i=25",
		[]
	)
	
	lista_param = output[2]

Where the following error appears:

Error running action 'system.onStartup' on Popups/popup_estado_actual@D: Traceback (most recent call last): File "function:runAction", line 4, in runAction java.lang.ClassCastException: class org.eclipse.milo.opcua.sdk.client.nodes.UaVariableNode cannot be cast to class org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode (org.eclipse.milo.opcua.sdk.client.nodes.UaVariableNode and org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode are in unnamed module of loader com.inductiveautomation.ignition.gateway.modules.ModuleClassLoader @603dec95) at org.eclipse.milo.opcua.sdk.client.nodes.UaNode.lambda$null$15(UaNode.java:1064) at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source) at java.base/java.util.concurrent.CompletableFuture.postComplete(Unknown Source) at java.base/java.util.concurrent.CompletableFuture.complete(Unknown Source) at org.eclipse.milo.opcua.stack.client.UaStackClient.lambda$deliverResponse$5(UaStackClient.java:318) at org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$Task.run(ExecutionQueue.java:119) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) java.lang.ClassCastException: java.lang.ClassCastException: class org.eclipse.milo.opcua.sdk.client.nodes.UaVariableNode cannot be cast to class org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode (org.eclipse.milo.opcua.sdk.client.nodes.UaVariableNode and org.eclipse.milo.opcua.sdk.client.model.nodes.variables.PropertyTypeNode are in unnamed module of loader com.inductiveautomation.ignition.gateway.modules.ModuleClassLoader @603dec95)

I know that the nodeId of the method and object are correct since prior to this I did a browse using system.opc.browse. The results were:

Any hints on why could this error be happening? Thanks in advance.

I have seen this before when the server address space is not modeled correctly or returning the right type definition for some Nodes, but without access to the server it will be difficult to confirm this is the issue.

Ignition 8.1.43 includes a new implementation of system.opcua.callMethod that works around certain bugs in FreeOpcUa-based servers, and it's possible this new implementation will help here as well.

If you aren't on 8.1.43 try upgrading.

3 Likes

Hi Kevin, thanks for your answer. Indeed upgrading to version 8.1.43 solved this issue.

1 Like