This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 10067
    
163

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: 10067
    
163

dahood shaikh,
Your post was moved to a new topic.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the best practice for property files outside the project EAR?