Tag Archives: Nails

[Solved] Using jdk11 to deploy Nacos under Linux, the startup error is: could not find or load main class

Deploying Nacos using jdk11 under Linux

Error log

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

Solution:

In the Nacos-Server bin/startup.sh
Startup error caused by JAVA_OPT_EXT_FIX configuration

Replace the following configuration in the startup.sh file

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 &

Nacos: How to Solve failed to req API:/nacos/v1/ns/instance after all servers([127.0.0.1:8848])

Problem description

After the local source code compiles the nacos-1.0 master branch and configures mysql, it is successfully started as the service center and configuration center
but the gateway application starts with an error of 500 and an empty pointer exception.

failed to req API:/nacos/v1/ns/instance after all servers([127.0.0.1:8848])

It is said that the online query is caused by starting in cluster mode. It can be changed to stand-alone mode
however, the source code is not very familiar, and the configuration modification seems to have no effect.

Solutions

method 1

Temporarily, add the system configuration in the main method of the Nacos console project, and then use it normally. I use the embedded database here.

@SpringBootApplication(scanBasePackages = "com.alibaba.nacos")
@ServletComponentScan
@EnableScheduling
public class Nacos {

    public static void main(String[] args) {
        System.setProperty("nacos.standalone", "true");
        SpringApplication.run(Nacos.class, args);
    }
}

It’s not clear what’s in the configuration file nacos.standalone=true The specific reason for not taking effect may be that the wrong documents have been put in and there is an opportunity to fill in the hole again

method 2

(both local uncompiled projects and compiled packages are valid)
Add startup parameters - Dnacos.standalone=true

method 3

If you are downloading the compiled Nacos. You can start
./bin by adding command directly/ startup.sh -m standalone