Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1803

JMH generated benchmark classes not included in jar



    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.8
    • 2.8.1
    • None


      Some time after the 2.7 release, the JMH benchmarks stopped working. When trying to execute them, this error occurs:

      java.lang.IllegalArgumentException: Benchmark does not match a class
      	at org.openjdk.jmh.util.ClassUtils.loadClass(ClassUtils.java:90)
      	at org.openjdk.jmh.runner.BaseRunner.runBenchmark(BaseRunner.java:198)
      	at org.openjdk.jmh.runner.BaseRunner.runBenchmarks(BaseRunner.java:95)
      	at org.openjdk.jmh.runner.ForkedRunner.run(ForkedRunner.java:51)
      	at org.openjdk.jmh.runner.ForkedMain.main(ForkedMain.java:68)
      Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.perf.jmh.generated.FileAppenderBenchmark_julFile
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
      	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      	at java.lang.Class.forName0(Native Method)
      	at java.lang.Class.forName(Class.java:195)
      	at org.openjdk.jmh.util.ClassUtils.loadClass(ClassUtils.java:72)
      	... 4 more

      When I build the project, the classes generated by JMH under log4j-perf/target/generated-sources/annotations are not included in the shaded benchmarks.jar or in log4j-perf-2.8.1-SNAPSHOT.jar...

      The cause seems to be a change in the master pom:
      the maven-compiler-plugin plugin now has the below section which was not there in 2.7.

      If I take it out and build only log4j-perf, the benchmarks run without error. (But building all modules fails: some problem in log4j-core...)

            <!-- disable annotation processing for first pass -->
            <!-- then do a processing-only pass to generate plugins .dat file -->

      From the log4j-dev mailing list:

      That maven-compiler-plugin config was originally only included in log4j-core in order to allow the PluginProcessor annotation processor to re-run against log4j-core without needing to split it into its own jar. I'm not sure why it's configured for everything now.

      Potentially related: somebody reported on StackOverflow that their custom plugin no longer loads with 2.8.




            rgoers Ralph Goers
            rpopma Remko Popma
            0 Vote for this issue
            2 Start watching this issue