troubleshooting Question

how to load properties file only once in enterprise application

Avatar of chaitu chaitu
chaitu chaituFlag for India asked on
JavaJSPJava EE
8 Comments2 Solutions2950 ViewsLast Modified:
This is the class which loads properties file which returns static instance;

public class LoadProperties {
	private static Properties properties = new Properties();

	public static Properties getProperties() {
		return properties;

	public static void setProperties(
			Properties properties) { = properties;


This is Listener class mentioned in web.xml which can be read when server starts up;
public class LoadProperties implements ServletContextListener {

public void contextInitialized(ServletContextEvent arg0) {
		//Below properties placed in application server class path in server lib folder with compressed jar;
		InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("");
				//value is printed successfully;



My requirement is How do we read this property(LoadProperties.getProperties().getProperty("type")) in EJB class without loading the properties file once again?because when we load this properties in WAR level we will get once instance of LoadProperties;I dont think same instance will not be propagated in EJB level as well.So Do i need to load same properties once again in EJB classes as well?

my EAR structure is like this;

lib--- jars -- related jar is placed in the application server class path not in this folder;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros