项目启动 报Failed to load plugin class

项目启动报错:

项目启动 报Failed to load plugin class_第1张图片

Caused by: ElasticsearchException[Unable to read /home/tomcat-vcompass-dev/bin/config/home/tomcat-vcompass-dev/webapps/domp/WEB-INF/classes/config/develop-keystore.jks (/home/tomcat-vcompass-dev/bin/config/home/tomcat-vcompass-dev/webapps/domp/WEB-INF/classes/config/develop-keystore.jks). Please make sure this files exists and is readable regarding to permissions. Property: searchguard.ssl.transport.keystore_filepath]

从报错信息可以看到,获取jks文件路径这里的目录有问题,报错原因是linux和windows获取类路径有差异,代码改造如下:

         

            ClassLoader classLoader = EsTransportclient.class.getClassLoader();
            URL resource = classLoader.getResource("config/develop-keystore.jks");
            URL truresource = classLoader.getResource("config/truststore.jks");
            
            String keypath = URLDecoder.decode(resource.getPath(), "UTF-8");
            String trupath = URLDecoder.decode(truresource.getPath(),"UTF-8");
            
            //windows中路径会多个/ 如/E windows下需要打开注释
            if("\\".equals(File.separator)){
                trupath = trupath.substring(1, trupath.length());
                keypath=keypath.substring(1, keypath.length());
            }
            
            //linux下
            if("/".equals(File.separator)){
                keypath = keypath.replace("\\", "/");
                trupath = trupath.replace("\\", "/");
            }

 

你可能感兴趣的:(后台)