Commit 82af616
Fix mvn exec:java ClassNotFoundException (#548)
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 <bpkroth@users.noreply.github.com>
Co-authored-by: Brian Kroth <bpkroth@microsoft.com>1 parent 51ae02f commit 82af616
File tree
3 files changed
+7
-3
lines changed- .github/workflows
- src/main/java/com/oltpbenchmark
- api
- util
3 files changed
+7
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| |||
0 commit comments