Skip to content
Discussions/App Development/NullPointerException when using UserManagementClientForum ↗

NullPointerException when using UserManagementClient

App Development8 posts238 viewsLast activity Aug 2023
HU
huwOP
Aug 2023

Hi there, I’m having some trouble when calling the rxjava UserManagementClient like this:

ledgerClient.getUserManagementClient.createUser(
  new CreateUserRequest(
    new User(myUser),
    new User.Right.CanActAs(myParty1),
    new User.Right.CanActAs(myParty2)
  )
).blockingGet();

It’s giving me a NullPointerException. There is no issue when using the other CreateUserRequest constructor – see below:

ledgerClient.getUserManagementClient().createUser(new CreateUserRequest(myUser, myParty)).blockingGet();

Note - my rxjava bindings version is 2.6.0

CO
cocreature
Aug 2023

Can you share the full stack trace you get?

HU
huw
Aug 2023

Here it is:

java.lang.NullPointerException: null
        at com.daml.ledger.api.v1.admin.UserManagementServiceOuterClass$User$Builder.setPrimaryParty(UserManagementServiceOuterClass.java:1028)
        at com.daml.ledger.javaapi.data.User.toProto(User.java:29)
        at com.daml.ledger.javaapi.data.CreateUserRequest.toProto(CreateUserRequest.java:40)
        at com.daml.ledger.rxjava.grpc.UserManagementClientImpl.createUser(UserManagementClientImpl.java:30)
        at com.daml.ledger.rxjava.grpc.UserManagementClientImpl.createUser(UserManagementClientImpl.java:36)
...
CO
cocreature
Aug 2023

It looks like there is probably a bug when trying to create a user without a primary party. Are you deliberately not setting one? Could you try new User(myUser, myParty1)?

HU
huw
Aug 2023

No, I didn’t do it deliberately. I can set the primary party if needed. Is the primary party required?

CO
cocreature
Aug 2023

It definitely shouldn’t be but I suspect it works around the bug here.

HU
huw
Aug 2023

My workaround is to set the primary party as shown below. Must be some bug related to not having a primary party.

ledgerClient.getUserManagementClient.createUser(
  new CreateUserRequest(
    new User(myUser, myParty1),
    new User.Right.CanActAs(myParty1),
    new User.Right.CanActAs(myParty2)
  )
).blockingGet();
CO
cocreature
Aug 2023

Thanks, I’ve reported it to the responsible team.

← Back to Discussions