Linux下部署Nacos启动报错:Could not find or load main class


一、报错

/usr/java/jdk-13.0.1/bin/java   -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/nacos/distribution/logs/java_heapdump.hprof -XX:-UseLargePages -Dnacos.member.list= -Xlog:gc*:file=/data/nacos/distribution/logs/nacos_gc.log:time,tags:filecount=10,filesize=102400 -Dloader.path=/data/nacos/distribution/plugins/health,/data/nacos/distribution/plugins/cmdb -Dnacos.home=/data/nacos/distribution -jar /data/nacos/distribution/target/nacos-server.jar  --spring.config.additional-location=file:/data/nacos/distribution/conf/ --logging.config=/data/nacos/distribution/conf/nacos-logback.xml --server.max-http-header-size=524288
Error: Could not find or load main class 
Caused by: java.lang.ClassNotFoundException: 

二、解决方案

打x的为原文本,√ 为需要替换成的内容

在Nacos-Server的 bin / startup.sh
由JAVA_OPT_EXT_FIX 配置引起启动报错

在startup.sh文件中替换下方配置

x JAVA_OPT_EXT_FIX="-Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext"JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext"

x echo "$JAVA $JAVA_OPT_EXT_FIX ${JAVA_OPT}"echo "$JAVA ${JAVA_OPT}"

x echo "$JAVA $JAVA_OPT_EXT_FIX ${JAVA_OPT}" > ${BASE_DIR}/logs/start.out 2>&1 &
x nohup "$JAVA" "$JAVA_OPT_EXT_FIX" ${JAVA_OPT} nacos.nacos >> ${BASE_DIR}/logs/start.out 2>&1 &echo "$JAVA ${JAVA_OPT}" > ${BASE_DIR}/logs/start.out 2>&1 &nohup $JAVA ${JAVA_OPT} nacos.nacos >> ${BASE_DIR}/logs/start.out 2>&1 &

总结

遇到问题慢慢改,耐心和细心,总能解决问题,亲自尝试,完美解决问题
Logo

更多推荐