I'm trying to write to the Firebase database following this page instructions. I'm using a servlet running in Appengine and the error happens when trying to read the serviceAccountCredentials.json file.
Here is part of the code where the problem happens:
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
FirebaseOptions options = new FirebaseOptions.Builder()
.setDatabaseUrl("https://my-database.firebaseio.com/")
.setServiceAccount(new FileInputStream("/src/main/webapp/WEB-INF/My File-89b47a8357ff.json"))
.build();
FirebaseApp.initializeApp(options);
And here is the logcat output:
java.security.AccessControlException: access denied ("java.io.FilePermission" "\src\main\webapp\WEB-INF\My File-89b47a8357ff.json" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
at java.security.AccessController.checkPermission(AccessController.java:559)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:429)
at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
at java.io.FileInputStream.<init>(FileInputStream.java:135)
at java.io.FileInputStream.<init>(FileInputStream.java:101)
at com.example.myexample.myapplication.backend.MyServlet.doPost(MyServlet.java:81)
any help will be appreciated.