Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
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: 9947
    
160

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: 9947
    
160

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?
 
Similar Threads
defining/exporting environement variables from tomcat server
Deployment practices for properties
JBOSS 5.1.0 issue with props folder in an EAR.
Best Practices - Properties files
When to stop using a properties file?