question

Samir Patel avatar image
Samir Patel asked Phong Vu commented

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)

rest api
1 |3000

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 Samir Patel commented

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
1 |3000

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

Samir Patel avatar image Samir Patel commented ·

Can your share list of dependencies for java server project?


0 Likes 0 ·
Samir Patel avatar image Samir Patel Samir Patel commented ·

Sorry thanks for your input. I figured out.

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

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
1 |3000

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

Samir Patel avatar image Samir Patel commented ·

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 ·
Phong Vu avatar image Phong Vu ♦♦ Samir Patel commented ·

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.

1 |3000

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

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys