I'm currently developing a Java server in App Engine flexible environment and I'm having some issues trying to do integration tests.
The problem doesn't seem to be the code, as the exception happens with just getting the Firebase reference.
@BeforeClass
public static void beforeAllTests() throws IOException {
String dbJson;
String dbUrl;
dbJson = "src/main/webapp/WEB-INF/xxxxx.json";
dbUrl = "https://xxxx.firebaseio.com/";
FirebaseOptions options = new FirebaseOptions.Builder().setServiceAccount(new FileInputStream(dbJson))
.setDatabaseUrl(dbUrl).build();
FirebaseApp.initializeApp(options);
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
}
This is enough to reproduce the problem. The error log is:
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.google.firebase.database.core.GaePlatform.getGaeThreadFactory(GaePlatform.java:67)
at com.google.firebase.database.core.GaePlatform.isActive(GaePlatform.java:78)
at com.google.firebase.database.core.Context.getPlatform(Context.java:42)
at com.google.firebase.database.core.Context.ensureLogger(Context.java:211)
at com.google.firebase.database.core.Context.initServices(Context.java:77)
at com.google.firebase.database.core.Context.freeze(Context.java:64)
at com.google.firebase.database.core.RepoManager.createLocalRepo(RepoManager.java:78)
at com.google.firebase.database.core.RepoManager.createRepo(RepoManager.java:28)
at com.google.firebase.database.FirebaseDatabase.ensureRepo(FirebaseDatabase.java:249)
at com.google.firebase.database.FirebaseDatabase.getReference(FirebaseDatabase.java:114)
at com.basetis.appengine.utils.FirebaseUtils.initializeApp(FirebaseUtils.java:15)
at integration.TestIntegration.beforeAllTests(TestIntegration.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.google.firebase.database.core.GaePlatform.getGaeThreadFactory(GaePlatform.java:62)
... 26 more
Caused by: java.lang.NullPointerException
at com.google.appengine.api.ThreadManager.backgroundThreadFactory(ThreadManager.java:72)
... 31 more
I'm using Firebase 3.0.1 SDK. Thank you for taking your time reading this.