Search code examples
javalinuxinstallationbazelmanjaro

Bazel fails to build/install under Arch/Manjaro (KDE) Linux 5.19rt returning ExceptionInInitializerError/NullPointerException


Problem: I'm trying to install tensorflow-amd and one of the dependencies is bazel. On installation of bazel I get the following error message:

[miner-ms7a59 Downloads]# sudo pacman -S bazel
resolving dependencies...
looking for conflicting packages...

Packages (7) jdk11-openjdk-11.0.16.1.u1-2  jre11-openjdk-11.0.16.1.u1-2  jre11-openjdk-headless-11.0.16.1.u1-2  libnet-1:1.1.6-1  unzip-6.0-19  zip-3.0-10
             bazel-5.2.0-1

Total Installed Size:  382.41 MiB

:: Proceed with installation? [Y/n] 
(7/7) checking keys in keyring                                                                [#######################################################] 100%
(7/7) checking package integrity                                                              [#######################################################] 100%
(7/7) loading package files                                                                   [#######################################################] 100%
(7/7) checking for file conflicts                                                             [#######################################################] 100%
(7/7) checking available disk space                                                           [#######################################################] 100%
:: Processing package changes...
(1/7) installing libnet                                                                       [#######################################################] 100%
(2/7) installing jre11-openjdk-headless                                                       [#######################################################] 100%
Optional dependencies for jre11-openjdk-headless
    java-rhino: for some JavaScript support
(3/7) installing jre11-openjdk                                                                [#######################################################] 100%
when you use a non-reparenting window manager,
set _JAVA_AWT_WM_NONREPARENTING=1 in /etc/profile.d/jre.sh
Optional dependencies for jre11-openjdk
    alsa-lib: for basic sound support [installed]
    gtk2: for the Gtk+ 2 look and feel - desktop usage [installed]
    gtk3: for the Gtk+ 3 look and feel - desktop usage [installed]
(4/7) installing jdk11-openjdk                                                                [#######################################################] 100%
(5/7) installing zip                                                                          [#######################################################] 100%
(6/7) installing unzip                                                                        [#######################################################] 100%
(7/7) installing bazel                                                                        [#######################################################] 100%
:: Running post-transaction hooks...
(1/4) Arming ConditionNeedsUpdate...
(2/4) Refreshing PackageKit...
(3/4) Updating icon theme caches...
(4/4) Updating the desktop file MIME type cache...
[miner-ms7a59 Downloads]# bazel --version
bazel 5.2.0
[miner-ms7a59 Downloads]# bazel
WARNING: Invoking Bazel in batch mode since it is not invoked from within a workspace (below a directory having a WORKSPACE file).
Extracting Bazel installation...
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.ExceptionInInitializerError
        at com.google.devtools.build.lib.skyframe.SkyframeExecutor.<clinit>(SkyframeExecutor.java:373)
        at com.google.devtools.build.lib.skyframe.BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder(BazelSkyframeExecutorConstants.java:63)
        at com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutorFactory.create(SequencedSkyframeExecutorFactory.java:43)
        at com.google.devtools.build.lib.runtime.WorkspaceBuilder.build(WorkspaceBuilder.java:73)
        at com.google.devtools.build.lib.runtime.BlazeRuntime.initWorkspace(BlazeRuntime.java:265)
        at com.google.devtools.build.lib.runtime.BlazeRuntime.newRuntime(BlazeRuntime.java:1316)
        at com.google.devtools.build.lib.runtime.BlazeRuntime.batchMain(BlazeRuntime.java:925)
        at com.google.devtools.build.lib.runtime.BlazeRuntime.main(BlazeRuntime.java:762)
        at com.google.devtools.build.lib.bazel.Bazel.main(Bazel.java:87)
Caused by: java.lang.NullPointerException
        at java.base/jdk.internal.platform.cgroupv2.CgroupV2Subsystem.getInstance(CgroupV2Subsystem.java:81)
        at java.base/jdk.internal.platform.CgroupSubsystemFactory.create(CgroupSubsystemFactory.java:113)
        at java.base/jdk.internal.platform.CgroupMetrics.getInstance(CgroupMetrics.java:167)
        at java.base/jdk.internal.platform.SystemMetrics.instance(SystemMetrics.java:29)
        at java.base/jdk.internal.platform.Metrics.systemMetrics(Metrics.java:58)
        at java.base/jdk.internal.platform.Container.metrics(Container.java:43)
        at jdk.management/com.sun.management.internal.OperatingSystemImpl.<init>(OperatingSystemImpl.java:182)
        at jdk.management/com.sun.management.internal.PlatformMBeanProviderImpl.getOperatingSystemMXBean(PlatformMBeanProviderImpl.java:281)
        at jdk.management/com.sun.management.internal.PlatformMBeanProviderImpl$3.nameToMBeanMap(PlatformMBeanProviderImpl.java:198)
        at java.management/sun.management.spi.PlatformMBeanProvider$PlatformComponent.getMBeans(PlatformMBeanProvider.java:195)
        at java.management/java.lang.management.ManagementFactory.getPlatformMXBean(ManagementFactory.java:686)
        at java.management/java.lang.management.ManagementFactory.getOperatingSystemMXBean(ManagementFactory.java:388)
        at com.google.devtools.build.lib.util.ResourceUsage.<clinit>(ResourceUsage.java:42)
        ... 9 more
[miner-ms7a59 Downloads]# 

Building bazel with the git repository with yay didn't really help much either, since it gave the same error message in the middle of the build. A lot of other stackoverflow questions trail off into either the java version or the linux version, even though the java version I'm running right now is openjdk 11.0.16.1 2022-08-12 and I dont have any other jdk installed other than jdk11-openjdk 11.0.16.1.u1-2, jre11-openjdk 11.0.16.1.u1-2, jre11-openjdk-headless 11.0.16.1.u1-2 (given by pacman -Q | grep jdk)


Solution

  • From the shared log, this looks like a Java language issue. Recommended solution is to reinstall JRE. Also, can you try this with a more recent version of Bazel? JavaCompilationHelper has changed quite a bit in the last year, so an updated repro might help here. https://bazel.build/docs/bazel-and-java#java-versions