redhat-developer / redhat-developer/vscode-java

Cannot launch Java project in workspace with several Java projects

Aberta
#4,055 1 comentário 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Linguagem predominante
TypeScript
Estrelas
2.3k
Forks
547
Merge médio
20h 1min
PRs com merge (30d)
11

Descrição

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.

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Reproduza a falha usando os repositórios poc e other-poc e seus launchers de .vscode/launch.json; em seguida, acompanhe o stack trace por AspectConfiguration.java e pelo comando workspace-clean do Java Language Server. Considera-se concluído quando cada projeto inicia independentemente no mesmo workspace sem a NoAspectBoundException, inclusive após limpar o workspace do servidor de linguagem.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
java, spring-boot
Domínio
developer-experience, tooling
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.