redhat-developer / redhat-developer/vscode-java

Cannot launch Java project in workspace with several Java projects

Abierto
#4,055 1 comentario 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
TypeScript
Estrellas
2.3k
Forks
546
Merge medio
20 h 1 min
PR fusionados (30 d)
11

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Reproduce el fallo utilizando los repositorios poc y other-poc y sus lanzadores de .vscode/launch.json; después, sigue el stack trace a través de AspectConfiguration.java y del comando workspace-clean de Java Language Server. Se considera terminado cuando cada proyecto se inicia de forma independiente en el mismo workspace sin la NoAspectBoundException, incluso después de limpiar el workspace del servidor de lenguaje.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java, spring-boot
Área
developer-experience, tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.