incubator-seata icon indicating copy to clipboard operation
incubator-seata copied to clipboard

OpenJDK 11 Server1.5.2 启动失败, Error: Could not create the Java Virtual Machine.

Open ShuningWan opened this issue 3 years ago • 1 comments

问题

Seata server 启动失败

  • JDK version : openjdk 11
  • Seata version: 1.5.2
  • OS : Linux

现象

/home/yuppweb/soft/jdk-11/bin/java  -server -Dloader.path=../lib -Xmx2048m -Xms2048m -Xmn1024m -Xss512k -XX:SurvivorRatio=10 -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m -XX:MaxDirectMemorySize=1024m -XX:-OmitStackTraceInFastThrow -XX:-UseAdaptiveSizePolicy -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/yuppweb/soft/seata-server-1.5.2/logs/java_heapdump.hprof -XX:+DisableExplicitGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 -Xloggc:/home/yuppweb/soft/seata-server-1.5.2/logs/seata_gc.log -verbose:gc -XX:+PrintGCDetails  -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dio.netty.leakDetectionLevel=advanced -Dapp.name=seata-server -Dapp.pid=1084 -Dapp.home=/home/yuppweb/soft/seata-server-1.5.2 -Dbasedir=/home/yuppweb/soft/seata-server-1.5.2 -Dspring.config.location=/home/yuppweb/soft/seata-server-1.5.2/conf/application.yml -Dlogging.config=/home/yuppweb/soft/seata-server-1.5.2/conf/logback-spring.xml -jar /home/yuppweb/soft/seata-server-1.5.2/target/seata-server.jar -h 192.168.10.14 -p 8091 -n 1
[0.000s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/home/yuppweb/soft/seata-server-1.5.2/logs/seata_gc.log instead.
Unrecognized VM option 'PrintGCDateStamps'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

原因

以下shell 截取自seata-server.sh

#132 JAVA_MAJOR_VERSION=$($JAVACMD -version 2>&1 | sed '1!d' | sed -e 's/"//g' | awk '{print $3}' | awk -F '.' '{print $2}')
#133 if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] ; then
#134   JAVA_OPT="${JAVA_OPT} -Xlog:gc*:file=${BASEDIR}/logs/seata_gc.log:time,tags:filecount=10,filesize=102400"
#135 else
#136   JAVA_OPT="${JAVA_OPT} -Xloggc:${BASEDIR}/logs/seata_gc.log -verbose:gc -XX:+PrintGCDetails  -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M"
#137 fi

在openjdk下L132 获取版本号为空,期望执行L134,错误执行了L136,导致异常的产生, 在oracle jdk下正常。

解决方案

临时:L132 截掉 (| awk -F '.' '{print $2}'),openjdk环境下正常,该操作在oracle jdk下获取不到对应版本号

可以增加openjdk 和 oracle jdk判断,按版本号格式,区别处理

ShuningWan avatar Aug 09 '22 02:08 ShuningWan

@ShuningWan can you submit a PR to fix it?

slievrly avatar Aug 16 '22 06:08 slievrly