Closed jeremyyang15 closed 9 months ago
I don't think this has anything to do with ArchUnit per se. I tested ArchUnit in combination with logback-classic:1.4.12
and couldn't reproduce any problem.
I could however reproduce the problem using the mentioned Spring Boot Starter. From what I see (analysing the dependency tree) the problem has nothing to do with ArchUnit, but that the default Spring Boot Starter Logging manages all the logback
dependencies to 1.4.11
. But this leads to the transitive dependency logback-classic -> logback-core
to be down-managed to 1.4.11
even though logback-classic
is version 1.4.12
. But logback-classic:1.4.12
and logback-core:1.4.11
seem to be incompatbile, more precisely in logback-core:1.4.11
there is no method Loader.systemClassloaderIfNull
which logback-classic:1.4.12
tries to call, which leads to your exception (AFAIS).
I explicitly declared logback-core:1.4.12
as dependency as well and the problem vanished. Can you try that?
Hi @codecholeric , thanks for your reply. it works with logback-core upgrade. My bad, I thought I have upgraded the core as well. All good now. thanks.
Hi, I am using spring-boot-starter-parent 3.1.6, which has some vulnerabilities from logback-classic lib, so I upgraded logback-classic to 1.4.12. However, after upgrade, when I run maven build, I got below errors.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.2.2:test (default-test) on project mr-config-server: [ERROR] [ERROR] Please refer to /Users/jeremyyang/Documents/medi/code/mr-config-server/target/surefire-reports for the individual test results. [ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream. [ERROR] There was an error in the forked process [ERROR] TestEngine with ID 'archunit' failed to discover tests [ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process [ERROR] TestEngine with ID 'archunit' failed to discover tests [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:631) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:285) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:250) [ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1240) [ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1089) [ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:905) [ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:370) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:351) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:171) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:163) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) [ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
detail error is `# Created at 2023-12-07T14:15:59.400 org.junit.platform.commons.JUnitException: TestEngine with ID 'archunit' failed to discover tests at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160) at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:132) at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:107) at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:78) at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:110) at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:78) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.discover(DefaultLauncherSession.java:81) at org.apache.maven.surefire.junitplatform.LazyLauncher.discover(LazyLauncher.java:50) at org.apache.maven.surefire.junitplatform.TestPlanScannerFilter.accept(TestPlanScannerFilter.java:52) at org.apache.maven.surefire.api.util.DefaultScanResult.applyFilter(DefaultScanResult.java:87) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.scanClasspath(JUnitPlatformProvider.java:142) at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:122) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385) at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162) at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495) Caused by: java.lang.NoSuchMethodError: 'java.lang.ClassLoader ch.qos.logback.core.util.Loader.systemClassloaderIfNull(java.lang.ClassLoader)' at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:73) at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:66) at ch.qos.logback.classic.spi.LogbackServiceProvider.initializeLoggerContext(LogbackServiceProvider.java:52) at ch.qos.logback.classic.spi.LogbackServiceProvider.initialize(LogbackServiceProvider.java:41) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:195) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:182) at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:490) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:476) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:425) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:451) at com.tngtech.archunit.junit.internal.ArchUnitTestDescriptor.(ArchUnitTestDescriptor.java:50)
at com.tngtech.archunit.junit.internal.ArchUnitTestEngine.lambda$resolveRequestedClasses$3(ArchUnitTestEngine.java:126)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
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.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
at com.tngtech.archunit.junit.internal.ArchUnitTestEngine.resolveRequestedClasses(ArchUnitTestEngine.java:126)
at com.tngtech.archunit.junit.internal.ArchUnitTestEngine.discover(ArchUnitTestEngine.java:88)
at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152)
... 15 more
`
Is there any compatibility issue with new version logback-classic?