Error starting Firebase on Google App Engine

I am currently developing the endpoint of a Java Java wrapper in GAE. Inside the endpoint, he will try to connect to the Firebase server to get some data.

However, when I create a Firebase object at my endpoint,

Firebase ref = new Firebase(<My Firebase URL>); 

GAE produces the following error:

 java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup") at java.security.AccessControlContext.checkPermission(AccessControlContext.java:382) at java.security.AccessController.checkPermission(AccessController.java:572) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315) at java.lang.Thread.init(Thread.java:391) at java.lang.Thread.init(Thread.java:349) at java.lang.Thread.<init>(Thread.java:675) at java.util.concurrent.Executors$DefaultThreadFactory.newThread(Executors.java:572) at com.firebase.client.utilities.DefaultRunLoop$FirebaseThreadFactory.newThread(DefaultRunLoop.java:25) at java.util.concurrent.ThreadPoolExecutor$Worker.<init>(ThreadPoolExecutor.java:600) at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:943) at java.util.concurrent.ThreadPoolExecutor.ensurePrestart(ThreadPoolExecutor.java:1635) at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:307) at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:526) at java.util.concurrent.ScheduledThreadPoolExecutor.execute(ScheduledThreadPoolExecutor.java:615) at com.firebase.client.utilities.DefaultRunLoop.scheduleNow(DefaultRunLoop.java:57) at com.firebase.client.core.Repo.scheduleNow(Repo.java:176) at com.firebase.client.core.Repo.<init>(Repo.java:58) at com.firebase.client.core.RepoManager.getLocalRepo(RepoManager.java:46) at com.firebase.client.core.RepoManager.getRepo(RepoManager.java:19) at com.firebase.client.Firebase.<init>(Firebase.java:194) at com.firebase.client.Firebase.<init>(Firebase.java:199) at com.firebase.client.Firebase.<init>(Firebase.java:177) 

I am using Firebase client 2.2.3. GAE seems to be preventing the application from creating new threads. Any idea?

+5
source share
3 answers

@ Mario is correct, the App Engine application cannot create new threads according to docs . This is because the AppEngine application runs in a sandbox in which you have some limitations. If you want to develop an application without any restrictions, I would suggest trying a "Managed Virtual Machine" in which you have these types of restrictions.

+3
source

There are some restrictions on creating new threads in the Java runtime for the Google App Engine.

See the Themes section for more information.

+4
source

I think this link will help you, it describes how we can use the firebase real-time database from the server application using the service account.

You can use the following code snippet to connect to the firebase database.

 // Initialize the app with a service account, granting admin privileges FirebaseOptions options = new FirebaseOptions.Builder() .setDatabaseUrl("https://databaseName.firebaseio.com") .setServiceAccount(new FileInputStream("path/to/serviceAccountCredentials.json")) .build(); FirebaseApp.initializeApp(options); // As an admin, the app has access to read and write all data, regardless of Security Rules DatabaseReference ref = FirebaseDatabase .getInstance() .getReference("restricted_access/secret_document"); ref.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { Object document = dataSnapshot.getValue(); System.out.println(document); } }); 
-3
source

All Articles