google-http-client-jackson2 cannot be excluded even when a JsonFactory is configured via FirebaseOptions
Maintainer antworten meist innerhalb von 4 Tagen
@lahirumaramba arbeitet bereits daran.
Seit 29.9.2026.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
Rechercherichtung
Beginnen Sie mit ApiClientUtils.java und dem im Stacktrace gezeigten Pfad FirebaseMessagingClientImpl.fromApp. Reproduzieren Sie anschließend die Maven-Exclusion und den Fehler beim ersten Senden mithilfe der FirebaseOptions-Konfiguration aus dem Issue. Stellen Sie fest, ob die konfigurierte JsonFactory während der Initialisierung der Request Factory oder der Credentials umgangen wird. Die Aufgabe ist erfüllt, wenn Jackson2 für diese Konfiguration nicht mehr erforderlich ist oder die harte Anforderung dokumentiert ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe your environment
- Operating System version: Amazon Linux 2023 (AWS ECS Fargate), also reproduced on macOS 15
- Firebase SDK version: 9.7.1 (the code in question is unchanged on
v9.10.0) - Library version:
com.google.firebase:firebase-admin:9.7.1, Java 25, Spring Boot 4.1 - Firebase Product: messaging (FCM only — no Firestore, Storage, Realtime Database or FirebaseAuth)
Describe the problem
google-http-client-jackson2 is a hard runtime requirement, and FirebaseOptions.setJsonFactory(...) is not sufficient to avoid it. Excluding the artifact still throws ClassNotFoundException on the first FCM send, which forces ~580 KB of Jackson 2 into deployments whose Firebase usage is otherwise entirely Gson-based.
Steps to reproduce:
- Configure
FirebaseOptionswith an explicit transport and JSON factory (see code below). - Exclude
com.google.http-client:google-http-client-jackson2from the build. - Start the application — startup succeeds, both
FirebaseAppinstances initialize fine. - Send a message via
FirebaseMessaging.sendEachForMulticast(...)— fails:
java.lang.ClassNotFoundException: com.google.api.client.json.jackson2.JacksonFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:490)
at com.google.firebase.messaging.FirebaseMessagingClientImpl.fromApp(FirebaseMessagingClientImpl.java:193)
at com.google.firebase.messaging.FirebaseMessaging$7.get(FirebaseMessaging.java:637)
at com.google.firebase.messaging.FirebaseMessaging$7.get(FirebaseMessaging.java:634)
at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:201)
at com.google.firebase.messaging.FirebaseMessaging.getMessagingClient(FirebaseMessaging.java:519)
at com.google.firebase.messaging.FirebaseMessaging.sendOpForSendResponse(FirebaseMessaging.java:253)
The failure only surfaces on the first send, because getMessagingClient() is lazy and memoized — so a startup smoke test does not catch it.
The configured factory does appear to be honoured for messaging itself; something in the request-factory / credentials initialization path loads JacksonFactory regardless of configuration.
Relevant Code:
FirebaseOptions.builder()
.setHttpTransport(new NetHttpTransport())
.setJsonFactory(GsonFactory.getDefaultInstance())
.setCredentials(GoogleCredentials.fromStream(serviceAccountJson))
.build();
We use FCM only, and prune the parts of the SDK we do not need:
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.cloud</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Why this matters
After that pruning, everything remaining is Gson-based. Credentials come from GoogleCredentials, and google-auth-library-oauth2-http uses GsonFactory (OAuth2Utils.JSON_FACTORY), which brings google-http-client-gson + gson 2.13.2 (283 KB) in at compile scope. Despite that, we must also ship:
+- com.google.http-client:google-http-client-jackson2:jar:runtime
| \- com.fasterxml.jackson.core:jackson-core:jar:2.21.4:runtime <- 580 KB, sole consumer
Jackson 2 is roughly twice the size of the Gson stack it duplicates, and nothing else on our classpath requires it.
This is amplified on Spring Boot 4.x, which moved to Jackson 3 (tools.jackson). Applications now carry both Jackson generations side by side, with Jackson 2 present solely to satisfy firebase-admin.
The blocker cited in the code may be stale
public static JsonFactory getDefaultJsonFactory() {
// Force using the Jackson2 parser for this project for now. Eventually we should switch
// to Gson, but there are some issues that are preventing this migration at the moment.
// See https://github.com/googleapis/google-api-java-client/issues/1779 for details.
return JacksonFactory.getDefaultInstance();
}
googleapis/google-api-java-client#1779 was closed on 2021-04-29 as triage rather than fixed, splitting into three sub-bugs. Per a 2023-03-03 comment on that issue from a Gson maintainer:
- floating-point serialization — fixed
- parser leniency — addressed by Gson's strict-parsing API
- exception handling — tracked in googleapis/google-http-java-client#1353, which is a documentation issue
ApiClientUtils.java does not appear to have been revisited on this point since (subsequent commits touch transports and copyright headers).
Ask
Any of these would help:
- Make the Jackson2 dependency genuinely optional when a
JsonFactoryis supplied viaFirebaseOptions. - Switch the default to
GsonFactory, if the 2021 blockers no longer apply. - Failing both, document that
google-http-client-jackson2is a hard requirement — that alone would save others the investigation.
- Vorherrschende Sprache
- Java
- Sterne
- 620
- Forks
- 306
- Ø Merge
- 4 T. 7 Std.
- Gemergte PRs (30 T.)
- 13
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus firebase/firebase-admin-java
-
[BUG] RemoteConfig unit tests fail in non-English (e.g., Korean) Locales due to Date ParsingEvtl. vergeben @rathovarun1032 hat das vor 205 Tagen übernommen. Offenapi: remoteconfig
firebase/firebase-admin-java#1196 · 1 Kommentar · 2 zugewiesene Personen ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Auth list tenants is not pageableEvtl. vergeben @siddharthmohan619-eng hat das vor 210 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
firebase/firebase-admin-java#1192 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 4 Tagen
-
needs-triage type: feature request
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
firebase/firebase-admin-java#1149 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 4 Tagen
-
needs-triage type: feature request
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 45/100
firebase/firebase-admin-java#1142 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Opentelemetry-context conflict, please bump google-api-client dependencyEvtl. wieder frei @lahirumaramba hat das vor 336 Tagen übernommen, und es ist kein Pull Request offen. Offenapi: core
firebase/firebase-admin-java#1138 · 8 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 4 Tagen
Alle Issues in firebase/firebase-admin-java
Ähnliche Issues
-
[destination-snowflake] Custom domains rejected unlike source connectionsEvtl. vergeben @kuza55 hat das heute übernommen. Offenautoteam community connectors/destination/snowflake team/use
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
area-dashboard
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
component/operate kind/feature-request
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
Forge coverage prompts carry text the agent cannot act onEvtl. vergeben @graalvmbot hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
oracle/graalvm-reachability-metadata#10572 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[CI] Core CI doesn't run for changes to amoro-format-lance (and amoro-web)Evtl. vergeben @MarkAlex1234 hat das heute übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 2 Tagen