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
BinaryEncoder: Object.class encoder was given a Variant directly, instead should given the value within Variant
August 18, 2022
14:06, EEST
Avatar
Manfred Hausmann
Member
Members
Forum Posts: 18
Member Since:
September 21, 2018
sp_UserOfflineSmall Offline

Hi,

our log gets filled with the warning “com.prosysopc.ua.stack.encoding.binary.BinaryEncoder: Object.class encoder was given a Variant directly, instead should given the value within Variant”. It seems that this warning turned up for the first time after we updated the Java SDK from 4.4.2 to 4.6.2 (currently we are using 4.8.0).

The stack trace (see below) does not lead into our code. Is this a problem in the OPC UA stack or in our application?

com.prosysopc.ua.stack.encoding.binary.BinaryEncoder: Object.class encoder was given a Variant directly, instead should given the value within Variant:
com.prosysopc.ua.stack.encoding.binary.BinaryEncoder$30.put(BinaryEncoder.java:351)
com.prosysopc.ua.stack.encoding.binary.BinaryEncoder.put(BinaryEncoder.java:643)
com.prosysopc.ua.types.opcua.Serializers$HistoryEventFieldListSerializer.putEncodeable(SourceFile:11424)
com.prosysopc.ua.stack.encoding.utils.AbstractSerializer.putEncodeable(SourceFile:211)
com.prosysopc.ua.stack.encoding.utils.SerializerComposition.putEncodeable(SourceFile:140)
com.prosysopc.ua.stack.encoding.binary.BinaryEncoder.putEncodeable(BinaryEncoder.java:1331)
com.prosysopc.ua.stack.encoding.binary.BinaryEncoder$23.put(BinaryEncoder.java:288)
com.prosysopc.ua.stack.encoding.binary.BinaryEncoder$23.put(BinaryEncoder.java:1)
com.prosysopc.ua.stack.encoding.binary.BinaryEncoder.put(BinaryEncoder.java:643)
com.prosysopc.ua.types.opcua.Serializers$HistoryEventSerializer.putEncodeable(SourceFile:10293)
com.prosysopc.ua.typedictionary.StructureSpecification.putEncodeable(SourceFile:415)
com.prosysopc.ua.stack.builtintypes.ExtensionObject.binaryEncode(SourceFile:96)
com.prosysopc.ua.stack.builtintypes.ExtensionObject.binaryEncode(SourceFile:56)
com.prosysopc.ua.server.ServiceHandler.toExtensionObject(SourceFile:161)
com.prosysopc.ua.server.AttributeServiceHandler.historyRead(SourceFile:697)
com.prosysopc.ua.server.AttributeServiceHandler.onHistoryRead(SourceFile:159)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
com.prosysopc.ua.stack.application.ServiceHandlerComposition$1.serve(SourceFile:114)
com.prosysopc.ua.stack.application.ServiceHandlerComposition.serve(SourceFile:235)
com.prosysopc.ua.stack.transport.tcp.nio.OpcTcpServerSecureChannel.handleSecureMessage(SourceFile:333)
com.prosysopc.ua.stack.transport.tcp.nio.OpcTcpServerConnection.handleSecureMessage(SourceFile:874)
com.prosysopc.ua.stack.transport.tcp.nio.OpcTcpServerConnection$3.onMessageComplete(SourceFile:263)
com.prosysopc.ua.stack.transport.tcp.nio.SecureInputMessageBuilder.fireComplete(SourceFile:458)
com.prosysopc.ua.stack.transport.tcp.nio.SecureInputMessageBuilder.setMessage(SourceFile:509)
com.prosysopc.ua.stack.transport.tcp.nio.SecureInputMessageBuilder$1.run(SourceFile:146)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)

August 19, 2022
10:59, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hmm.. odd, but easiest I first explain what that means.

Before SDK 4.0.0 (https://downloads.prosysopc.com/opcua/Prosys_OPC_UA_SDK_for_Java_4_Release_Notes.html#version-4-0-0) the mapping for BaseDataType was either Variant.class (stack level) or Object.class (SDK level), from 4.0.0 onward it is always Object.class (in a technical sense everything is now generated by the SDK level Codegen so there is only one mapping). To make the transition from old code easier the “Object.class encoder” also still accepts Variant as well, but will log WARN if that happens.

So basically somewhere where is xxx(Object yyy) a Variant was given for yyy when in 4.x world the correct way would be to give Variant.getValue().

The stacktrace mentions ‘HistoryEvent’. Do you happen to put a Variant somewhere in the HistoryEventFieldList within that (or well the EventFields of them, it is Object[]). You can put the Variant.getValue() there directly (as one of the elements).

It is possible that it is something else, but I would first assume it is within your code and probably somewhere where you have implemented HistoryManagerListener.onReadEvents.

P.S.
We also have static helpers in the Variant class: asObjectArray + asVariantArray

P.S.2
Variant is still being used In DataValue(s) though.

August 19, 2022
12:52, EEST
Avatar
Manfred Hausmann
Member
Members
Forum Posts: 18
Member Since:
September 21, 2018
sp_UserOfflineSmall Offline

Thanks a lot Bjarne, I will do that.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
18 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: 728

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0

Administrators: admin: 1