← All tasks
javaapache/dubbo #15674Not a task: not reproduced

[Bug] ClassNotFoundException was thrown when compile with dubbo-native and dubbo-maven-plugin

envgap__apache__dubbo-15674

Original GitHub issue ↗Opened 2025-09-07

01 / FAILURE SIGNATURE

As reported upstream

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
Not a benchmark task.
  • No curated issue-specific recipe or verified environment fix is available.

02 / ENVIRONMENT RECIPE

Base commit
Not freshly verified
Manifest
pom.xml
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

apache/dubbo #15674 · read the original issue
### Pre-check

- [x] I am sure that all the content I provide is in English.


### Search before asking

- [x] I had searched in the [issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no similar issues.


### Apache Dubbo Component

Java SDK (apache/dubbo)

### Dubbo Version

dubbo 3.3.5,java 17,mac 15.6

### Steps to reproduce this issue

在非 spring 环境,项目在 jvm 运行时下是正常的。。。使用 dubbo-native + dubbo-maven-plugin (原生编译时)出现以下异常。

* 异常

```
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
        at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3373)
        at java.base/java.lang.Class.getConstructors(Class.java:2060)
        at org.apache.dubbo.aot.generate.ReflectConfigMetadataRepository.buildTypeDescriberWithConstructor(ReflectConfigMetadataRepository.java:74)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
        at org.apache.dubbo.aot.generate.ReflectConfigMetadataRepository.registerSpiExtensionType(ReflectConfigMetadataRepository.java:45)
        at org.apache.dubbo.aot.generate.AotProcessor.main(AotProcessor.java:62)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        ... 14 more
```

* 截图

<img width="2038" height="1232" alt="Image" src="https://github.com/user-attachments/assets/cf730c0f-cf54-405f-a97a-8365523064cc" />

### What you expected to happen

希望 dubbo-native java 原生编译,不要硬性依赖 spring 相关接口。。。希望去除依赖,或者通过适配。。。希望在非 spring 环境下,也能使用。

### Anything else

_No response_

### 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

- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]

Issue-specific recipe and runtime smoke command require review against the complete issue and repository.

Legacy reproduction is generic install-only; match the actual issue failure before admission.