0

i use cloud firestore on my spring boot application; when i testing in local it run right. i deployed my war file on my tomcat instance vm i get this error FirebaseApp with name [DEFAULT] doesn't exist. i following this link solution https://firebase.google.com/docs/firestore/quickstart but not working on server. i use many solution but i get always the same error. i need help to resolve this probleme. i use this code to initialize firebase-admin-sdk

Dride
  • 37
  • 5
  • I found a few similar issues and they seem to be all code related. I'm not sure if this might apply to your situation, or if you can give us a little more detail regarding your particular issue. https://stackoverflow.com/questions/50829899/how-to-fix-this-firebaseapp-name-default-already-exists-spring-boot-and-fireb/50834738 https://stackoverflow.com/questions/37342403/firebaseapp-with-name-default-doesnt-exist – Oliver Aragon Aug 12 '19 at 19:30
  • thank for answers i use the similar solution but not work – Dride Aug 14 '19 at 16:52

1 Answers1

0

this is my java main class

public static void main(String[] args) {
SpringApplication.run(BemanagementfirestoreApplication.class, args);
    try {
        InputStream serviceAccount = new FileInputStream("/Users/macbookpro/MyjavaProjet/apikey.json");
        GoogleCredentials credentials = GoogleCredentials.fromStream(serviceAccount);
        FirebaseOptions options = new FirebaseOptions.Builder()
                .setCredentials(credentials)
                .build();
        FirebaseApp.initializeApp(options);
        Firestore db = FirestoreClient.getFirestore();
    } catch (IOException e) {
        e.printStackTrace();
}
}
Dride
  • 37
  • 5