Weblogic 10.3找不到外部属性文件

时间:2012-05-08 11:28:50

标签: spring weblogic classpath

我在其他示例中尝试了DeploymentException & Class Not Found on WebLogic Admin Server 11g,但是我无法让Spring读取外部属性文件。

我有这个代码,它读取属性文件。将文件(PROPERTIES_FILES)放在src / main / resources中,app i部署得很好。将它移动到文件系统中的外部文件夹,它很容易部署。

我尝试http://www.mkyong.com/java/how-to-print-out-the-current-project-classpath/来修改类路径并获取:

/C:/Oracle/Middleware/patch_wls1034/profiles/default/sys_manifest_classpath/weblogic_patch.jar
/C:/Oracle/Middleware/patch_oepe1040/profiles/default/sys_manifest_classpath/weblogic_patch.jar     /C:/Oracle/Middleware/patch_ocp360/profiles/default/sys_manifest_classpath/weblogic_patch.jar
/C:/Oracle/Middleware/jdk160_21/lib/tools.jar
/C:/Oracle/Middleware/wlserver_10.3/server/lib/weblogic_sp.jar
/C:/Oracle/Middleware/wlserver_10.3/server/lib/weblogic.jar
/C:/Oracle/Middleware/modules/features/weblogic.server.modules_10.3.4.0.jar
/C:/Oracle/Middleware/wlserver_10.3/server/lib/webservices.jar
/C:/Oracle/Middleware/modules/org.apache.ant_1.7.1/lib/ant-all.jar
/C:/Oracle/Middleware/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar
/C:/Oracle/Middleware/wlserver_10.3/common/derby/lib/derbyclient.jar
/C:/Oracle/Middleware/wlserver_10.3/server/lib/xqrl.jar

Trying to read test.properties
Found false
Could not find properties file: test.properties

我的实现如下:

    ClassLoader cl = ClassLoader.getSystemClassLoader();

    URL[] urls = ((URLClassLoader)cl).getURLs();

    for(URL url: urls){
        logger.debug(url.getFile());
    }

    logger.debug("Trying to read {}", PROPERTIES_FILES);
    Resource resource = new ClassPathResource(PROPERTIES_FILES);
    logger.debug("Found {}", resource.exists());
    try {
        props = PropertiesLoaderUtils.loadProperties(resource);
    } catch (IOException e) {
        logger.error("Could not find properties file: " + PROPERTIES_FILES, e);
    }

我在servlet-dispatcher中移动另一个属性文件时遇到同样的问题:

<context:property-placeholder location="classpath*:test.properties"/>

但我猜这是同样的问题。 我在Windows上。

有人能帮助我吗?

1 个答案:

答案 0 :(得分:1)

完整的系统是否重启并且有效。