Skip to content

Log4j Dependencies not being passed to the Benchmark #213

@pavibhai

Description

@pavibhai

I have a project that creates a new log4j2 appender and has log4j dependencies called out in the project

"org.apache.logging.log4j" % "log4j-core" % "2.17.1"
"org.apache.logging.log4j" % "log4j-api" % "2.17.1"
"org.apache.logging.log4j" % "log4j-slf4j-impl" % "2.17.1"
"org.apache.logging.log4j" % "log4j-1.2-api" % "2.17.1"

When I run the benchmarks, I get the following failure

AverageTime(RandomLogBench_perform_jmhTest.java:162)
[info] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[info] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[info] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[info] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[info] 	at org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:470)
[info] 	at org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:453)
[info] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[info] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[info] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[info] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128
[info] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628
[info] 	at java.base/java.lang.Thread.run(Thread.java:829)
[info] Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
[info] 	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
[info] 	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
[info] 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
[info] 	... 15 more

The module does compile and test successfully using the same classes, only the jmh:run sees this failure.

I further explored the class path values

show bench/Jmh/dependencyClasspath
...
[info] * Attributed([snip]/.ivy2/cache/org.apache.logging.log4j/log4j-api/jars/log4j-api-2.17.1.jar)
[info] * Attributed([snip]/.ivy2/cache/org.apache.logging.log4j/log4j-slf4j-impl/jars/log4j-slf4j-impl-2.17.1.jar)
[info] * Attributed([snip]/.ivy2/cache/org.apache.logging.log4j/log4j-1.2-api/jars/log4j-1.2-api-2.17.1.jar)
...
[info] * Attributed([snip]/.ivy2/cache/org.apache.logging.log4j/log4j-core/jars/log4j-core-2.17.1.jar)
...

I tried outputting the classpath from an empty bench and there I don't see the log4j jars in the class path, but I see all other dependencies.

Do I need to do anything special to propagate the log4j libraries to the benchmarks?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions