Bugfix: ERROR! Neo4j cannot be started using java version .

2,086 views
Skip to first unread message

Gert Hulselmans

unread,
Oct 28, 2014, 6:44:00 AM10/28/14
to ne...@googlegroups.com
Hi,

I have problems with starting Neo4J on a server with 256GiB of RAM.

$ ./neo4j-community-2.1.5/bin/neo4j start
ERROR! Neo4j cannot be started using java version .
* Please use Oracle(R) Java(TM) 7 or OpenJDK(TM) to run Neo4j Server.
* Please see http://docs.neo4j.org/ for Neo4j Server installation instructions.



The problem comes from the checkjvmcompatibility function in ./bin/utils,
as it tries to run JVM without giving initial and maximum heap size.
Due the large amount of RAM in the server, JVM tries to allocate to many GiB
which are not always free.

# check if running Oracle JDK 7 or OpenJDK 7, warn if not
checkjvmcompatibility() {
  # Shut down if java version < 1.7
  JAVAVERSION=$("$JAVACMD" ${JAVA_OPTS} -version 2>&1 | awk -F '"' '/version/ {print $2}')
  if [[ "$JAVAVERSION" < "1.7" ]]; then
    complain_about_java_version
    #exit 1
  fi

  $JAVACMD ${JAVA_OPTS} -version 2>&1 | egrep -q "(Java HotSpot\\(TM\\)|OpenJDK) (64-Bit Server|Server|Client) VM"
  if [ $? -eq 1 ]
  then
    warn_about_java_runtime
  fi
}



After fixing the function to the following, I can start Neo4J correctly.


# check if running Oracle JDK 7 or OpenJDK 7, warn if not
checkjvmcompatibility() {
  # Get Java version output
  JAVAVERSIONOUTPUT=$("$JAVACMD" -Xms10M -Xmx10M -version 2>&1)
  
  # Check if JVM was able to start correctly.
  if [ $? -ne 0 ] ; then
    echo 'ERROR: Problem with starting JVM.'
    exit 1
   fi

  # Shut down if java version < 1.7
  JAVAVERSION=$(echo "$JAVAVERSIONOUTPUT" | awk -F '"' '/version/ {print $2}')
  if [[ "$JAVAVERSION" < "1.7" ]]; then
    complain_about_java_version
    exit 1
  fi

  echo "$JAVAVERSIONOUTPUT" | egrep -q "(Java HotSpot\\(TM\\)|OpenJDK) (64-Bit Server|Server|Client) VM"
  if [ $? -eq 1 ]
  then
    warn_about_java_runtime
  fi
}


According to the manual of grep: egrep is deprecated, so it might be better to use grep -E instead:

    In addition, three variant programs egrep, fgrep and rgrep are available.
    egrep is the same as grep -E.
    fgrep is the same as grep -F.
    rgrep is the same as grep -r.
    Direct invocation as either egrep or fgrep is deprecated, but is provided to allow historical applications that rely on them to run unmodified.


Kind regards,
Gert Hulselmans

Lasse Westh-Nielsen

unread,
Oct 30, 2014, 4:28:39 AM10/30/14
to Neo4j User
Gert,

We have functionality in place for you to manage memory using Neo4j configs. Look for neo4j-wrapper.conf in $NEO4J_HOME/conf. The configuration in there is used here: https://github.com/neo4j/neo4j/blob/master/packaging/standalone/src/main/distribution/shell-scripts/bin/neo4j#L73

As for using different versions of grep, I remember writing that particular bit of code a couple of years ago! Alas, my Linux skills are not up to scratch, well spotted.

As for changing it, any chance you might want to submit a pull request with the change for us? There is some stuff here about how to go about it: http://neo4j.com/docs/stable/community-contributing.html. We always welcome help like that, and your name would live forever afterwards: http://neo4j.com/docs/stable/contributors.html ;)

Thanks,

Lasse




--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gert Hulselmans

unread,
Oct 30, 2014, 10:21:53 AM10/30/14
to ne...@googlegroups.com

Hi Lasse,

I know that your have functionality in place for managing memory using Neo4j configs ( I use it ).

The "ERROR! Neo4j cannot be started using java version . " error occurs because of the following command:
    java -version
which does not use the config settings used in the Neo4J config settings.


On the server over commit memory was set to 2 (do not allow overcommiting of memory):
    sudo sysctl vm.overcommit_memory=2
Swap was disabled.
And disk cache was huge (200 GiB).

So when "java -version" tried to run, is was not allowed because it tried to claim to much memory by default
(when vm.overcommit_memory=2 is active, if you malloc memory, even if you don't use it, it should be less than the total amount of free RAM + swap).

I will look at the pull request stuff later.

Thanks,
Gert

The patch above just solves the
Op donderdag 30 oktober 2014 09:28:39 UTC+1 schreef Lasse Westh-Nielsen:

Lasse Westh-Nielsen

unread,
Jan 27, 2016, 5:18:57 AM1/27/16
to Neo4j User
Gert,

We (as in my colleague Ben) have at long last fixed this issue: https://github.com/neo4j/neo4j/pull/6304

Regards,

Lasse



Reply all
Reply to author
Forward
0 new messages