Firebase Database connection with Java server throws `InvocationTargetException`
<p>I am trying to connect to firebase database from my Java Server. When i get any reference from <code>FirebaseDatabase</code> object, it throws <code>InvocationTargetException</code></p>

<p>Error log trace : </p>

<pre><code>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:125)
    at com.hw.service.impl.AppServiceImpl.repopulateCounsellors(AppServiceImpl.java:161)
    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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy57.repopulateCounsellors(Unknown Source)
    at com.hw.controller.AppController.repopulateCounsellors(AppController.java:70)
</code></pre>

<p>Nested exception :</p>

<pre><code>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)
... 60 more
Caused by: java.lang.NullPointerException
    at com.google.appengine.api.ThreadManager.backgroundThreadFactory(ThreadManager.java:72)
</code></pre>

<p>Error occurs here in the 3rd line of the code below <code>fireDB.getReference</code></p>

<pre><code>FirebaseDatabase fireDB = FirebaseDatabase.getInstance(firebaseApp);
System.out.println(fireDB);
DatabaseReference ref = fireDB.getReference("/users");
System.out.println("db counsellor ref : " + ref);
System.out.println("db ref key : " + ref.getKey());
</code></pre>

<p>I am using Spring MVC for my java Server. <code>firebaseApp</code> is autowired and initialized in config class as : </p>

<pre><code>        String firebaseJson = env.getProperty("firebase.credentials");
        String fireDb = env.getProperty("firebase.db");
        FirebaseOptions options = new FirebaseOptions.Builder()
                .setServiceAccount(new FileInputStream(firebaseJson))
                .setDatabaseUrl(fireDb)
                .build();
        return FirebaseApp.initializeApp(options);
</code></pre>

<p>I have no idea where i am going wrong</p>