File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes What is the best practice for property files outside the project EAR? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "What is the best practice for property files outside the project EAR?" Watch "What is the best practice for property files outside the project EAR?" New topic
Author

What is the best practice for property files outside the project EAR?

William Nelson
Greenhorn

Joined: Oct 24, 2008
Posts: 7
Hi, I'm relatively new to JBoss AS and I'm doing a migration from WAS to JBoss. One thing we need to do is keep our datasource usernames/passwords in a properties file outside of the deployed EAR. I can currently get it to work with the following code in jboss-service.xml:

<classpath codebase="file:///C:/props/"/>

What I'd like to do is make this path relative instead of absolute. I guess I'm unclear as to the best practice for configuring external property files in JBoss.

If someone else is doing this, can you please post an example of what you did, along with the java code to access it?

I should mention that we have other property files inside the project and I want to use the same code to access all properties. Here is what that code looks like:

URL url = Thread.currentThread().getContextClassLoader().getResource(property);
Properties p = createPropertyObject(url);

Thanks in advance.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10241
    
168

Try placing the properties file under %JBOSS_HOME%/server/< serverName>/conf folder, which by default is in the classpath.


[My Blog] [JavaRanch Journal]
William Nelson
Greenhorn

Joined: Oct 24, 2008
Posts: 7
Thanks, that takes care of the problem without any additional configuration.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10241
    
168

dahood shaikh,
Your post was moved to a new topic.
 
Don't get me started about those stupid light bulbs.
 
subject: What is the best practice for property files outside the project EAR?