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
"Cannot find data type of Structure type interface" when passing empty array of generated data type to method
October 14, 2016
18:30, EEST
Avatar
maartenmichiels
Member
Members
Forum Posts: 4
Member Since:
October 13, 2016
sp_UserOfflineSmall Offline

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

October 17, 2016
11:49, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

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

October 17, 2016
14:04, EEST
Avatar
maartenmichiels
Member
Members
Forum Posts: 4
Member Since:
October 13, 2016
sp_UserOfflineSmall Offline

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

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

TimK: 41

Member Stats:

Guest Posters: 0

Members: 683

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

digitechroshni, LouieWreve, Kickbiche, karrimacvitie5, graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma

Moderators: Jouni Aro: 1010, 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: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1