14:06, EEST
September 21, 2018
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)
10:59, EEST
April 3, 2012
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.
Most Users Ever Online: 1919
Currently Online:
16 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: 735
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1523
Posts: 6449
Newest Members:
rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, Thomassnism, biancacraft16Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1