Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring integration tests not running because resources are not present in the classpath junit command #155

Closed
qverkk opened this issue Oct 7, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@qverkk
Copy link

qverkk commented Oct 7, 2024

Hey, i'm getting the following error:

...in-neotest-java/lua/neotest-java/build_tool/compiler.lua:113: Error compiling sources: /home/qverkk/Documents/....PATH....java:12: error: package lombok does not exist
import lombok.AllArgsConstructor;

my jdtls is working fine with lombok, are there any requirements to get it working with a project using lombok?

@rcasia
Copy link
Owner

rcasia commented Oct 7, 2024

Hi @qverkk,

It seems like you don''t have the current neotest-java version. The file ./neotest-java/lua/neotest-java/build_tool/compiler.lua does not exist anymore since v0.17.0.

@qverkk
Copy link
Author

qverkk commented Oct 7, 2024

nvm, you're right :D i had to delete my jdtls cache as that was causing troubles. But now i have an issue where i cannot run my spring integration tests, have you tried using the new version for integration tests that override beans etc?

@rcasia
Copy link
Owner

rcasia commented Oct 7, 2024

I did.
Can you share the error? Is it related to compilation parameters? Is it a maven project?

(This might be related #153 (comment))

@qverkk
Copy link
Author

qverkk commented Oct 7, 2024

https://github.com/qverkk/neotest-java-debug

just made a repo where you can reproduce it. The tests run fine through gradle & the intellij runner but i've got issues when running them through neotest-java even on the latest version 0.17.1.

The issue you mentioned doesn't fix the case i have sadly. Here's the stack trace

unique-id: [engine:junit-jupiter]/[class:com.example.demo.DemoApplicationTests]/[method:contextLoads()]
display-name: contextLoads()
=================================
java.lang.IllegalStateException: Failed to load ApplicationContext for [WebMergedContextConfiguration@2c6aed22 testClass = com.example.demo.De
moApplicationTests, locations = [], classes = [com.example.demo.DemoApplication], contextInitializerClasses = [], activeProfiles = [], propert
ySourceDescriptors = [], propertySourceProperties = ["org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTestContextBootstrapper=tr
ue"], contextCustomizers = [org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigura
tionContextCustomizer@2c4d1ac, org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$Disable
ObservabilityContextCustomizer@1f, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@8016782a, org.spring
framework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@f02c231b, org.springframework.boot.test.autoconfigure.web.servle
t.WebDriverContextCustomizer@2dcd168a, [ImportsContextCustomizer@e322ec9 key = [org.springframework.boot.autoconfigure.task.TaskExecutionAutoC
onfiguration, org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.web.servlet.HttpEnco
dingAutoConfiguration, org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration, org.springframework.boot.autoconfigure.c
ontext.MessageSourceAutoConfiguration, org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration, org.springframework.boot.au
toconfigure.jackson.JacksonAutoConfiguration, org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration, org.springframew
ork.boot.test.autoconfigure.web.reactive.WebTestClientAutoConfiguration, org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAuto
Configuration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcAutoConfiguration, org.springframework.boot.autoconfigure.securi
ty.servlet.SecurityAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration, org.springframe
work.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration, org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAu
th2ClientAutoConfiguration, com.example.demo.IntegrationTestConfig, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcSecurityCon
figuration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebClientAutoConfiguration, com.example.demo.BaseSecurityConfig, or
g.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConfiguration, org.springframework.boot.autoconfigure.thymeleaf.Thym
eleafAutoConfiguration, org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration, org.springframework.boot.autoconfigure.jsonb.JsonbA
utoConfiguration, org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration, org.springframework.boot.autoconfigure.web.se
rvlet.WebMvcAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration, org.springframewor
k.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration, org.springframework.boot.autoconfigure.groovy.tem
plate.GroovyTemplateAutoConfiguration, org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration]], org.springframework.boot.t
est.context.filter.ExcludeFilterContextCustomizer@4612b856, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$Dup
licateJsonObjectContextCustomizer@79c7532f, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.te
st.web.reactor.netty.DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory$DisableReactorResourceFactoryGlobalResourcesContextC
ustomizerCustomizer@2826f61, org.springframework.boot.test.context.SpringBootTestAnnotation@9ff721e9], resourceBasePath = "src/main/webapp", c
ontextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null]
        at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.ja
va:180)
        at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:130)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecuti
onListener.java:142)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecut
ionListener.java:98)
        at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:260)
        at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:163)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
        at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
        at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
        at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
        at java.base/java.util.Optional.orElseGet(Optional.java:364)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'filterChain' defined 
in class path resource [com/example/demo/BaseSecurityConfig.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract
=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.example.demo.BaseSecurity
Config; factoryMethodName=filterChain; initMethodNames=null; destroyMethodNames=[(inferred)]; defined in class path resource [com/example/demo
/BaseSecurityConfig.class]] for bean 'filterChain' since there is already [Root bean: class [null]; scope=; abstract=false; lazyInit=null; aut
owireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.example.demo.IntegrationTestConfig; factoryMethodNa
me=filterChain; initMethodNames=null; destroyMethodNames=[(inferred)]; defined in class path resource [com/example/demo/IntegrationTestConfig.
class]] bound.
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.registerBeanDefinition(DefaultListableBeanFactory.java:1017)
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBe
anDefinitionReader.java:277)
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(Configuratio
nClassBeanDefinitionReader.java:144)
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionR
eader.java:120)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor
.java:429)
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProc
essor.java:290)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegis
trationDelegate.java:349)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDele
gate.java:118)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:789)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:607)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
        at org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137)
        at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58)
        at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46)
        at org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1463)
        at org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:553)
        at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137)
        at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:108)
        at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDel
egate.java:225)
        at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.ja
va:152)
        ... 17 more

@rcasia
Copy link
Owner

rcasia commented Oct 7, 2024

Thanks for the repro!

This also happens when using nvim-jdtls.
The command java.project.getClasspaths (this) from eclipse-jdtls is not retrieving the project resources.

I'm adding a patch for that.

@rcasia rcasia changed the title Lombok isn't detected in the newest version Spring integration tests not running because resources are not present in the classpath junit command Oct 7, 2024
@rcasia rcasia added the bug Something isn't working label Oct 7, 2024
rcasia added a commit that referenced this issue Oct 7, 2024
@rcasia
Copy link
Owner

rcasia commented Oct 7, 2024

Should be fixed with #156

@qverkk
Copy link
Author

qverkk commented Oct 7, 2024

Works awesome, thanks! 💯 😄

@qverkk qverkk closed this as completed Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants