【问题标题】:java.lang.IllegalStateException: Failed to initialize a GAE background thread factoryjava.lang.IllegalStateException:无法初始化 GAE 后台线程工厂
【发布时间】:2017-11-12 16:30:43
【问题描述】:

当我尝试获取 firebase databasereferece 时收到此错误。

java.lang.IllegalStateException: 无法初始化 GAE 后台线程工厂

如果我获取的数据库引用不正确,请告诉我。

提前致谢。

try {
        FileInputStream serviceAccount = new FileInputStream("abcd.json");

        FirebaseOptions options = new FirebaseOptions.Builder()
                  .setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
                  .setDatabaseUrl("https://abc.firebaseio.com/").build();

        FirebaseApp.initializeApp(options);


    } catch (FileNotFoundException e) {
         System.out.println("ERROR: FileNotFoundException :invalid service account credentials. See README.");
         System.out.println(e.getMessage());

    } catch (IOException e) {
        System.out.println("ERROR: IOException : invalid service account credentials. See README.");
        System.out.println(e.getMessage());
    }

    DatabaseReference defaultDBRef = FirebaseDatabase.getInstance().getReference();

【问题讨论】:

    标签: java google-app-engine firebase firebase-realtime-database


    【解决方案1】:

    尝试使用手动扩展(检查您的免费配额!)。 firebase-admin-sdk 在处理线程方面存在问题。

    文档状态:

    我们建议即使是 Java 后端也使用 REST API for Firebase,因为重启运行 Firebase Java SDK 的 App Engine 线程存在已知问题。

    请看这里:https://cloud.google.com/solutions/using-firebase-real-time-events-app-engine

    【讨论】:

    • 感谢您的建议,rest api 是更好的方法。
    猜你喜欢
    • 2017-06-10
    • 1970-01-01
    • 1970-01-01
    • 2016-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多