Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
NullPointerException when SDK checks output arguments of a method call
December 15, 2017
13:16, EET
Avatar
Thomas Reuther
Member
Members
Forum Posts: 33
Member Since:
September 18, 2017
sp_UserOfflineSmall Offline

Hello,

I’m using the Java SDK 2.3.2. My task is to forward a method call from my server (aka local) to a remote server.
My local server’s method has the same signature as the remote one. The method has 2 arguments: Argument1=Array of atrings, Argument2=Array of NodeId. Output argument=Array of StatusCode.
My code looks like this:

public class MyMethodListener implements CallableListener {
@Override
public boolean onCall(ServiceContext serviceContext, NodeId objectId, UaNode object, NodeId methodId,
UaMethod method, Variant[] inputArguments, StatusCode[] inputArgumentResults,
DiagnosticInfo[] inputArgumentDiagnosticInfos, Variant[] outputs) throws StatusException {
String sNodeId = methodId.toString();
switch (sNodeId) {
case "ns=2;i=7010":
try {
myMethod(inputArguments, inputArgumentResults, outputs);
} catch (ServiceException e) {
throw new StatusException(e.getMessage(), e.getServiceResult());
}
return true;
}
return false;
}

private void myMethod(Variant[] inputArguments, StatusCode[] inputArgumentResults, Variant[] outputs) throws MethodCallStatusException, ServiceException {
Variant[] myoutputs = this.client.call(remoteObjectId, remoteMethodId, inputArguments);
System.arraycopy(myoutputs, 0, outputs, 0, myoutputs.length);
}
}

The client is connected to the remote server. The method call is also successful on the remote server. The return values are as expected. So far everything is perfect until my method ends.
But then the toolkit checks the output arguments:

ServiceFault: Bad_InternalError (0x80020000) "An internal error occurred as a result of a programming or configuration error."
Diagnostic Info: java.lang.IllegalArgumentException: Cannot find data type of class org.opcfoundation.ua.builtintypes.StatusCode
at com.prosysopc.ua.DataTypeConverter.getDataTypesForJavaClass(Unknown Source)
at com.prosysopc.ua.server.ServiceManagerBase.dataTypeEquals(Unknown Source)
at com.prosysopc.ua.server.MethodManagerUaNode.checkOutputArguments(Unknown Source)
at com.prosysopc.ua.server.MethodManagerUaNode.callMethod(Unknown Source)
at com.prosysopc.ua.server.NodeManager.callMethod(Unknown Source)
at com.prosysopc.ua.server.NodeManagerTable.callMethod(Unknown Source)
at com.prosysopc.ua.server.NodeManagementServiceHandler.callMethod(Unknown Source)
at com.prosysopc.ua.server.NodeManagementServiceHandler.call(Unknown Source)
at com.prosysopc.ua.server.NodeManagementServiceHandler.onCall(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.opcfoundation.ua.application.ServiceHandlerComposition$1.serve(Unknown Source)
at org.opcfoundation.ua.application.ServiceHandlerComposition.serve(Unknown Source)
at org.opcfoundation.ua.transport.tcp.nio.OpcTcpServerSecureChannel.handleSecureMessage(Unknown Source)
at org.opcfoundation.ua.transport.tcp.nio.OpcTcpServerConnection.handleSecureMessage(Unknown Source)
at org.opcfoundation.ua.transport.tcp.nio.OpcTcpServerConnection$4.onMessageComplete(Unknown Source)
at org.opcfoundation.ua.transport.tcp.nio.SecureInputMessageBuilder.fireComplete(Unknown Source)
at org.opcfoundation.ua.transport.tcp.nio.SecureInputMessageBuilder.setMessage(Unknown Source)
at org.opcfoundation.ua.transport.tcp.nio.SecureInputMessageBuilder$1.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

I want my local server return the same output values as the remote server does.

What can I do?
All the nodes in the address space are created using a node set file and calling UaServer.getAddressSpace().loadModel(stream).

Thomas

P.S. Sorry but the title contains the wrong exception name. It’s an IllegalArgumentException but not NullPointerException!

December 15, 2017
16:20, EET
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hi Thomas,

Thank you for a very good issue report. The Java SDK seems to be missing the class mapping for StatusCode datatype. Thanks for noticing! I’ll put this into our issue tracker and we’ll integrate the fix into next release version.

Until official fix, you can make a workaround by setting the Java class yourself in the server application:

UaServer.getNodeManagerRoot().getType(Identifiers.StatusCode).setJavaClass(org.opcfoundation.ua.builtintypes.StatusCode.class);

a suitable place for setting this is for example right after calling UaServer.init();

Let us know if the workaround works for you or if you still have any further questions.

December 15, 2017
17:38, EET
Avatar
Thomas Reuther
Member
Members
Forum Posts: 33
Member Since:
September 18, 2017
sp_UserOfflineSmall Offline

Thank you for the quick response! Now my server is working properly!

🙂 🙂 🙂

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
8 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 76

ibrahim: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 685

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6257

Newest Members:

Jan-Pfizer, DavidROunc, fen.pang@woodside.com, aytule, rashadbrownrigg, christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 320, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1