apache/dubbo

[Bug] When running a Dubbo 3.3.6 application on JDK 25, application startup fails with `NoClassDefFoundError: com/google/gson/JsonSyntaxException`.

Open

#16,295 opened on May 28, 2026

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Java (41,524 stars) (26,453 forks)batch import
help wanted

Description

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues and found no similar issues.

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

When running a Dubbo 3.3.6 application on JDK 25, application startup fails with NoClassDefFoundError: com/google/gson/JsonSyntaxException.

The application does not depend on Gson and does not intend to use Gson as Dubbo's JSON implementation. Dubbo's default JSON implementation should be fastjson2, and the same application starts normally on JDK 21.

Steps to reproduce this issue

  Caused by: java.lang.NoClassDefFoundError: com/google/gson/JsonSyntaxException
      at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:2985)
      at java.base/java.lang.Class.getConstructor0(Class.java:3180)
      at java.base/java.lang.Class.getConstructor(Class.java:2199)
      at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:623)
      at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1111)
      at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1142)
      at org.apache.dubbo.common.utils.JsonUtils.loadExtensions(JsonUtils.java:81)
      at org.apache.dubbo.common.utils.JsonUtils.createJsonUtil(JsonUtils.java:52)
      at org.apache.dubbo.common.utils.JsonUtils.getJson(JsonUtils.java:40)
      at org.apache.dubbo.common.utils.JsonUtils.toJavaObject(JsonUtils.java:106)
      at org.apache.dubbo.registry.client.metadata.store.MetaCacheManager.toValueType(MetaCacheManager.java:73)

Expected behavior

Dubbo should not fail startup because the optional Gson dependency is absent, especially when Gson is not selected as the JSON implementation.

If fastjson2 is the default/preferred JSON implementation, Dubbo should be able to select it without forcing ServiceLoader to instantiate or inspect the Gson implementation class.

Actual behavior

On JDK 25, ServiceLoader appears to inspect the Gson JSON implementation during Dubbo JSON SPI loading. Since Gson is not on the classpath, this causes startup failure before Dubbo can use fastjson2.

Workaround

Setting the following system property avoids the issue:

System.setProperty("dubbo.json-framework.prefer", "fastjson2");

Environment

  • Dubbo version: 3.3.6
  • JDK version: 25
  • Works on: JDK 21
  • Registry: Nacos
  • Gson dependency: not present

What you expected to happen

Intercept exceptions, skip processing

Anything else

No response

Do you have a (mini) reproduction demo?

  • Yes, I have a minimal reproduction demo to help resolve this issue more effectively!

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

Contributor guide