Copy link to clipboard
Copied
In ColdFusion, we generated an OAuth token to send notifications. However, due to the limitations of FCM HTTP v1, we cannot send notifications to multiple devices at once. To overcome this, we found a solution: using a TOPIC to subscribe device tokens. We attempted to subscribe multiple tokens using the FCM SDK.
We included all the necessary dependent JAR files for subscribing, but it throws an error.
We are using ColdFusion 2023.
Here’s a simplified version of what we’re trying:
<cfset FirebaseAdmin = createObject("java", "com.google.firebase.FirebaseApp") /> <cfset FirebaseMessaging = createObject("java", "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin) />
<cfset registrationTokens = ["token1", "token2", "token3"] />
<cfset response = FirebaseMessaging.subscribeToTopic(registrationTokens, topic) />
However, we’re getting an error when trying to subscribe the tokens.
Could anyone please provide a solution?
Copy link to clipboard
Copied
Can you share all the details of the error?
Copy link to clipboard
Copied
Getting below error
com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor
We searched for this soltuion. It is something related to guava jar file. But we tried with almost all the version guava jar file. But still shows the error.
Copy link to clipboard
Copied
The error is not related to ColdFusion. I agree with you that it is an error coming from Google's Guava library.
What is the name/version of the Guava Jar files you are using? You could download and copy the latest versions of the Jar files to ColdFusion's lib directory, and see if that helps.
Copy link to clipboard
Copied
I have used guava-33.3.0-jre.jar library. It's a latest version. Also tried with older version.
Copy link to clipboard
Copied
As an example, I have just done the following test:
<cfset FirebaseAdmin = createObject("java", "com.google.firebase.FirebaseApp")>
<cfdump var="#FirebaseAdmin#">​
Copy link to clipboard
Copied
<cfset FirebaseAdmin = createObject("java", "com.google.firebase.FirebaseApp") />
<cfset FirebaseMessaging = createObject("java", "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin) />
<cfset registrationTokens = ["token1", "token2", "token3"] />
<cfset response = FirebaseMessaging.subscribeToTopic(registrationTokens, topic) />
We know that it's working and creating the object for this <cfset FirebaseMessaging = createObject("java", "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin) /> when we are caliing FirebaseMessaging.subscribeToTopic(registrationTokens, topic) method in response we are getting HTTP 500 :: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor
We want soltuion for this.
Copy link to clipboard
Copied
"com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin) /> when we are caliing FirebaseMessaging.subscribeToTopic(registrationTokens, topic) method in response we are getting HTTP 500 :: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor
By @Piyush32537068gy36
As I said before, given that your question is about Firebase Messaging, you would probably be better off asking it in a Google Firebase forum.
In any case, shouldn't that line be "com.google.firebase.messaging.FirebaseMessaging").getInstance()" instead of "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin)"? I ask because I can see the following in https://firebase.google.com/docs/cloud-messaging/cpp/topic-messaging :
Your code passes the variable topic as an argument to subscribeToTopic. Question: is the value of topic a string?
Copy link to clipboard
Copied
Thanks for the reply. I will check it in detail and let you know
Copy link to clipboard
Copied
Test:
What do you get when you modify the code as follows?
<cfset FirebaseAdmin = createObject("java", "com.google.firebase.FirebaseApp") />
<cfset FirebaseMessaging = createObject("java", "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin) />
<cfset registrationTokens = ["token1", "token2", "token3"] />
<!--- Temporary test code --->
<cfdump var="#FirebaseMessaging#" label="FirebaseMessaging" abort="true">
<cfset response = FirebaseMessaging.subscribeToTopic(registrationTokens, topic) />
If a variable is dumped, please share a printscreen of it.
Copy link to clipboard
Copied
Plese refer the attach screenshot
Copy link to clipboard
Copied
The screenshot suggests that the HTTP 500 error is caused by the line
<cfset FirebaseMessaging = createObject("java", "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin) />
So, what happens when you run the following test?
<cfset FirebaseAdmin = createObject("java", "com.google.firebase.FirebaseApp") />
<cfset FirebaseMessaging = createObject("java", "com.google.firebase.messaging.FirebaseMessaging").getInstance() />
<cfset registrationTokens = ["token1", "token2", "token3"] />
<!--- Temporary test code --->
<cfdump var="#FirebaseMessaging#" label="FirebaseMessaging" abort="true">
<cfset response = FirebaseMessaging.subscribeToTopic(registrationTokens, topic) />
Copy link to clipboard
Copied
Will it work on Coldfusion 2021? When we execute the code below
we got the error "Object instantiation exception.". please advise
Copy link to clipboard
Copied
Yes, it work in Coldfusion 2021.
But you wana download this firebase-admin-9.3.0 jar file and paste into coldfusion\lib folder
Copy link to clipboard
Copied
Thanks. I downloaded the above firebase-admin-9.3.0 jar file and got the below error
Then I got a fix to add dependency jar files so i added below jar files
Then i got the response as
Thanks @BKBK. It helps me a lot.
Copy link to clipboard
Copied
Hi @jibinanto40792294 , thanks for the update.
Piyush's problem is different from yours. As a result, it is confusing to have two separate discussions here. Could you therefore continue your discussion in your own thread?
That will help anyone who comes here to look for answers to a question similar to yours.