Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-77923

Jira won't work with Java 17 on Linux if the Java binary is taken from the PATH or if using JRE_HOME

XMLWordPrintable

      Issue Summary

      Jira may not start with Java 17 on Linux when the Java location is brought by the PATH environment variable.

      Steps to Reproduce

      1. Download Adoptium JDK 11.
      2. Add the <jdk11-home>/bin directory to the PATH variable.
        export PATH=<jdk11-home>/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
        
      3. Don't set JAVA_HOME nor JRE_HOME environment variables.
        unset JAVA_HOME
        unset JRE_HOME
        
      4. Install a vanilla instance of Jira using the tar.gz.
      5. Start Jira with the start-jira.sh script.
      6. Note Jira recognizes the java binary and starts properly without any error.
      7. Stop Jira.
      8. Download Adoptium JDK 17.
      9. Add the <jdk17-home>/bin directory to the PATH variable.
        export PATH=<jdk17-home>/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
        
      10. Start Jira with the start-jira.sh script.

      Expected Results

      Jira starts properly without any error.

      Actual Results

      Jira fails to start properly because it's unable to include necessary --add-opens and --add-exports properties.

      The startup scripts properly identify the Java binary as below.

      $ ./start-jira.sh
      
      To run Jira in the foreground, start the server with start-jira.sh -fg
      executing as current user
      
                        `sMMMMMMMMMMMMMM+
                           MMMMMMMMMMMMMM
                           :sdMMMMMMMMMMM
                                   MMMMMM
                `sMMMMMMMMMMMMMM+  MMMMMM
                   MMMMMMMMMMMMMM  +MMMMM
                    :sMMMMMMMMMMM   MMMMM
                           MMMMMM    `UOJ
         `sMMMMMMMMMMMMM+  MMMMMM
           MMMMMMMMMMMMMM  +MMMMM
            :sdMMMMMMMMMM   MMMMM
                   MMMMMM    `UOJ
                   MMMMMM
                   +MMMMM
                    MMMMM
                     `UOJ
      
            Atlassian Jira
            Version : 9.12.10
      
      
      If you encounter issues starting or stopping Jira, please see the Troubleshooting guide at https://docs.atlassian.com/jira/jadm-docs-0912/Troubleshooting+installation
      
      Using JIRA_HOME:       /var/atlassian/application-data/jira/
      
      Server startup logs are located in /opt/atlassian/jira/current/logs/catalina.out
      Using CATALINA_BASE:   /opt/atlassian/jira/current
      Using CATALINA_HOME:   /opt/atlassian/jira/current
      Using CATALINA_TMPDIR: /var/atlassian/application-data/jira//temp
      Using JRE_HOME:        /opt/atlassian/jira/jdk-17.0.12+7
      Using CLASSPATH:       /opt/atlassian/jira/current/bin/bootstrap.jar:/opt/atlassian/jira/current/bin/tomcat-juli.jar
      Using CATALINA_OPTS:
      Using CATALINA_PID:    /opt/atlassian/jira/current/work/catalina.pid
      Tomcat started.
      

      Looking at the Tomcat logs we have an error similar to the below.

      2024-07-30 12:15:06,981+0000 main ERROR      [c.a.jira.startup.ComponentContainerLauncher] An Error occurred during ComponentContainerLauncher servlet context initialisation - class com.atlassian.jira.issue.customfields.manager.xml.AllowlistedXStreamFactory (in unnamed module @0x534fc1f7) cannot access class sun.util.calendar.BaseCalendar$Date (in module java.base) because module java.base does not export sun.util.calendar to unnamed module @0x534fc1f7.
      java.lang.IllegalAccessError: class com.atlassian.jira.issue.customfields.manager.xml.AllowlistedXStreamFactory (in unnamed module @0x534fc1f7) cannot access class sun.util.calendar.BaseCalendar$Date (in module java.base) because module java.base does not export sun.util.calendar to unnamed module @0x534fc1f7
      	at com.atlassian.jira.issue.customfields.manager.xml.AllowlistedXStreamFactory.fillJiraDefaults(AllowlistedXStreamFactory.java:77)
      



      The root cause is from the incomplete fix from JRASERVER-76224 on which the <jira-install-dir>/bin/set-opens.sh script relies on JAVA_HOME to identify the current Java version.
      It should use an existing solution from the check-java.sh script by checking the java_version environment variable.

      Workaround

      Choose one of the following workarounds:

      1. Set the JAVA_HOME variable before starting Jira.
      2. Modify the <jira-install-dir>/bin/set-opens.sh file to have the following contents.
        #!/bin/sh
        
        if [ $java_version -ge 17 ]; then
          JVM_OPENS=$(cat $PRGDIR/java-opens.txt)
          JAVA_OPTS="$JVM_OPENS $JAVA_OPTS"
        fi
        

              Unassigned Unassigned
              tmasutti Thiago Masutti
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: