2016-03-24 96 views
2

我正在使用JBoss EAP 6.4。我有一个包含资源(需要通过我的应用程序配置文件),并具有以下文件结构的模块文件夹:JBoss:在Module Path中包含子目录

modules 
    | 
    |---resources 
      | 
      |---main 
       | 
       |---templates 
       |  |---template1.xml 
       |  |---template2.xml 
       | 
       |---axis2.xml 
       |---hibernate.cfg.xml 
       |---module.xml 

module.xml文件看起来像这样:

<?xml version="1.0" encoding="UTF-8"?> 
<module xmlns="urn:jboss:module:1.1" name="resources"> 
    <resources> 
     <resource-root path="."/> 
     <resource-root path="./templates"/> 
    </resources> 
</module> 

我也有一个jboss-deployment-structure.xml文件:

<?xml version="1.0" encoding="UTF-8"?> 
<jboss-deployment-structure> 
    <deployment> 
     <dependencies> 
      <module name="resources" /> 
     </dependencies> 
    </deployment> 
</jboss-deployment-structure> 

我把模块文件夹放在JBOSS_MODULEPATH。该应用程序可以找到modules/resources/main中的XML文件,如axis2.xmlhibernate.cfg.xml。但是,它无法找到子目录templates(如template1.xml)中的文件。

有什么建议吗?

+0

我尝试一个类似的配置,遇到同样的问题,你正在描述。我的猜测是JBoss类加载器不会遍历这些自定义模块中的子路径。如果它可以工作,我很想知道如何。 –

回答

0

我找到了解决方法。当启动JBoss服务器我用下面的启动参数:

-Dresource.path=/path/to/modules/resources/main 

所以resource.path停留作为环境属性,我可以以这种方式访问​​在模板文件夹中的文件:

File f = new File(System.getProperty("resource.path") + "/templates/template1.xml"); 
+0

我可能也需要使用这样的方法。应该指出的是,这种“解决方法”完全放弃了JBoss模块功能,只是通过路径引用文件资源。 –