Question

ringcentral java sdk RestClient authorize throws null pointer exception

  • 26 November 2019
  • 3 replies
  • 482 views

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)


3 replies

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.

Userlevel 1

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?

Sorry thanks for your input. I figured out.

Reply