idea-jmh-plugin: Scala: Unable to find the resource: /META-INF/BenchmarkList
idea ultimate 14.1.2 + scala plugin 1.4.15 + jmh plugin 1.0.1
I have an sbt project opened in IDEA. When I run one benchmark method or all methods in a class I get this error:
Exception in thread "main" java.lang.RuntimeException: ERROR: Unable to find the resource: /META-INF/BenchmarkList
at org.openjdk.jmh.runner.AbstractResourceReader.getReaders(AbstractResourceReader.java:96)
at org.openjdk.jmh.runner.BenchmarkList.find(BenchmarkList.java:104)
at org.openjdk.jmh.runner.Runner.internalRun(Runner.java:250)
at org.openjdk.jmh.runner.Runner.run(Runner.java:202)
at org.openjdk.jmh.Main.main(Main.java:69)
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 22
- Comments: 26 (3 by maintainers)
Commits related to this issue
- upgrading jmh to 1.25 Following instructions here: https://github.com/artyushov/idea-jmh-plugin/issues/13#issuecomment-687805558 — committed to dfa1/graphql-java by dfa1 4 years ago
- upgrading jmh to 1.25 Following instructions here: https://github.com/artyushov/idea-jmh-plugin/issues/13#issuecomment-687805558 — committed to aleksandarsusnjar/graphql-java by dfa1 4 years ago
Hi!
Do you have
org.openjdk.jmh:jmh-generator-annprocess
on your classpath? If yes, is annotation processing enabled in your IDE? You can find the checkbox underPreferences -> Build, Execution, Deployment -> Compiler -> Annotation Processors
The solution for me was to use
testAnnotationProcessor
in Gradle 6 build.gradle:instead of
Mind that my setup is a bit non-standard - I run JMH from JUnit. Still, this solved missing BenchmarkList problem.
Also I don’t use jmh-gradle-plugin, only those two dependencies from above are enough to integrate JMH to JUnit.
If you’re using the jmh-gradle-plugin you just need to have all of the following in your dependencies block:
Then I was able to run the test from within the IDE (I’m using IntelliJ).
Seconding this, changing to
testAnnotationProcessor
worked for me to fix the same issue.Adding dependency “org.openjdk.jmh:jmh-generator-annprocess” solved an issue for me.
It seems like sometimes I can get this to work, but I’m not sure what I have been doing that is making it work. Just a minute ago, I ran
./gradlew --stacktrace jmh
and it failed, and then I just ran it again after adding--info
and it worked. I also setverbosity = 'EXTRA'
, although I’m not certain when I did that. I’ve seen this happen a few times, where it just works a few times in a row, and then it starts getting this error again, without any changes.I also notice that when I searched for BenchmarkList again, I found it in additional places:
I then re-ran the same command and it worked again.
I am using IntelliJ IDEA Ultimate with a plain old Java Module (no Maven or Gradle). I downloaded the JHM suite as a dependency, I made sure that all of the above suggestions are done on my side. Most importantly:
Tried building, compiling, cleaning, running, changing the configuration, running again with no luck.
Then I added the fully qualified name of the annotation processor that has to run, and it worked:
org.openjdk.jmh.generators.BenchmarkProcessor
You do this under: Build, Execution, Deployment > Compiler > Annotation Processors (see screenshot).
I wonder if you want to add some business logic to the module to not just offer to enable AP, but also add the FQN?
I added this to my build.gradle and solved the problem, I can run from IntelliJ
I am seeing this problem, and I can’t find a workaround.
Here is my build.gradle:
Here’s the output when I run, forcing tasks to run:
I see the raw file at:
Here’s an elided listing of the jar contents:
What can I do to resolve this?
Seems like you have an inner module
devicegraph-benchmarks
and outerdevicegraph
. When jmh configuration is created outer module is chosen automatically, but it doesn’t have dependency on annprocess. Currently I would suggest adding this dependency if it does not cause too much problem to you, but in general I should implement choosing the module in run configuration. I’ll do my best, but still not sure that will find time for that quite soon.