18:30, EEST
October 13, 2016
I have an object with a method that expects, as one of its arguments, an array of a custom data type. All of my types were automatically generated by the SDK.
I am using the SampleConsoleServer and SampleConsoleClient to test my application. I have made a small modification to SampleConsoleClient so it can parse my input into an array of my custom data type where necessary.
Calling the method works fine if I pass an array of my custom data type that contains one or more elements. However, if I pass an empty array of my custom data type, I get the following error:
com.prosysopc.ua.ServiceException: ServiceFault: Bad_InternalError (0x80020000) “An internal error occurred as a result of a programming or configuration error.”
Diagnostic Info: 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 Structure type interface org.opcfoundation.ua.builtintypes.Structure
at com.prosysopc.ua.DataTypeConverter.getDataTypesForJavaClass(Unknown Source)
at com.prosysopc.ua.server.ServiceManagerBase.dataTypeEquals(Unknown Source)
at com.prosysopc.ua.server.MethodManagerUaNode.checkInputArguments(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)
Inner Info: java.lang.NoSuchFieldException: ID (Bad_InternalError (0x80020000) “An internal error occurred as a result of a programming or configuration error.”)
at java.lang.Class.getField(Class.java:1703)
at com.prosysopc.ua.DataTypeConverter.getDataTypesForJavaClass(Unknown Source)
at com.prosysopc.ua.server.ServiceManagerBase.dataTypeEquals(Unknown Source)
at com.prosysopc.ua.server.MethodManagerUaNode.checkInputArguments(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 see this error in both the server and client console and the error seems to occur before the method is actually called. The ID field is present on the generated data type class and this problem only occurs if the array is empty. Is this a bug or am I missing something?
Unfortunately I cannot share the actual files, so I hope the information I’ve given is sufficient.
Best regards
Maarten
11:49, EEST
April 3, 2012
Hi,
The easiest current workaround if possible is to use null value instead of empty array. Is this possible for you?
Anyway this can be considered as a bug. However we need to think how to solve this.
The root of the problem is that an empty array of Structures in UA does not contain type information. An array of Structures is encoded element by element sequentially. If it does not have any, then in practice this means the array does not have a type, or at least there no way to resolve it. In the binary level it is encoded as empty array of ExtensionObjects inside Variant. This means it is decoded (by the Stack) as an empty array of Structures (the interface ‘Structure’), which of course is not of the correct type. This will then in turn lead to the exceptions you are seeing.
This should be fixable still. How critical is this to you? If you send mail to uajava-support@prosysopc.com, I can send you a beta version when this is fixed. Otherwise it will most likely be done in next release.
– Bjarne
14:04, EEST
October 13, 2016
Hi Bjarne
I will test the workaround passing a null value. I have been sending an array with a dummy element as a workaround, but sending null seems less ugly.
At the moment, the issue is not critical to me. In the future this may become a problem as I will have to interface with other systems that I do not have control over and which may send an empty array instead of null.
Best regards
Maarten
Most Users Ever Online: 1919
Currently Online:
23 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 731
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
PromotionToold, HypromeImpupe, toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachusModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1