1 Reply Latest reply on Jul 28, 2006 3:28 AM by jaikiran

    Properties file with the same name in separate JAR

    syncter

      Hi all,

      I have two EJB jars deployed on the same instance JBOSS application server. These two jars (lets say A.jar and B.jar) both have a utility class that retrieves custom property definition in a file called MyResource.properties. Each of the jar contains its own sets of properties defined in the property file and a copy of util class.

      Method in util class:
      public String getMyCustomMessage(String msg)
      {

      ResourceBundle myresource= ResourceBundle.getBundle("MyResource", getLocale());

      return new StringBuffer(myresource.getString(msg)).toString();
      }

      Here is the problem, when A.jar request service from B.jar, somehow funtions in B.jar refers to property file in A.jar when it calls the util class within B.jar. For instance, I have a property Myname=sync in MyResource.properties file in B.jar not in A.jar. It throws error that it could not find the property definition even though it is defined and bundled in the jar. When I added Myname=sync in MyResource.properties file in A.jar, this errror is gone.

      May i know what is the cause of such cross reference and how could I rectify this issue?

      Any help is much appreciated. Thank you.

        • 1. Re: Properties file with the same name in separate JAR
          jaikiran

          Are these 2 jars part of the same application? If yes, then why are the properties files having the same name. Is there any problem in giving two different names to the properties file and using the appropriate one through your code?

          The reason i ask these questions is that the properties file is picked by the classloader and if you want to maintain 2 property files with the same name in 2 jars of the *SAME* application, then i dont think thats possible. I believe classloader isolation is possible at application level and not jar level.