Firestore Null Pointer Exception on firestoreoptions.getService

By | July 12, 2018

Hi i am using SmartFoxServer with a Java extension. Inside that extension i am trying to get firestore instance. Below is the code i am using to connect to service that is working fine inside IDE (Eclipse). but when i deploy my extension on SmartFoxServer it gives a null pointer exception on firestoreOptions.getService

String jsonPath = "data/************.json";
        GoogleCredentials credentials = null;
            try {
                credentials = GoogleCredentials.fromStream(new FileInputStream(jsonPath))
            } catch (FileNotFoundException e1) {
                trace("Exception" + e1.toString());
            } catch (IOException e1) {
                trace("Exception" + e1.toString());

            FirestoreOptions firestoreOptions = FirestoreOptions.newBuilder().setCredentials(credentials).build();

            Firestore db = firestoreOptions.getService();
            this.db = db;
            try {
            } catch (Exception e) {
                // TODO Auto-generated catch block
                trace("Exception : " + e);

Here is the exception i am getting.
Message: java.lang.NullPointerException
Description: Extension initialization failed.
+--- --- ---+
Stack Trace:
+--- --- ---+$DefaultFirestoreRpcFactory.create($DefaultFirestoreRpcFactory.create(<init>($DefaultFirestoreFactory.create($DefaultFirestoreFactory.create(

i am new to firestore. Don’t know if any jar file/library is missing to run this code on server. any help would be appreciated.


Leave a Reply

Your email address will not be published. Required fields are marked *