redhat-developer / redhat-developer/vscode-java

Cannot launch Java project in workspace with several Java projects

Open
#4,055 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure using the poc and other-poc repositories and their .vscode/launch.json launchers, then follow the stack trace through AspectConfiguration.java and the Java Language Server workspace-clean command. Done means each project launches independently in the same workspace without the NoAspectBoundException, including after cleaning the language-server workspace.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.