redhat-developer / redhat-developer/vscode-java

Cannot launch Java project in workspace with several Java projects

未关闭
#4,055 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
TypeScript
星标
2.3k
派生
546
平均合并
20 小时 1 分钟
30 天内合并 PR
11

描述

Hello, I’m experiencing a very frustrating problem with the Visual Studio Code launcher for my Java/Spring boot/AspectJ/Gradle multi module project.

Description

All is working fine if my project is the only project in my VScode workspace. But as soon as I have several projects in the workspace, I get errors related to Aspects when running my project.

Steps to reproduce

After wasting my time on trying to make my project work, I could finally reproduce the problem on 2 minimalistic projects. Here is how to proceed:

  1. Use a new empty workspace

  2. Clone the 2 following projects from command line (not in vscode):

  • https://github.com/pelmato/poc.git
    Project "poc" is a Gradle multi-module project with
    - module "poc-a": a spring boot project with a simple endpoint.
    - module "poc-b": a simple gradle module which defines and use a basic Aspect.
    Please also note that poc-a needs to set an injected service into poc-b aspect.
  • https://github.com/pelmato/other-poc.git
    Project "other-poc" is a simple copy of "poc" with package name changed.
  1. Import the "poc" project into the vscode workspace.

  2. Run and Debug the "poc" project (using the "POC" launcher from poc/.vscode/launch.json).

So far so good.

  1. Stop the POC debug session.

  2. Import the other-poc project into the vscode workspace.

  3. Run and Debug the "other-poc" project (using the "Other POC" launcher from other-poc/.vscode/launch.json).

Expected: the other-project is run.
Observed: exception:

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2025-05-22T10:11:17.833+02:00 ERROR 90273 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aspectConfiguration': Invocation of init method failed
        at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:222) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:429) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1810) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:607) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:371) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1221) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1187) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1122) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:987) ~[spring-context-6.2.6.jar:6.2.6]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627) ~[spring-context-6.2.6.jar:6.2.6]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.4.5.jar:3.4.5]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:753) ~[spring-boot-3.4.5.jar:3.4.5]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-3.4.5.jar:3.4.5]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) ~[spring-boot-3.4.5.jar:3.4.5]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1362) ~[spring-boot-3.4.5.jar:3.4.5]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1351) ~[spring-boot-3.4.5.jar:3.4.5]
        at fr.test.poc.poca.PocApplication.main(PocApplication.java:9) ~[main/:na]
Caused by: org.aspectj.lang.NoAspectBoundException: Exception while initializing fr.test.poc.pocb.aspect.PocAspect: java.lang.NoSuchMethodException: fr.test.poc.pocb.aspect.PocAspect.aspectOf()
        at org.aspectj.lang.Aspects.aspectOf(Aspects.java:50) ~[aspectjrt-1.9.24.jar:1.9.24]
        at fr.test.poc.poca.configuration.AspectConfiguration.configureAspect(AspectConfiguration.java:20) ~[main/:na]
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
        at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMethod.invoke(InitDestroyAnnotationBeanPostProcessor.java:457) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:401) ~[spring-beans-6.2.6.jar:6.2.6]
        at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:219) ~[spring-beans-6.2.6.jar:6.2.6]
        ... 20 common frames omitted
Caused by: java.lang.NoSuchMethodException: fr.test.poc.pocb.aspect.PocAspect.aspectOf()
        at java.base/java.lang.Class.getDeclaredMethod(Class.java:2848) ~[na:na]
        at org.aspectj.lang.Aspects.getSingletonOrThreadAspectOf(Aspects.java:134) ~[aspectjrt-1.9.24.jar:1.9.24]
        at org.aspectj.lang.Aspects.aspectOf(Aspects.java:45) ~[aspectjrt-1.9.24.jar:1.9.24]
        ... 26 common frames omitted
  1. Call the command "Java: Clean Java Language Server Workspace"

Now both projects have the same error.

  1. Remove "other-poc" project and re-clean the Java Language Server Workspace. Now the error is gone.

Any help would be greatly appreciated.

PS: tested on version 1.42.0, but also affects previous versions.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用 poc 和 other-poc 仓库及其 .vscode/launch.json 启动器重现该故障,然后通过 AspectConfiguration.java 和 Java Language Server 的 workspace-clean 命令跟踪堆栈跟踪。完成的标准是每个项目都能在同一 workspace 中独立启动且不会出现 NoAspectBoundException,包括清理 language server workspace 之后。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, spring-boot
领域
developer-experience, tooling
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。