question

Samir Patel avatar image
Samir Patel asked ·

ringcentral java sdk RestClient authorize throws null pointer exception

Running following code on tomcat throws null pointer exception. Running same code in java main method runs fine.

        RestClient rc = new RestClient(clientID, clientSecret, serverURL);
        System.out.println("server-> " + rc.server);
        try {
            rc.authorize(username, extension, password);
            GetVersionsResponse result = rc.restapi().list();
            System.out.println("Result " + result.uri);
            rc.revoke();
        }
        catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        catch (RestException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

java.lang.NullPointerException

at com.ringcentral.RestClient.requestRaw(RestClient.java:257)

at com.ringcentral.RestClient.request(RestClient.java:320)

at com.ringcentral.RestClient.request(RestClient.java:251)

at com.ringcentral.RestClient.post(RestClient.java:146)

at com.ringcentral.paths.restapi.oauth.token.Index.post(Index.kt:18)

at com.ringcentral.RestClient.authorize(RestClient.java:113)

ringcentral java sdk restclient authorize throws null pointer exception
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Khadhar Koneti avatar image
Khadhar Koneti answered ·

HI, Ideally you should not get the null pointer. How you are loading ring central dependencies ? If you are using maven or gradle then try to use latest version jars.

2 comments Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Can your share list of dependencies for java server project?


0 Likes 0 · ·

Sorry thanks for your input. I figured out.

0 Likes 0 · ·
Phong Vu avatar image
Phong Vu answered ·

It looks like something is wrong in your project settings that did not import the RingCentral SDK properly. I don't see this line printed in your post:

System.out.println("server-> " + rc.server);

Can you double check or show how you import the SDK?

2 comments Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Thank you. Let me give try again. The server line is printed, fails on authorize call

server-> "https://platform.devtest.ringcentral.com"

0 Likes 0 · ·

Have you put some breakpoints and run line by line to see what object is null? Also which catch did it end up in

catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
catch (RestException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


0 Likes 0 · ·
Samir Patel avatar image
Samir Patel answered ·

Sorry thanks for your input. I figured out.

Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.