5:17, EEST
February 21, 2014
Hi,
I want to create a method using the “PlainMethod” type. When I’ll set the Input Arguments, a NullPointer exception is thrown upon reading the arguments’ attributes.
I’ll also copied the Arguments related code straight from the SDK sample and still receive the exception.
Here is the respective code snippet:
PlainMethod uploadMethod = new PlainMethod(serverNodeManager, new NodeId(ns, “uploadConfiguration”), new QualifiedName(ns, “uploadConfiguration”), new LocalizedText(“uploadConfiguration”));
Argument inputArgument = new Argument(“csvConfigurationString”, Identifiers.ByteString, ValueRanks.Scalar, (UnsignedInteger[]) null, new LocalizedText(“Configuration in CSV Format”));
uploadMethod.setInputArguments(new Argument[]{inputArgument});
The exception is triggered when trying to read the attributes of the Arguments (e.g. in UAExpert clicking on the Argument. From the StackTrace:
org.opcfoundation.ua.common.ServiceFaultException: ServiceFault: Bad_InternalError (0x80020000) “An internal error occurred as a result of a programming or configuration error.”
Diagnostic Info: java.lang.NullPointerException
at com.prosysopc.ua.server.UaServer$NodeManagerUaServer$1.onGetUserAccessLevel(UaServer.java:303)
at com.prosysopc.ua.server.io.IoManagerListenerChainImpl.onGetUserAccessLevel(IoManagerListenerChainImpl.java:49)
at com.prosysopc.ua.server.IoManager.getUserAccessLevel(IoManager.java:844)
[…. much more]
Thanks,
-Hans-Uwe
7:44, EEST
April 3, 2012
Most likely you have not added the method node to an Object/ObjectType node with a HasComponent Reference. In UA a method node is similar to a method/function in object oriented languages, meaning it is always called in the context of an object (or object type). This is also the reason why nodebuilder does usually not create new method nodes when instantiating, since the method is the same for each instance (just the node id of the object for which it is called changes).
– Bjarne
11:13, EEST
February 21, 2014
I had added the method to an outer objectNode by a hasComponent references, although I did this after the MethodNode has been constructed completely, i.e. after I added the arguments to the method node.
Before:
1) create plainMethodNode
2) add arguments to method
3) add MethodNode to outer object (hasComponent)
After changing the order of activities to
1) create plainMethodNode
2) add MethodNode to outer object
3) add arguments to method (hasComponent)
the exception is no longer thrown.
While this solves the problem, I find the order a bit counter-intuitive, because, as you quoted Object Oriented Programming, my expectation was rather to first construct the methodNode with all its subNodes and only then add the method to its owning object.
Maybe a little hint could be added to the JavaDoc for the PlainMethod node, explaining the correct sequence.
Anyhow, many thanks for your support.
Best,
Hans-Uwe
11:45, EEST
April 3, 2012
12:10, EEST
February 21, 2014
This is the version which threw an exception:
PlainMethod uploadMethod = new PlainMethod(serverNodeManager, new NodeId(ns, “uploadConfiguration”), new QualifiedName(ns, “uploadConfiguration”), new LocalizedText(“uploadConfiguration”));
Argument inputArgument = new Argument(“csvConfigurationString”, Identifiers.ByteString, ValueRanks.Scalar, (UnsignedInteger[]) null, new LocalizedText(“Modbus Configuration in CSV Format”));
uploadMethod.setInputArguments(new Argument[]{inputArgument});
configurationObjectNode.addComponent(uploadMethod);
the configurationObjectNode (BaseObjectTypeNode) has been defined earlier in the code
I’m working with the SDK 2.2.0, by the way
Most Users Ever Online: 1919
Currently Online:
21 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:
inilarythikibia, rickykennion, PromotionToold, HypromeImpupe, toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1