riva riva - 25 days ago 23
Java Question

JMH Unable to find the resource: /META-INF/BenchmarkList

I'm not able to run simple JMH benchmark inside eclipse.
Maven dependencies:

<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.12</version>
</dependency>


Java code:

public class BTest {
@Benchmark
public void test() {
// todo
}

public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(BTest.class.getSimpleName())
.build();

new Runner(opt).run();
}
}


Result of run:


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:256) at
org.openjdk.jmh.runner.Runner.run(Runner.java:206) at
com.test.BTest.main(BTest.java:24)


Maybe the problem is, that I'm running it from eclipse.

Thanks for any help.

Answer

Finally found it out. There was a problem with missing maven plugin

<plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>run-benchmarks</id>
                            <phase>integration-test</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                            <configuration>
                                <classpathScope>test</classpathScope>
                                <executable>java</executable>
                                <arguments>
                                    <argument>-classpath</argument>
                                    <classpath />
                                    <argument>org.openjdk.jmh.Main</argument>
                                    <argument>.*</argument>
                                </arguments>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
Comments