Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mvn exec:java no longer works #493

Open
juvenn opened this issue Mar 23, 2024 · 0 comments
Open

mvn exec:java no longer works #493

juvenn opened this issue Mar 23, 2024 · 0 comments

Comments

@juvenn
Copy link

juvenn commented Mar 23, 2024

The maven exec seems not work anymore, upon upgrading to java 21. I'm still pinpoint where is wrong.

mvn clean compile exec:java -P postgres -Dexec.args="-b tpcc -c config/postgres/sample_tpcc_config.xml --create=true --load=true --execute=true"

java.lang.RuntimeException: Failed to retrieve class for com.oltpbenchmark.benchmarks.tpcc.TPCCBenchmark
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:200)
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:187)
    at com.oltpbenchmark.util.ClassUtil.newInstance (ClassUtil.java:112)
    at com.oltpbenchmark.DBWorkload.main (DBWorkload.java:165)
    at org.codehaus.mojo.exec.ExecJavaMojo.doMain (ExecJavaMojo.java:385)
    at org.codehaus.mojo.exec.ExecJavaMojo.doExec (ExecJavaMojo.java:374)
    at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0 (ExecJavaMojo.java:296)
    at java.lang.Thread.run (Thread.java:1583)
Caused by: java.lang.ClassNotFoundException: com.oltpbenchmark.benchmarks.tpcc.TPCCBenchmark
    at jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:641)
    at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:188)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:526)
    at java.lang.Class.forName0 (Native Method)
    at java.lang.Class.forName (Class.java:534)
    at java.lang.Class.forName (Class.java:513)
    at org.apache.commons.lang3.ClassUtils.getClass (ClassUtils.java:532)
    at org.apache.commons.lang3.ClassUtils.getClass (ClassUtils.java:514)
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:198)
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:187)
    at com.oltpbenchmark.util.ClassUtil.newInstance (ClassUtil.java:112)
    at com.oltpbenchmark.DBWorkload.main (DBWorkload.java:165)
    at org.codehaus.mojo.exec.ExecJavaMojo.doMain (ExecJavaMojo.java:385)
    at org.codehaus.mojo.exec.ExecJavaMojo.doExec (ExecJavaMojo.java:374)
    at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0 (ExecJavaMojo.java:296)
    at java.lang.Thread.run (Thread.java:1583)

Environment

mvn -v
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: /opt/homebrew/Cellar/maven/3.9.6/libexec
Java version: 21.0.2, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk/21.0.2/libexec/openjdk.jdk/Contents/Home
Default locale: en_CN, platform encoding: UTF-8
OS name: "mac os x", version: "14.2.1", arch: "aarch64", family: "mac"
pjungwir added a commit to pjungwir/benchbase that referenced this issue Jul 12, 2024
Running benchmarks without packaging first fails like so:

```
mvn clean compile exec:java -P postgres -Dexec.args="-b tpcc -c config/postgres/sample_tpcc_config.xml --create=true --load=true --execute=true"

java.lang.RuntimeException: Failed to retrieve class for com.oltpbenchmark.benchmarks.tpcc.TPCCBenchmark
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:200)
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:187)
    at com.oltpbenchmark.util.ClassUtil.newInstance (ClassUtil.java:112)
    at com.oltpbenchmark.DBWorkload.main (DBWorkload.java:165)
    at org.codehaus.mojo.exec.ExecJavaMojo.doMain (ExecJavaMojo.java:385)
    at org.codehaus.mojo.exec.ExecJavaMojo.doExec (ExecJavaMojo.java:374)
    at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0 (ExecJavaMojo.java:296)
    at java.lang.Thread.run (Thread.java:1583)
Caused by: java.lang.ClassNotFoundException: com.oltpbenchmark.benchmarks.tpcc.TPCCBenchmark
    at jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:641)
    at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:188)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:526)
    at java.lang.Class.forName0 (Native Method)
    at java.lang.Class.forName (Class.java:534)
    at java.lang.Class.forName (Class.java:513)
    at org.apache.commons.lang3.ClassUtils.getClass (ClassUtils.java:532)
    at org.apache.commons.lang3.ClassUtils.getClass (ClassUtils.java:514)
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:198)
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:187)
    at com.oltpbenchmark.util.ClassUtil.newInstance (ClassUtil.java:112)
    at com.oltpbenchmark.DBWorkload.main (DBWorkload.java:165)
    at org.codehaus.mojo.exec.ExecJavaMojo.doMain (ExecJavaMojo.java:385)
    at org.codehaus.mojo.exec.ExecJavaMojo.doExec (ExecJavaMojo.java:374)
    at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0 (ExecJavaMojo.java:296)
    at java.lang.Thread.run (Thread.java:1583)
```

The bug was introduced by 611f3d4. I believe we should be using
`Thread.getCurrentThread().getContextClassLoader()`, not
`ClassLoader.getSystemClassLoader()`.
pjungwir added a commit to pjungwir/benchbase that referenced this issue Jul 12, 2024
This was reported by cmu-db#493.

Running benchmarks without packaging first fails like so:

```
mvn clean compile exec:java -P postgres -Dexec.args="-b tpcc -c config/postgres/sample_tpcc_config.xml --create=true --load=true --execute=true"

java.lang.RuntimeException: Failed to retrieve class for com.oltpbenchmark.benchmarks.tpcc.TPCCBenchmark
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:200)
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:187)
    at com.oltpbenchmark.util.ClassUtil.newInstance (ClassUtil.java:112)
    at com.oltpbenchmark.DBWorkload.main (DBWorkload.java:165)
    at org.codehaus.mojo.exec.ExecJavaMojo.doMain (ExecJavaMojo.java:385)
    at org.codehaus.mojo.exec.ExecJavaMojo.doExec (ExecJavaMojo.java:374)
    at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0 (ExecJavaMojo.java:296)
    at java.lang.Thread.run (Thread.java:1583)
Caused by: java.lang.ClassNotFoundException: com.oltpbenchmark.benchmarks.tpcc.TPCCBenchmark
    at jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:641)
    at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:188)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:526)
    at java.lang.Class.forName0 (Native Method)
    at java.lang.Class.forName (Class.java:534)
    at java.lang.Class.forName (Class.java:513)
    at org.apache.commons.lang3.ClassUtils.getClass (ClassUtils.java:532)
    at org.apache.commons.lang3.ClassUtils.getClass (ClassUtils.java:514)
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:198)
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:187)
    at com.oltpbenchmark.util.ClassUtil.newInstance (ClassUtil.java:112)
    at com.oltpbenchmark.DBWorkload.main (DBWorkload.java:165)
    at org.codehaus.mojo.exec.ExecJavaMojo.doMain (ExecJavaMojo.java:385)
    at org.codehaus.mojo.exec.ExecJavaMojo.doExec (ExecJavaMojo.java:374)
    at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0 (ExecJavaMojo.java:296)
    at java.lang.Thread.run (Thread.java:1583)
```

The bug was introduced by 611f3d4. I believe we should be using
`Thread.getCurrentThread().getContextClassLoader()`, not
`ClassLoader.getSystemClassLoader()`.
bpkroth added a commit that referenced this issue Oct 10, 2024
This was reported by #493.

Running benchmarks without packaging first fails like so:

```
mvn clean compile exec:java -P postgres -Dexec.args="-b tpcc -c config/postgres/sample_tpcc_config.xml --create=true --load=true --execute=true"

java.lang.RuntimeException: Failed to retrieve class for com.oltpbenchmark.benchmarks.tpcc.TPCCBenchmark
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:200)
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:187)
    at com.oltpbenchmark.util.ClassUtil.newInstance (ClassUtil.java:112)
    at com.oltpbenchmark.DBWorkload.main (DBWorkload.java:165)
    at org.codehaus.mojo.exec.ExecJavaMojo.doMain (ExecJavaMojo.java:385)
    at org.codehaus.mojo.exec.ExecJavaMojo.doExec (ExecJavaMojo.java:374)
    at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0 (ExecJavaMojo.java:296)
    at java.lang.Thread.run (Thread.java:1583)
Caused by: java.lang.ClassNotFoundException: com.oltpbenchmark.benchmarks.tpcc.TPCCBenchmark
    at jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:641)
    at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:188)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:526)
    at java.lang.Class.forName0 (Native Method)
    at java.lang.Class.forName (Class.java:534)
    at java.lang.Class.forName (Class.java:513)
    at org.apache.commons.lang3.ClassUtils.getClass (ClassUtils.java:532)
    at org.apache.commons.lang3.ClassUtils.getClass (ClassUtils.java:514)
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:198)
    at com.oltpbenchmark.util.ClassUtil.getClass (ClassUtil.java:187)
    at com.oltpbenchmark.util.ClassUtil.newInstance (ClassUtil.java:112)
    at com.oltpbenchmark.DBWorkload.main (DBWorkload.java:165)
    at org.codehaus.mojo.exec.ExecJavaMojo.doMain (ExecJavaMojo.java:385)
    at org.codehaus.mojo.exec.ExecJavaMojo.doExec (ExecJavaMojo.java:374)
    at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0 (ExecJavaMojo.java:296)
    at java.lang.Thread.run (Thread.java:1583)
```

The bug was introduced by 611f3d4. I believe we should be using
`Thread.getCurrentThread().getContextClassLoader()`, not
`ClassLoader.getSystemClassLoader()`.

---------

Co-authored-by: Brian Kroth <[email protected]>
Co-authored-by: Brian Kroth <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant