redhat-developer / redhat-developer/vscode-java
Problem with multi-module project: classes not on classpath and unresolved imports
还没有人认领这个 Issue。
- 主要语言
- TypeScript
- 星标
- 2.3k
- 派生
- 547
- 平均合并
- 20 小时 1 分钟
- 30 天内合并 PR
- 11
描述
VS Code Version:
- Version: 1.101.2 (user setup)
- Commit: 2901c5ac6db8a986a5666c3af51ff804d05af0d4
- Date: 2025-06-24T20:27:15.391Z
- Electron: 35.5.1
- ElectronBuildId: 11727614
- Chromium: 134.0.6998.205
- Node.js: 22.15.1
- V8: 13.4.114.21-electron.0
Extensions:
- Extension Pack for Java | Microsoft | microsoft.com | 0.29.2
- Language Support for Java(TM) by Red Hat | Red Hat | redhat.com | 1.43.1
- Debugger for Java | Microsoft | microsoft.com | 0.58.2
- Test Runner for Java | Microsoft | microsoft.com | 0.43.1
- Maven for Java | Microsoft | microsoft.com | 0.44.0
- Project Manager for Java | Microsoft | microsoft.com | 0.24.1
OS:
Windows 11 Business
Java Version:
openjdk version "11.0.10" 2021-01-19
Problem Description:
In a multi-module Maven project with modules that use src or ejbModule as the source folder (not the standard Maven structure), the Java Language Server does not recognize the classes as part of the classpath and shows the error:
<ClassName>.java is not on the classpath of project <project>, only syntax errors are reported.
Some classes fail to resolve imports and show red underlines.
However, if I run mvn clean install, the project and all submodules compile correctly.
What I've already tried:
- Added
"java.project.sourcePaths": ["src"]or["ejbModule"]in the various modules - Cleaned and rebuilt the Java workspace
- Deleted
.vscode,.project,.classpath - Reloaded the window and restarted VS Code
- All dependencies are correctly resolved by Maven (
mvn clean installworks) - Other colleagues using VS Code do not experience this issue with this same project structure
Project structure:
Logs from Output → Java Language Server:
!ENTRY org.eclipse.jdt.ls.core 4 0 2025-07-08 15:39:31.350 !MESSAGE _/oamui/src/com/imnet/oam/web [in oam.ng_d235b972] does not exist !STACK 1 Java Model Exception: Error in Java Model (code 969): _/oamui/src/com/imnet/oam/web [in oam.ng_d235b972] does not exist at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:548) at org.eclipse.jdt.internal.core.PackageFragmentRoot.getUnderlyingResource(PackageFragmentRoot.java:768) at org.eclipse.jdt.internal.core.PackageFragment.getUnderlyingResource(PackageFragment.java:417) at org.eclipse.jdt.internal.core.Openable.getUnderlyingResource(Openable.java:333) at org.eclipse.jdt.internal.core.CompilationUnit.getUnderlyingResource(CompilationUnit.java:1095) at org.eclipse.jdt.ls.core.internal.handlers.BaseDiagnosticsHandler.collectNonJavaProblems(BaseDiagnosticsHandler.java:198) at org.eclipse.jdt.ls.core.internal.handlers.BaseDiagnosticsHandler.endReporting(BaseDiagnosticsHandler.java:149) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.reportProblems(ReconcileWorkingCopyOperation.java:157) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:126) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:751) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:816) at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1431) at org.eclipse.jdt.ls.core.internal.handlers.BaseDocumentLifeCycleHandler.publishDiagnostics(BaseDocumentLifeCycleHandler.java:338) at org.eclipse.jdt.ls.core.internal.handlers.BaseDocumentLifeCycleHandler.publishDiagnostics(BaseDocumentLifeCycleHandler.java:301) at org.eclipse.jdt.ls.core.internal.handlers.BaseDocumentLifeCycleHandler$PublishDiagnosticJob.run(BaseDocumentLifeCycleHandler.java:798) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) !SUBENTRY 1 org.eclipse.jdt.core 4 969 2025-07-08 15:39:31.350 !MESSAGE _/oamui/src/com/imnet/oam/web [in oam.ng_d235b972] does not exist
Steps to reproduce:
- Open the project root in VS Code
- Wait for indexing to complete
- Open a Java class in
srcorejbModuleof a module - See the classpath error
Thanks for your help!
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从项目根目录开始,使用一个包含带有 src 或 ejbModule 的模块的多模块 Maven 项目重现问题,然后检查 Java Language Server 的输出以查找报告的缺失资源路径。将已配置的源路径与模块布局进行比较,并通过打开受影响的类来验证结果。完成的标准是类位于项目 classpath 上,导入能够解析,并且 classpath 诊断不再出现。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100