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
NullPointerException on activateSession()
August 26, 2020
9:45, EEST
Avatar
Thomas Reuther
Member
Members
Forum Posts: 33
Member Since:
September 18, 2017
sp_UserOfflineSmall Offline

Hello support,

I just update my server from SDK for Java 3.2.0 to 4.3.0. I also update the JDK version from 8 to 11. When I start my CTT scripts (OPCUA compliance test tool) I get an exception when I try to connect.

My server is acting as a data source in a test environment. I use CTT to test other servers than mine. During the tests I also need to connect to my server because the server under test is connecting to my server during test phase.
Using SDK 3.2.0 the CTT script runs without any issues and could connect to my server. When I update my server I only exchanged the toolkit, replaced the packages OPC Foundation Stack by yours (replace “org.opcfoundation.ua.*” by “com.prosysopc.ua.stack.*”), replaced deprecated methods by suggested ones (e.g. “new UaAddress()” by “UaAddress.parse()”), replaced some enums (e.g. replace “WriteAccess” by “AttributeWriteMask”). That’s it.

When I use other clients then I can successfully connect to my server, e.g. UA Expert 1.5.1 or Prosys OPCUA Client 3.2.0. I can even connect to my server using the project settings dialog of CTT.
On the other hand my script can still successfully connect to other servers base on different toolkits, e.g. Softing, Unified Automation (e.g. UA Demo Server 1.3.2), and servers built on older versions of Prosys SDK.

I pretty sure to implement a workaround on either CTT script or my server, but I have no idea what happens. On client side (my CTT script) I only get the bad status “BadInternalError” when calling ActivateSession. CreateChannel and CreateSession were working fine. When I run my server in debug mode Eclipse stops in method SessionManager.activateSession(). It shows that input argument “arg1” (AuthenticationToken) is null. At the client I can see that the AuthenticationToken of the RequestHeader of UaActivateSessionRequest is the same as at the session object. When I continue running my server after debug/exception breakpoint the following log contains the value of the AuthenticationToken which is not null!

Here comes the full log including stack trace:

08/26/2020 08:05:09.465 INFO SecureChannel opened; SecurityToken(Id=1, secureChannelId=34, creationTime=26.08.2020, 08:05:09, lifetime=600000)
08/26/2020 08:05:09.467 INFO Session created: UaCttSession_3 (ID=ns=1;g=2876cd63-6f24-4593-b645-d6c63e9159d9 Token=b=MkLOG6UqR1GPkUa4z8yzt/frkDiqL+S3ENz8Fl5FH4k= Channel=(SecureChannelId=34 State=Open URL=opc.tcp://192.168.100.1:4999/OPCUA/TestServer SecurityPolicy=http://opcfoundation.org/UA/SecurityPolicy#None RemoteAddress=/192.168.100.1:58315))
08/26/2020 08:05:11.946 ERROR While handling ActivateSessionRequest [RequestHeader="RequestHeader [AuthenticationToken="b=MkLOG6UqR1GPkUa4z8yzt/frkDiqL+S3ENz8Fl5FH4k=", Timestamp="08/26/20 06:05:09.4695126 GMT", RequestHandle="2", ReturnDiagnostics="0", AuditEntryId="null", TimeoutHint="1800000", AdditionalHeader="null"]", ClientSignature="SignatureData [Algorithm="null", Signature="null"]", ClientSoftwareCertificates="null", LocaleIds="[]", UserIdentityToken="ExtensionObject [typeId=null, encodeType=null, object=AnonymousIdentityToken [PolicyId="Anonymous"]]", UserTokenSignature="SignatureData [Algorithm="null", Signature="null"]"]
ServiceFault [ResponseHeader="ResponseHeader [Timestamp="08/26/20 06:05:11.9450000 GMT", RequestHandle="null", ServiceResult="Bad_InternalError (0x80020000) "An internal error occurred as a result of a programming or configuration error."", ServiceDiagnostics="Diagnostic Info: java.lang.NullPointerException (Bad_InternalError (0x80020000) "An internal error occurred as a result of a programming or configuration error.")
at com.prosysopc.ua.server.SessionManager.activateSession(SourceFile:639)
at com.prosysopc.ua.server.SessionServiceHandler.onActivateSession(SourceFile:83)
at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.prosysopc.ua.stack.application.ServiceHandlerComposition$1.serve(SourceFile:114)
at com.prosysopc.ua.stack.application.ServiceHandlerComposition.serve(SourceFile:235)
at com.prosysopc.ua.stack.transport.tcp.nio.OpcTcpServerSecureChannel.handleSecureMessage(SourceFile:333)
at com.prosysopc.ua.stack.transport.tcp.nio.OpcTcpServerConnection.handleSecureMessage(SourceFile:862)
at com.prosysopc.ua.stack.transport.tcp.nio.OpcTcpServerConnection$3.onMessageComplete(SourceFile:263)
at com.prosysopc.ua.stack.transport.tcp.nio.SecureInputMessageBuilder.fireComplete(SourceFile:442)
at com.prosysopc.ua.stack.transport.tcp.nio.SecureInputMessageBuilder.setMessage(SourceFile:493)
at com.prosysopc.ua.stack.transport.tcp.nio.SecureInputMessageBuilder$1.run(SourceFile:146)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

", StringTable="[java.lang.NullPointerException]", AdditionalHeader="null"]"]
at com.prosysopc.ua.stack.application.ServiceHandlerComposition$1.serve(SourceFile:127)
at com.prosysopc.ua.stack.application.ServiceHandlerComposition.serve(SourceFile:235)
at com.prosysopc.ua.stack.transport.tcp.nio.OpcTcpServerSecureChannel.handleSecureMessage(SourceFile:333)
at com.prosysopc.ua.stack.transport.tcp.nio.OpcTcpServerConnection.handleSecureMessage(SourceFile:862)
at com.prosysopc.ua.stack.transport.tcp.nio.OpcTcpServerConnection$3.onMessageComplete(SourceFile:263)
at com.prosysopc.ua.stack.transport.tcp.nio.SecureInputMessageBuilder.fireComplete(SourceFile:442)
at com.prosysopc.ua.stack.transport.tcp.nio.SecureInputMessageBuilder.setMessage(SourceFile:493)
at com.prosysopc.ua.stack.transport.tcp.nio.SecureInputMessageBuilder$1.run(SourceFile:146)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException
at com.prosysopc.ua.server.SessionManager.activateSession(SourceFile:639)
at com.prosysopc.ua.server.SessionServiceHandler.onActivateSession(SourceFile:83)
at jdk.internal.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.prosysopc.ua.stack.application.ServiceHandlerComposition$1.serve(SourceFile:114)
… 10 more
08/26/2020 08:05:11.949 INFO AsyncSocketInputStream.close(): unexpected untriggered monitor
08/26/2020 08:05:11.949 INFO Secure Channel closed, token=SecurityToken(Id=1, secureChannelId=34, creationTime=26.08.2020, 08:05:09, lifetime=600000)
08/26/2020 08:05:11.950 INFO Channel closed: Id=34
08/26/2020 08:05:19.938 INFO Session closed: UaCttSession_3 (ID=ns=1;g=2876cd63-6f24-4593-b645-d6c63e9159d9 Token=b=MkLOG6UqR1GPkUa4z8yzt/frkDiqL+S3ENz8Fl5FH4k= Channel=(SecureChannelId=34 State=Closed URL=opc.tcp://192.168.100.1:4999/OPCUA/TestServer SecurityPolicy=http://opcfoundation.org/UA/SecurityPolicy#None RemoteAddress=null))

Can you tell me what happens in line 639 of SessionManager?

Thanks in advance.
Thomas Reuther

August 26, 2020
10:11, EEST
Avatar
Thomas Reuther
Member
Members
Forum Posts: 33
Member Since:
September 18, 2017
sp_UserOfflineSmall Offline

Update: I rebuild my server using Java 8. But that makes no difference.

August 26, 2020
10:50, EEST
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 349
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

Version 4.3.0 of the Prosys OPC UA SDK for Java made numerous changes to activation of Sessions and validation of Certificates. Updating to this version could mean that Clients that were previously able to activate a Session would no longer be able to do so unless they could pass the new stricter security checks. The Compliance Test Tool was used to test these changes.

Assuming you have the Client & Server Source Edition of the Prosys OPC UA SDK for Java, on this particular line of SessionManager the Server’s UserTokenPolicies are compared to the UserTokenPolicy defined in the UserIdentityToken sent by the Client. Based on the log, the Client’s UserIdentityToken defines Anonymous as its UserTokenPolicy. Therefore, this shouldn’t cause a NullPointerException unless your Server has no UserTokenPolicies defined, which seems unlikely.

If you’re not using the Source Edition, then this line is covered by code obfuscation and it’s impossible to tell exactly what is happening on that particular line.

Which version of the Compliance Test Tool you’re using? Is the script causing this error a custom test script or part of the CTT’s conformance units?

August 26, 2020
16:00, EEST
Avatar
Thomas Reuther
Member
Members
Forum Posts: 33
Member Since:
September 18, 2017
sp_UserOfflineSmall Offline

Hello,

it took me some hours of investigation but finally I found the reason. UserTokenPolicies are the right point. With SDK 3.2.0 I used to setup my server this way:

addUserTokenPolicy(UserTokenPolicy.ANONYMOUS);

In SDK 4.3.0 this constant is no longer available. So I did it this way:

UserTokenPolicy u = new UserTokenPolicy();
u.setTokenType(UserTokenType.Anonymous);
addUserTokenPolicy(u);

Here I forgot to define the policy id. The correct way has to be:

UserTokenPolicy u = new UserTokenPolicy();
u.setTokenType(UserTokenType.Anonymous);
u.setPolicyId("anonymous");
addUserTokenPolicy(u);

And now it works. 🙂

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
24 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: 727

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

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

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

Administrators: admin: 1