Reputation: 1870
We have a monorepo where we have recently added the MAVEN_REPOS to be used with Bazel. We are using Quarkus 2.9.2.Final. So I am planning to create a CLI Application using Quarkus. But whenever I am running them I am getting a runtime exception. Following how my code looks like -
BUILD.bazel
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("//build/bazel/rule_app_launcher:task_master.bzl", "tm_task")
java_binary(
name = "MyApp",
srcs = ["Main.java"],
main_class = "<package to the Main class>.Main",
resources = ["<references to the application properties>"],
visibility = ["//visibility:public"],
deps = [
"@maven//:io_quarkus_quarkus_arc",
"@maven//:io_quarkus_quarkus_core",
],
)
Main.java
import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.QuarkusMain;
@QuarkusMain
public class Main {
public static void main(String... args) {
Quarkus.run(HelloWorldMain.class, args);
}
public class HelloWorldMain implements QuarkusApplication {
@Override
public int run(String... args) throws Exception {
System.out.println("Hello " + args[0]);
return 0;
}
}
}
Following is the error I am getting when running bazel run //:MyApp
Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at io.quarkus.launcher.QuarkusLauncher.launch(QuarkusLauncher.java:58)
at io.quarkus.runtime.Quarkus.launchFromIDE(Quarkus.java:97)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:84)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
at <package to the Main class>.Main.main(Main.java:12)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.launcher.QuarkusLauncher.launch(QuarkusLauncher.java:56)
... 4 more
Caused by: java.lang.IllegalStateException: Failed to locate project dir for /home/User123/.cache/bazel/_bazel_User123/b0cc32ca6725cc3e1476fd4087bd3d1d/execroot/app/bazel-out/k8-fastbuild/bin/<component path>/MyApp.jar
at io.quarkus.bootstrap.IDELauncherImpl.launch(IDELauncherImpl.java:38)
... 9 more
Appreciate for any clues to solve this problem.
Thanks.
Upvotes: 1
Views: 492