redhat-developer / redhat-developer/vscode-java

Problem with multi-module project: classes not on classpath and unresolved imports

オープン
#4,107 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
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 install works)
  • Other colleagues using VS Code do not experience this issue with this same project structure

Project structure:

Image

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:

  1. Open the project root in VS Code
  2. Wait for indexing to complete
  3. Open a Java class in src or ejbModule of a module
  4. See the classpath error

Thanks for your help!

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

src または ejbModule を含むモジュールを持つマルチモジュール Maven プロジェクトを使用してプロジェクトルートから再現し、その後 Java Language Server の出力で報告された missing-resource パスを確認します。設定されているソースパスとモジュールのレイアウトを比較し、影響を受けるクラスを開いて結果を検証します。完了条件は、クラスがプロジェクトの classpath 上にあり、import が解決され、classpath の診断が表示されなくなることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。