JBoss External Properties Files in Classpath

孤者浪人 提交于 2019-12-24 05:22:07

问题


I was going through JBoss.org how to put external file in the classpath, but it doesn't work.

I have 1 file with name "config.properties". It is placed in jboss/modules/com/xsiraul/test/main/ folder. In the same folder there is module.xml which looks like -

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

I have load config.properties file from Java using -

InputStream settingsStream = getClass().getClassLoader().getResourceAsStream("config.properties");  

Java class is in package named com.xsiraul.test

The problem is that method getResourceAsStream returns NULL and I don't understand why. Maybe somebody has any ideas?

I use JBoss EAP 6.1.0.GA version.


回答1:


  1. Copy your 'config.properties' and 'module.xml' in the following directory:

    <JBOSS-6.1-ROOT>/modules/system/layers/base/com/fico/test/main
    
  2. Extend '/standalone/configuration/standalone.xml' by the following sub-system:

    <subsystem xmlns="urn:jboss:domain:ee:1.1">
     <global-modules>
      <module name="com.fico.test" slot="main"/>
     </global-modules>
     <spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>
     <jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
    </subsystem>
    
  3. Restart JBoss




回答2:


Did you declare the dependency to your module? maybe you missed that..

Add Dependencies: com.fico.test to your manifest.mf file



来源:https://stackoverflow.com/questions/28432321/jboss-external-properties-files-in-classpath

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!