Menu

#581 Java environment variable causes Areca startup to fail

areca-7.x
open
nobody
None
1
2018-09-10
2015-09-23
Brad
No

I ran into a problem where Areca would no longer start on my RHEL7 box. After going to the command line to run areca.sh from there, I received the following error output:

*ls: cannot access /usr/java: No such file or directory
No valid JRE found in /usr/java.
*

I had not done any system/java updates since I last ran Areca successfully, but I had added a system-wide java variable to /etc/environment (underscoreJAVAunderscoreOPTIONS). I determined this addition to be the change that tickled this bug. In areca_run.sh, the function check_version() determines the java version by parsing the first line returned from "java -version"; however with the addition of the java environment variable, the first line produced from the aforementioned command is "Picked up underscoreJAVAunderscoreOPTIONS ..." rather than the expected "java version 1.x.x".

To fix this issue (and to take into account the bug found in ticket #563 regarding the java version string of OpenJDK 1.8), I changed check_version() from:

JAVA_HEADER=${JAVA_PROGRAM_DIR}java -version 2>&1 | head -n 1

TO

JAVA_HEADER=${JAVA_PROGRAM_DIR}java -version 2>&1 | grep -Eo "(java|openjdk) version \"[0-9._]*\""

This modification allowed Areca to properly validate java and start without error.

Discussion

  • Kempelen

    Kempelen - 2015-09-30

    Very similar problem here and fixed like mentioned above. I add this comment because search for the error message didn't find this bug report due to writing "underscore"

    $java -version
    Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
    java version "1.7.0_79"
    OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.15.04.1)
    OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

    Useful info, this message cannot be disabled:
    https://community.oracle.com/thread/1239778?start=0&tstart=0

     
  • tastyminerals

    tastyminerals - 2016-03-24

    The correct bash statement is:

    JAVA_HEADER=$(${JAVA_PROGRAM_DIR}java -version 2>&1 | grep -Eo "(java|openjdk) version \"[0-9._]*\"")

     

    Last edit: tastyminerals 2016-03-24
  • Joe Linux

    Joe Linux - 2017-04-23

    Hi all,

    this is a really bad bug because it keeps people from compiling and testing Areca Backup. Please see the discussion here, for example: https://forum.mxlinux.org/viewtopic.php?f=121&t=42039. As you can see, it even keeps Areca Backup from being regarded as a candidate for a superb Debian based distro's test repo. (As for now, it's not in Debian Jessie's repos.)

    Maybe one of you would be able to implement a clean fix into the Java package? That would be great, and maybe it would greatly help to revitalise Areca Backup, which has great features that are rarely found otherwise. As far as I understand it from what I've read above, the problem is fully understood and a solution is available.

    I would implement the fix myself but unfortunately my knowledge is far too limited.

    Greetings, Joe

    PS In case Oliver Petrucci, the developer ("aventin"), reads this: Since you seem to be all on your own, I guess quite a few people would love to support this project with small donations if only you published some bank account data on the Areca Backup website. Not everybody has (or wants to have) a PayPal account. In any case, thanks a lot for your decent work.

     

    Last edit: Joe Linux 2017-04-23
  • Desuche

    Desuche - 2017-11-19

    My system is ubuntu 16.04 LTS 64bits and java openjdk version "1.8.0_151",

    This work-aroud was not enough (or not useful); I leave this change in the "areca_run.sh" file but have to add another fix found on the web :
    Change,
    if [[ "$JAVA_IMPL" = "java" ; then
    by :
    if [[ "$JAVA_IMPL" = "java" || "$JAVA_IMPL" = "openjdk" ]] ; then

    After these changes, Areca backup accept to start.

     
  • Koaunghi Un

    Koaunghi Un - 2018-09-10

    I've come to here to run areca.sh. I had following error message:

    ls: cannot access '/usr/java': No such file or directory
    No valid JRE found in /usr/java.

    The Brad's solution didn't work for me. Probably because I use Fedora Linux 28 and the directory structure of java is not the same as RHEL7.

    For Fedora, the JAVADIR should be

    JAVADIR=/usr/lib/jvm
    

    and the look_for_java() should be changed to

    look_for_java() {
      IFS=$'\n'
      potential_java_dirs=(`ls -1 "$JAVADIR" | sort | tac`)
      IFS=
      for D in "${potential_java_dirs[@]}"; do
        #if [[ -d "$JAVADIR/$D" && -x "$JAVADIR/$D/java" ]]; then
          #JAVA_PROGRAM_DIR="$JAVADIR/$D/"
        if [[ -d "$JAVADIR/$D" && -x "$JAVADIR/$D/bin/java" ]]; then
          JAVA_PROGRAM_DIR="$JAVADIR/$D/bin/"
          echo "JRE found in ${JAVA_PROGRAM_DIR} directory."
          if check_version ; then
            return 0
          else
            return 1
          fi
        fi
      done
      echo "No valid JRE found in ${JAVADIR}."
      return 1
    }
    

    In order to implement openjdk-awareness, I took the tastyminerals' and Deutsche's advice in the function check_version() as follows:

    check_version() {
      #JAVA_HEADER=`${JAVA_PROGRAM_DIR}java -version 2>&1 | head -n 1`
      JAVA_HEADER=$(${JAVA_PROGRAM_DIR}java -version 2>&1 | grep -Eo "(java|openjdk) version \"[0-9._]*\"")
      JAVA_IMPL=`echo ${JAVA_HEADER} | cut -f1 -d' '`
      #if [ "$JAVA_IMPL" = "java" ] ; then
      if [[ "$JAVA_IMPL" = "java" || "$JAVA_IMPL" = "openjdk" ]] ; then
        VERSION=`echo ${JAVA_HEADER} | sed "s/java version \"\(.*\)\"/\1/"`
        if echo $VERSION | grep "^1.[0-3]" ; then
          return 1
        else
          return 0
        fi
      else
        return 1
      fi
    }
    
     

    Last edit: Koaunghi Un 2018-09-10
  • Koaunghi Un

    Koaunghi Un - 2018-09-10

    One more thing.

    Becasuse the directory structure seems to vary from distros to distros, it could be an alternative to install Sun's jre (installed to the folder /opt in my case) and modify areca_run.sh as follows:

    JAVADIR=/opt/jre1.8.0_181
    ...
    look_for_java() {
      IFS=$'\n'
      potential_java_dirs=(`ls -1 "$JAVADIR" | sort | tac`)
      IFS=
      for D in "${potential_java_dirs[@]}"; do
        #if [[ -d "$JAVADIR/$D" && -x "$JAVADIR/$D/java" ]]; then
          #JAVA_PROGRAM_DIR="$JAVADIR/$D/"
        if [[ -d "$JAVADIR/$D" && -x "$JAVADIR/$D/bin/java" ]]; then
          JAVA_PROGRAM_DIR="$JAVADIR/$D/bin/"
          echo "JRE found in ${JAVA_PROGRAM_DIR} directory."
          if check_version ; then
            return 0
          else
            return 1
          fi
        fi
      done
      echo "No valid JRE found in ${JAVADIR}."
      return 1
    }
    
     

Log in to post a comment.