ERROR: Unable to find the resource: /META-INF/BenchmarkList when running JMH with gradle
Asked Answered
S

4

11

I want to benchmark my application using JMH. I am using JMH with gradle as build tool. The github repository is here.

But whenever I run the application com.demo.aerospike.JMHAerospikeSpringData I get below error.

$ gradle run

> Configure project :
Task :jmh Last added: null

> Task :run
JMHAerospikeSpringData is running ...
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:98)
    at org.openjdk.jmh.runner.BenchmarkList.find(BenchmarkList.java:122)
    at org.openjdk.jmh.runner.Runner.internalRun(Runner.java:256)
    at org.openjdk.jmh.runner.Runner.run(Runner.java:206)
    at com.demo.aerospike.JMHAerospikeSpringData.main(JMHAerospikeSpringData.java:47)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command 
'/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I tried different solutions in other stackoverflow but couldn't help.

Any idea what I'm missing.

Strop answered 8/12, 2017 at 5:59 Comment(2)
your repo link is dead. if it's fixed, could you share it?Atelier
@Atelier - I updated the repo.Strop
K
7

I have resolved this problem by adding this dependency to my project:

testAnnotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:$jmhVersion"

next to

testImplementation "org.openjdk.jmh:jmh-core:$jmhVersion"
Korey answered 6/10, 2020 at 8:39 Comment(0)
T
4

implementation 'org.openjdk.jmh:jmh-core:1.33'

annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.33'

just like lombok

Tonetic answered 1/12, 2021 at 14:25 Comment(2)
Welcome to Stack Overflow! While this code may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please edit your answer to add explanations and give an indication of what limitations and assumptions apply. "just like lombok" ist not enough. And stackoverflow.com/editing-helpSitin
Please add some explanation to your answer such that others can learn from itGorton
L
0

Try running without gradle daemon:

gradle --stop
gradle --no-daemon jmh
Loudish answered 14/3, 2018 at 19:2 Comment(1)
Same result for me.Phanerogam
M
0

Not sure how is your project setup like because I can't find com.demo.aerospike.JMHAerospikeSpringData in your repo. Maybe you want to check this project out to get some ideas to try.

https://github.com/eugenp/tutorials/blob/master/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/concurrenthashmap/MapPerformanceComparison.java

Monomial answered 30/6, 2021 at 13:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.