Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java firestoreoptions.getService上的Firestore空指针异常_Java_Linux_Google Cloud Firestore_Smartfoxserver - Fatal编程技术网

Java firestoreoptions.getService上的Firestore空指针异常

Java firestoreoptions.getService上的Firestore空指针异常,java,linux,google-cloud-firestore,smartfoxserver,Java,Linux,Google Cloud Firestore,Smartfoxserver,您好,我正在使用带有Java扩展的SmartFoxServer。在该扩展中,我正在尝试获取firestore实例。下面是我用来连接到IDE(Eclipse)中运行良好的服务的代码。但当我在SmartFoxServer上部署扩展时,firestoreOptions.getService上会出现空指针异常 String jsonPath = "data/************.json"; GoogleCredentials credentials = null;

您好,我正在使用带有Java扩展的SmartFoxServer。在该扩展中,我正在尝试获取firestore实例。下面是我用来连接到IDE(Eclipse)中运行良好的服务的代码。但当我在SmartFoxServer上部署扩展时,firestoreOptions.getService上会出现空指针异常

String jsonPath = "data/************.json";
        GoogleCredentials credentials = null;
            try {
                credentials = GoogleCredentials.fromStream(new FileInputStream(jsonPath))
                        .createScoped(Lists.newArrayList("https://www.googleapis.com/auth/cloud-platform"));
            } 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 {
                run();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                trace("Exception : " + e);
            }
这是我得到的一个例外

    com.google.cloud.firestore.FirestoreException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: com.google.cloud.firestore.FirestoreException
Message: java.lang.NullPointerException
Description: Extension initialization failed.
+--- --- ---+
Stack Trace:
+--- --- ---+
com.google.cloud.firestore.FirestoreException.networkException(FirestoreException.java:70)
com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:81)
com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:71)
com.google.cloud.ServiceOptions.getRpc(ServiceOptions.java:506)
com.google.cloud.firestore.FirestoreOptions.getFirestoreRpc(FirestoreOptions.java:306)
com.google.cloud.firestore.FirestoreImpl.<init>(FirestoreImpl.java:76)
com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreFactory.create(FirestoreOptions.java:62)
com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreFactory.create(FirestoreOptions.java:55)
com.google.cloud.ServiceOptions.getService(ServiceOptions.java:493)
sfs2x.extension.game.quiz.QuizExtension.init(QuizExtension.java:159)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.createExtension(SFSExtensionManager.java:303)
com.smartfoxserver.v2.entities.managers.SFSZoneManager.createZone(SFSZoneManager.java:426)
com.google.cloud.firestore.FirestoreException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
例外:com.google.cloud.firestore.FirestoreException
消息:java.lang.NullPointerException
描述:扩展初始化失败。
+--- --- ---+
堆栈跟踪:
+--- --- ---+
com.google.cloud.firestore.FirestoreException.networkException(FirestoreException.java:70)
com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:81)
com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:71)
com.google.cloud.ServiceOptions.getRpc(ServiceOptions.java:506)
com.google.cloud.firestore.FirestoreOptions.getFirestoreRpc(FirestoreOptions.java:306)
FirestoreImpl.(FirestoreImpl.java:76)
com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreFactory.create(FirestoreOptions.java:62)
com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreFactory.create(FirestoreOptions.java:55)
com.google.cloud.ServiceOptions.getService(ServiceOptions.java:493)
sfs2x.extension.game.quick.QuizExtension.init(QuizExtension.java:159)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.createExtension(SFSExtensionManager.java:303)
com.smartfoxserver.v2.entities.managers.SFSZoneManager.createZone(SFSZoneManager.java:426)
我是新来的消防商店。不知道在服务器上运行此代码是否缺少任何jar文件/库。任何帮助都将不胜感激

GOOGLE\u应用程序\u凭据


必须使用正确的凭据文件路径和名称添加环境变量,才能在服务器上运行firestore。

您确定
credentials
对象已正确初始化吗?是。我已通过记录凭据对象进行了检查。它有正确的值。