redhat-developer / redhat-developer/vscode-java

Cannot launch Java project in workspace with several Java projects

Aperta
#4,055 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
TypeScript
Stelle
2.3k
Fork
546
Merge medio
20h 1m
PR unite (30g)
11

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riprodurre il malfunzionamento utilizzando i repository poc e other-poc e i relativi launcher di .vscode/launch.json, quindi seguire lo stack trace attraverso AspectConfiguration.java e il comando workspace-clean di Java Language Server. Il lavoro è completato quando ogni progetto si avvia in modo indipendente nello stesso workspace senza la NoAspectBoundException, anche dopo la pulizia del workspace del language server.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java, spring-boot
Ambito
developer-experience, tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.