自定义了一个Property类用于读取应用上下文下面的所有properties文件

下面是定义的类,此类在windows下面运行很正常,但是在linux下面运行不正常,不知道是什么原因,有木有大神指教一下:
package com.cdsf.basicmanage.redirect.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;

public final class Property extends Properties {
private static final long serialVersionUID = 1L;
private static String baseURL = Property.class.getResource("/").getPath();

private final static class PropertyInstanceHandler {
    private final static Property properties = new Property();
}

private static final  String CLASS_PATH_NAME = "classes"; 

private static ConcurrentHashMap<String, String> concurrentHashMap = new ConcurrentHashMap<>();

private Property() {
    initIndex(baseURL.substring(1, baseURL.lastIndexOf(CLASS_PATH_NAME)));
}

public static Property getProperties() {
    return PropertyInstanceHandler.properties;
}

private void initIndex(String path) {
    File file = new File(path);
    if(!file.isFile()) {
        String[] files = file.list();
        for (String dir : files) {
            if(dir.equals(CLASS_PATH_NAME))
                continue;
            initIndex(path + File.separator + dir);
        }
    }else {
        String fullFileName = file.getName();
        if(fullFileName.contains(".")) {
            if(fullFileName.substring(fullFileName.lastIndexOf("."),fullFileName.length()).equals(".properties")) {
                    concurrentHashMap.put(fullFileName.substring(0,fullFileName.lastIndexOf(".")), file.getAbsolutePath());
                concurrentHashMap.keys();
            }
        }
    }
}

@Override
public String getProperty(String key,String filename) {
    try {
        if(!concurrentHashMap.containsKey(filename)) {
            return "";
        }
        load(new FileInputStream(new File(concurrentHashMap.get(filename))));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return super.getProperty(key);
}

}

这个类在服务器会报如下的错误:
[2017-07-28 10:39:31][localhost-startStop-1][org.springframework.web.context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.cdsf.basicmanage.redirect.ESRedirectController#0' defined in file [/home/apache-tomcat-7.0.57/webapps/bms/WEB-INF/classes/com/cdsf/basicmanage/redirect/ESRedirectController.class]: Instantiation of bean failed; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.ExceptionInInitializerError-->null
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1093) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1038) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) ~[spring-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) ~[spring-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at com.cdsf.webmvc.ssm.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:40) [webmvc-ssm-2.0.6-SNAPSHOT.jar:na]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994) [catalina.jar:7.0.57]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492) [catalina.jar:7.0.57]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.57]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) [catalina.jar:7.0.57]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) [catalina.jar:7.0.57]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649) [catalina.jar:7.0.57]
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1245) [catalina.jar:7.0.57]
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1895) [catalina.jar:7.0.57]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_112]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_112]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_112]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_112]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_112]
Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.ExceptionInInitializerError-->null
at org.springframework.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:235) ~[spring-core-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220) ~[spring-core-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:216) ~[spring-core-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:643) ~[spring-core-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.cglib.proxy.Enhancer.firstInstance(Enhancer.java:538) ~[spring-core-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:225) ~[spring-core-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) ~[spring-core-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at org.springframework.cglib.proxy.Enhancer.create(Enhancer.java:285) ~[spring-core-4.1.3.RELEASE.jar:4.1.3.RELEASE]
at com.cdsf.webmvc.ssm.context.InternalInstantiationStrategy.instantiate(InternalInstantiationStrategy.java:39) ~[webmvc-ssm-2.0.6-SNAPSHOT.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1086) ~[spring-beans-4.1.3.RELEASE.jar:4.1.3.RELEASE]
... 27 common frames omitted
Caused by: java.lang.ExceptionInInitializerError: null
at com.cdsf.basicmanage.redirect.util.Property.getProperties(Property.java:23) ~[Property.class:na]
at com.cdsf.basicmanage.redirect.ESRedirectController.(ESRedirectController.java:33) ~[ESRedirectController.class:na]
at com.cdsf.basicmanage.redirect.ESRedirectController$$EnhancerByCGLIB$$a021635f.() ~[spring-core-4.1.3.RELEASE.jar:na]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_112]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_112]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_112]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_112]
at org.springframework.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:228) ~[spring-core-4.1.3.RELEASE.jar:4.1.3.RELEASE]
... 36 common frames omitted
Caused by: java.lang.NullPointerException: null
at com.cdsf.basicmanage.redirect.util.Property.initIndex(Property.java:30) ~[Property.class:na]
at com.cdsf.basicmanage.redirect.util.Property.(Property.java:19) ~[Property.class:na]
at com.cdsf.basicmanage.redirect.util.Property.(Property.java:18) ~[Property.class:na]
at com.cdsf.basicmanage.redirect.util.Property$PropertyInstanceHandler.(Property.java:13) ~[Property$PropertyInstanceHandler.class:na]
... 44 common frames omitted
Jul 28, 2017 10:39:31 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问