Forking with mvn exec:java
Guillaume Drouet
guidrouet at gmail.com
Mon Jul 28 08:06:59 UTC 2014
Hi,
My main:
final Options opt = new OptionsBuilder()
.include(".*" + JmhBenchmark.class.getSimpleName() + ".*")
.forks(1)
.verbosity(VerboseMode.EXTRA)
.warmupIterations(5)
.measurementIterations(5)
.threads(4)
.build();
new Runner(opt).run();
My command line: mvn clean install exec:java
So yes I think exec-maven-plugin does not use the jar file and specfies
each dependency jar in -classpath argument.
# VM invoker: c:\Program Files (x86)\Java\jdk1.6.0_31\jre\bin\java.exe
# VM options: -Xverify:none
-Xbootclasspath/p:D:\Dev\EVL\tools\JRebel\jrebel-bootstrap.jar;D:\Dev\EVL\tools\JRebel\jrebel.jar
-Drebel.jersey_plugin=true -Xms256m -XX:MaxPermSize=192m -Xmx1024m
-Dclassworlds.conf=d:/Dev/Transverse/tools/apache-maven/3.2.1/bin/m2.conf
-Dmaven.home=d:/Dev/Transverse/tools/apache-maven/3.2.1
# Warmup: 5 iterations, 1 s each
# Measurement: 5 iterations, 1 s each
# Threads: 4 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark:
com.github.gdrouet.scannerbenchmark.JmhBenchmark.scanSubtypeWithAnnotationDetector
Forking 1 times using command: [c:\Program Files
(x86)\Java\jdk1.6.0_31\jre\bin\java.exe, -Xverify:none,
-Xbootclasspath/p:D:\Dev\EVL\tools\JRebel\jrebel-bootstrap.jar;D:\Dev\EVL\tools\JRebel\jrebel.jar,
-Drebel.jersey_plugin=true, -Xms256m, -XX:MaxPermSize=192m, -Xmx1024m,
-Dclassworlds.conf=d:/Dev/Transverse/tools/apache-maven/3.2.1/bin/m2.conf,
-Dmaven.home=d:/Dev/Transverse/tools/apache-maven/3.2.1,
-XX:CompileCommandFile=c:\temp\jmh1640929078555797577compilecommand, -cp,
"d:/Dev/Transverse/tools/apache-maven/3.2.1/boot/plexus-classworlds-2.5.1.jar",
org.openjdk.jmh.runner.ForkedMain, 127.0.0.1, 58003]
# Run progress: 0,00% complete, ETA 00:00:20
# Fork: 1 of 1
<forked VM failed with exit code 1>
<stdout last='10 lines'>
</stdout>
<stderr last='10 lines'>
java.lang.NoClassDefFoundError: org/openjdk/jmh/runner/ForkedMain
Caused by: java.lang.ClassNotFoundException:
org.openjdk.jmh.runner.ForkedMain
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.openjdk.jmh.runner.ForkedMain. Program
will exit.
Exception in thread "main"
</stderr>
# VM invoker: c:\Program Files (x86)\Java\jdk1.6.0_31\jre\bin\java.exe
# VM options: -Xverify:none
-Xbootclasspath/p:D:\Dev\EVL\tools\JRebel\jrebel-bootstrap.jar;D:\Dev\EVL\tools\JRebel\jrebel.jar
-Drebel.jersey_plugin=true -Xms256m -XX:MaxPermSize=192m -Xmx1024m
-Dclassworlds.conf=d:/Dev/Transverse/tools/apache-maven/3.2.1/bin/m2.conf
-Dmaven.home=d:/Dev/Transverse/tools/apache-maven/3.2.1
# Warmup: 5 iterations, 1 s each
# Measurement: 5 iterations, 1 s each
# Threads: 4 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark:
com.github.gdrouet.scannerbenchmark.JmhBenchmark.scanSubtypeWithReflections
Forking 1 times using command: [c:\Program Files
(x86)\Java\jdk1.6.0_31\jre\bin\java.exe, -Xverify:none,
-Xbootclasspath/p:D:\Dev\EVL\tools\JRebel\jrebel-bootstrap.jar;D:\Dev\EVL\tools\JRebel\jrebel.jar,
-Drebel.jersey_plugin=true, -Xms256m, -XX:MaxPermSize=192m, -Xmx1024m,
-Dclassworlds.conf=d:/Dev/Transverse/tools/apache-maven/3.2.1/bin/m2.conf,
-Dmaven.home=d:/Dev/Transverse/tools/apache-maven/3.2.1,
-XX:CompileCommandFile=c:\temp\jmh1640929078555797577compilecommand, -cp,
"d:/Dev/Transverse/tools/apache-maven/3.2.1/boot/plexus-classworlds-2.5.1.jar",
org.openjdk.jmh.runner.ForkedMain, 127.0.0.1, 58004]
# Run progress: 0,00% complete, ETA 00:00:20
# Fork: 1 of 1
<forked VM failed with exit code 1>
<stdout last='10 lines'>
</stdout>
<stderr last='10 lines'>
java.lang.NoClassDefFoundError: org/openjdk/jmh/runner/ForkedMain
Caused by: java.lang.ClassNotFoundException:
org.openjdk.jmh.runner.ForkedMain
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.openjdk.jmh.runner.ForkedMain. Program
will exit.
Exception in thread "main"
</stderr>
# Run complete. Total time: 00:00:00
Benchmark Mode Samples Score Score error Units
Thanks
2014-07-28 3:01 GMT+02:00 Aleksey Shipilev <aleksey.shipilev at oracle.com>:
> Hi,
>
> On 07/27/2014 06:06 AM, Guillaume Drouet wrote:
> > java.lang.NoClassDefFoundError: org/openjdk/jmh/runner/ForkedMain
> > Caused by: java.lang.ClassNotFoundException:
>
> So it looks like jmh-core is not on classpath, which is weird.
>
> > Of course, I don't reproduce the issue if I disable forks. However, I
> > don't understand why JMH doesn't keep the classpath set when it performs
> > fork.
>
> Actually, we do propagate the classpath to the forked VM:
>
> http://hg.openjdk.java.net/code-tools/jmh/file/98a3cd8c58ef/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java#l704
>
> Can you post the complete log with launch options and "-v EXTRA"?
>
> Note that if you are invoking JMH via -jar benchmarks.jar, then *JVM
> launcher* is ignoring the classpath [1], and JMH is oblivious about it.
> It still would not explain why your scenario works when you disable the
> forks. Are you launching the JMH main class directly, without -jar?
>
> -Aleksey.
>
> [1]
> http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html,
> see "-jar".
>
--
Guillaume DROUET
More information about the jmh-dev
mailing list