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
ClassCastException on write
April 5, 2013
13:56, EEST
Avatar
TimK
Member
Members
Forum Posts: 41
Member Since:
June 27, 2012
sp_UserOfflineSmall Offline

I’m using a custom node manager, and I’m seeing this exception when I try to write to an Int32 in my namespace.
I can read the value okay, and when I look at its properties in the client, I see that the data type is Int32 – nodeId is 0:6

This is how I’m creating the reference to the dataType in getReferences:

new NewClxReference(nodeInfo.nodeId,
getNamespaceTable().toExpandedNodeId(nodeInfo.dataTypeId),
Identifiers.HasTypeDefinition));

nodeInfo.dataTypeId is Identifiers.Int32 in this case.

Caused by: java.lang.ClassCastException: com.prosysopc.ua.server.nodes.UaExternalNodeImpl cannot be cast to com.prosysopc.ua.nodes.UaDataType
at com.prosysopc.ua.DataTypeConverter.a(Unknown Source)
at com.prosysopc.ua.DataTypeConverter.a(Unknown Source)
at com.prosysopc.ua.DataTypeConverter.(Unknown Source)
at com.prosysopc.ua.server.NodeManagerRoot.getDataTypeConverter(Unknown Source)
at com.prosysopc.ua.server.ServiceManagerBase.dataTypeEquals(Unknown Source)
at com.prosysopc.ua.server.IoManager.checkDataType(Unknown Source)
at com.prosysopc.ua.server.IoManager.writeAttribute(Unknown Source)
at com.oldi.opcuaserver.NewClxNodeManager$NewClxIoManager.writeAttribute(NewClxNodeManager.java:1016)
at com.prosysopc.ua.server.NodeManagerTable.writeAttribute(Unknown Source)
at com.prosysopc.ua.server.AttributeServiceHandler.writeAttribute(Unknown Source)
at com.prosysopc.ua.server.AttributeServiceHandler.write(Unknown Source)
at com.prosysopc.ua.server.AttributeServiceHandler.onWrite(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
… 11 more

April 5, 2013
14:24, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 960
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Have you defined a custom data type in your address space? It looks like there is a HasSubtype reference to an UaExternalNode from one of the DataType nodes.

If yes, what kind of reference is it?

The DataTypeConverter is not expecting such, but I believe it should be able to handle that better anyway.

April 5, 2013
14:45, EEST
Avatar
TimK
Member
Members
Forum Posts: 41
Member Since:
June 27, 2012
sp_UserOfflineSmall Offline

Yes, I have. From BaseDataTypes/Structure, I have a reference to my custom type node. It’s a HasSubtype reference to a DataType node.
My custom type also has a bunch of HasSubtype references to its children.

Does UAExternalNode just mean one created by my node manager?

April 5, 2013
17:03, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 960
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

UaExternalNode is used for nodes that are not otherwise available (and may exist in an external server).

Check that all your DataType nodes are actually of type UaDataType. Unfortunately, the error does not reveal which node is the problematic one.

April 5, 2013
18:32, EEST
Avatar
TimK
Member
Members
Forum Posts: 41
Member Since:
June 27, 2012
sp_UserOfflineSmall Offline

Maybe there’s something I’m misunderstanding here, but AFAIK I’m not creating any node objects. I’m implementing a custom node manager, and my understanding was that in that case, the node objects themselves aren’t actually created – my node manager just responds to requests for information about them. When asked for the various node attributes, values, or their references my code seems to be returning the right stuff, but I don’t see anywhere that I would create/return a UaDataType object.

April 5, 2013
21:32, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 960
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

OK, yes that explains it, of course: external node is used for nodes that are not defined as nodes in the . So far all Data Types have been defined with nodes, and that is also expected in the DataTypeConverter. I will figure how this situation should be handled. Version 1.4.4 is about to be released next week and this might go in there as well. Send an email to uajava-support@prosysopc.com, if you wish to verify it with a beta before the release.

What kind of types do you have, i.e. what’s their super type(s)?

Alternative is that you define the DataType nodes with UaDataTypes.

April 8, 2013
11:38, EEST
Avatar
TimK
Member
Members
Forum Posts: 41
Member Since:
June 27, 2012
sp_UserOfflineSmall Offline

The types I have are subtypes of Structure. I have one node under Structure, and then it has a child for each of the user-defined types I’m dealing with.
If I defined the nodes with UaDataTypes, how would that work in combination with the custom node manager?

April 9, 2013
6:45, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 960
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

OK, the structure types will not support “automatic” conversions anyway with the DataTypeConverter – and probably will not need such. So I suppose it is valid to define the types in your own node manager. I will have made the converter to omit non-UaDataType nodes, instead of throwing an exception.

You would have two options to define the types with UaDataType nodes, although your other data is custom nodes.

1. You can define another NodeManagerUaNode in which you add the type nodes, aside your custom node manager.
2. You can use a “hybrid” node manager that can include some UaNode-nodes and provide the rest as your “custom nodes”. This should be a sub class of NodeManagerUaNode so that it can handle UaNodes, but you could use the same way to provide your custom nodes. You would need to modify the overridden methods of the “big node manager” to call the super-methods, in case you do not provide data for the requested node yourself.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 267

Currently Online:
15 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 124

pramanj: 86

ibrahim: 74

rocket science: 65

kapsl: 57

Sabari: 51

gjevremovic: 49

Xavier: 43

fred: 41

TimK: 41

Member Stats:

Guest Posters: 0

Members: 1749

Moderators: 15

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1323

Posts: 5649

Newest Members:

WalterFOUNC, datafastproxiespx01, LenkaLok, seoninet, justinevillanuev, namtrott5457, DonaldWibip, AlfredoEthix, andreidla, everangel7021

Moderators: Jouni Aro: 960, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 860, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 25, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 222, Lusetti: 0

Administrators: admin: 1