Skip to main content
The First Step
November 26, 2019
Question

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)

3 replies

The First Step
November 27, 2019

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.

PhongVu
Community Manager
Community Manager
November 27, 2019

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?

The First Step
November 27, 2019

Sorry thanks for your input. I figured out.