javabazelbazel-rulesbazel-java

Java Bazel Build Error : java/toolchains/bootclasspath_classes/DumpPlatformClassPath.class [for host] failed: not all outputs were created or valid


Getting following error while building java bazel project -->

$ bazel build :all
INFO: Invocation ID: f3087fe5-67a5-4b0f-a3a8-a61b3bbfa869
WARNING: /home/ess/.cache/bazel/_bazel_ess/4fc692f493f73198611cffef8bfaa09d/external/cayman_zlib/BUILD.bazel:77:11: in linkstatic attribute of cc_library rule @cayman_zlib//:zlib: setting 'linkstatic=1' is recommended if there are no object files
INFO: Analyzed 23 targets (0 packages loaded, 0 targets configured).
INFO: Found 23 targets...
ERROR: /home/ess/.cache/bazel/_bazel_ess/4fc692f493f73198611cffef8bfaa09d/external/prj_build/java/toolchains/BUILD:13:14: output 'external/prj_build/java/toolchains/bootclasspath_classes/DumpPlatformClassPath.class' was not created
ERROR: /home/ess/.cache/bazel/_bazel_ess/4fc692f493f73198611cffef8bfaa09d/external/prj_build/java/toolchains/BUILD:13:14: Action external/prj_build/java/toolchains/bootclasspath_classes/DumpPlatformClassPath.class [for host] failed: not all outputs were created or valid
INFO: Elapsed time: 0.794s, Critical Path: 0.43s
INFO: 3 processes: 1 remote cache hit, 2 internal.
FAILED: Build did NOT complete successfully

how can I resolve this bazel build issue? Bazel version I am using is 4.0.0


Solution

  • Setting bazel toolchain and updating .bazelrc file with below contents solved my issue ---->

    $ cat ~/.bazelrc
    startup --server_javabase=/build/toolchain/lin64/jdk-1.8.0_201
    
    startup --host_jvm_args=-Xms2G
    startup --host_jvm_args=-Xmx2G
    
    build --remote_http_cache=http://127.0.0.1:9090
    build --remote_upload_local_results=true
    build --remote_timeout=15