Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8319816

java.io.FileNotFoundException: /usr/lib/jvm/[...]/lib/tzdb.dat

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Occurs in linux Redhat and mac with OpenJDK11 version 11.0.20.0.8-2.el9


      A DESCRIPTION OF THE PROBLEM :
      Full error message:
      Caused by: java.lang.Error: java.io.FileNotFoundException: /usr/lib/jvm/java-11-openjdk-11.0.20.0.8-2.el9.x86_64/lib/tzdb.dat (No such file or directory)
      at java.base/sun.util.calendar.ZoneInfoFile$1.run(ZoneInfoFile.java:261)
      at java.base/sun.util.calendar.ZoneInfoFile$1.run(ZoneInfoFile.java:251)
      at java.base/java.security.AccessController.doPrivileged(Native Method)
      at java.base/sun.util.calendar.ZoneInfoFile.<clinit>(ZoneInfoFile.java:251)
      at java.base/sun.util.calendar.ZoneInfo.getTimeZone(ZoneInfo.java:588)
      at java.base/java.util.TimeZone.getTimeZone(TimeZone.java:577)
      at java.base/java.util.TimeZone.setDefaultZone(TimeZone.java:682)
      at java.base/java.util.TimeZone.getDefaultRef(TimeZone.java:653)
      at java.base/java.util.TimeZone.getDefault(TimeZone.java:642)

      The latest redhat build of java-11-openjdk version, is missing a dependency on tzdata-java. This means that any java program using the popular log4j library fails at runtime.

      Older versions of java 11 all worked fine until this latest patch release, so this is a bug that retroactively will break many, many packages.

      REGRESSION : Last worked in version 11

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      This occurs most easily in redhat where openjdk 11.0.20 is available through the repositories.
      There needs to be no prexisting java install of any kind.

      docker run -it --rm redhat/ubi9:latest
      # then inside the container...
      dnf install -y java-11-openjdk maven
      stat /usr/lib/jvm/java-11-openjdk-11.0.20.0.8-2.el9.x86_64/lib/tzdb.dat
      # this will show that tzdb.dat exists and is a link to /usr/share/javazi-1.8/tzdb.dat
      stat /usr/share/javazi-1.8/tzdb.dat


      To reproduce the problem with the error I mentioned I have attached some source code which will fail to compile against 11.0.20


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      File /usr/share/javazi-1.8/tzdb.dat exists and stat shows its statistics
      ACTUAL -
      File does not exist.
      stat: cannot statx '/usr/share/javazi-1.8/tzdb.dat': No such file or directory

      ---------- BEGIN SOURCE ----------
      The helloworld example from the log4j website is enough. https://logging.apache.org/log4j/2.x/manual/api.html

      source:
      import org.apache.logging.log4j.LogManager;
      import org.apache.logging.log4j.Logger;

      public class HelloWorld
      {
          private static final Logger logger = LogManager.getLogger( "HelloWorld");

          public static void main(String[] args) {
              logger.info("Hello, World!");
          }
      }

      pom:

      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>

          <groupId>org.example</groupId>
          <artifactId>openjdk11020-repro</artifactId>
          <version>1.0-SNAPSHOT</version>

          <properties>
              <maven.compiler.source>11</maven.compiler.source>
              <maven.compiler.target>11</maven.compiler.target>
          </properties>
          <dependencies>
              <dependency>
                  <groupId>org.apache.logging.log4j</groupId>
                  <artifactId>log4j-api</artifactId>
                  <version>2.20.0</version>
              </dependency>
              <dependency>
                  <groupId>org.apache.logging.log4j</groupId>
                  <artifactId>log4j-core</artifactId>
                  <version>2.20.0</version>
              </dependency>
          </dependencies>
      </project>
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      manually installing `tzdata-java` fixes the issue. The bug is that java rpm now misses `tzdata-java` as a package dependency. It is unclear if the deb package is affected, since 11.0.20 has not yet reached debian or ubuntu repositories.

      FREQUENCY : always


            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: