Connect to Firebase from spring boot and read callback method not executing

tan90 Source

I am trying to connect to firebase DB from the Spring Boot application using below code. But call back method is not executing and it never prints either in Success or Fail.

public void helper(){
    FileInputStream fileInputStream = null;

    try {
        // Fetch the service account key JSON file contents
        File file = new ClassPathResource("XXXXXXXX.json").getFile();
        fileInputStream = new FileInputStream(file);

        FirebaseOptions options = new FirebaseOptions.Builder()

        DatabaseReference ref = FirebaseDatabase

        ref.addListenerForSingleValueEvent(new ValueEventListener() {
            public void onDataChange(DataSnapshot dataSnapshot) {
                String res = dataSnapshot.getValue().toString();

            public void onCancelled(DatabaseError databaseError) {
                String res = databaseError.toString();
    }catch (Exception e){
    }finally {
        if (fileInputStream != null) {

Can you please let me know if I am doing anything wrong or something I need to change. I appreciate your help.



comments powered by Disqus