Resource Bundle (*.properties) only packaged with application in EAP 6

Latest response

When reviewing what steps are required to migrate from EAP 5 to EAP 6, I noticed this paragraph about deploying properties files to EAP 6, (based on AS7). Since EAP 6 is still in a planning phase, I thought it might be interesting to see what you all thought about packaging all configuration with your applications. Also I would be interested to find out the reason behind this change, if anyone knows.

 

"In previous versions of AS, the JBOSS_HOME/server/<servername>/conf/ was available in the classpath. Hence the properties files in that location were available in the classpath of the application.

In AS7, to get those properties available in the classpath, package them within your application. For example, if you are deploying a .war then package those properties in WAR WEB-INF/classes/ folder. If you want those properties accessible to all components in a .ear, then package them at the root of some .jar and place that jar in EAR lib/ folder."

 

https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7

 

It seems to me that have a environment specific properties file is a convienent solution to deploying applications to different environments, allowing you to specify settings specific to an environment at the application server (AS) level, instead of at the application level.

 

Of course logging, and datasource configuration remains part of the AS configuration because they are defined in the AS configuration file, but I wonder if there are application specific settings which are better specified at the AS level.

Responses

we have a lot of environment specific .properties files in the "conf" directory of our EAP 5 JBoss. For us it would be quite painful to change this behaviour in all of our applications.

I'd appreciate if you provide one place from where I'm able to get files via the classloader.

Try creating a module where you put your properties files and then list that module as a global module in standalone*.xml

 

mkdir -p $JBOSS_HOME/modules/conf/main/properties/

 

Put your properties files in $JBOSS_HOME/modules/conf/main/properties/

 

Create a module.xml here $JBOSS_HOME/modules/conf/main/module.xml

 

<module xmlns="urn:jboss:module:1.1" name="conf">
    <resources>
        <resource-root path="properties"/>
    </resources>
 </module>

 

Edit $JBOSS_HOME/standalone/standalone.xml or the config xml you are using and Change   <subsystem xmlns="urn:jboss:domain:ee:1.0"/>
 

to

 

<subsystem xmlns="urn:jboss:domain:ee:1.0" >            
  <global-modules>
    <module name="conf" slot="main" />            
  </global-modules>
</subsystem>

 

Then you can access your propeties files using

Thread.currentThread().getContextClassLoader().getResource("my.properties");

 

For example if you had my.properties in $JBOSS_HOME/modules/conf/main/properties/

 

 

[1] https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7

[2] https://docs.jboss.org/author/display/MODULES/Home

Thank you very much! It works perfectly;-)

I am calling like this ResourceBundle.getBundle("ImageBundle_en_US", en_US_Locale); instead of Thread.currentThread().getContextClassLoader().getResource("my.properties"); it is not working. may i know we must call with Thread ?

I configured the same like you have told but getting error like Can't find bundle for base name ImageBundle_en_US, locale en_US I am deploying EJB3.0

If you can afford changing app. source code, then just specify environment-specific properties as EAP6 System Properties.

You can do it in your <config>.xml directly or do it through admin console or CLI.

Moreover, you can specify/override them at different levels, such as

  • profile
  • server-group
  • host
  • server-instance 

configurations. This is especially handy when you run a dozen of eap6 in domain mode managed by a single master. 

tair,

how to add the directory .

i understand if it is the key value pair yes . But if it is a drectory everything under a directory needs to be available

Hi team, I am working on migrating jboss server from EAP 5 to 7. In this process i have resolved many issues but i can not resolve resource bundle issue. java.util.MissingResourceException: Can't find bundle for base name ImageBundle_en_US, locale en_US I am deploying EJB3.0

Anybody please tell me clear view.