2 Replies Latest reply on Mar 10, 2005 7:51 AM by nobel

    classloading of properties file

    nobel

      Hello!

      I have something that works which I didnt expect it would :-)

      Using jboss326, I have 2 ears that each contain a war. Both wars are identical with the exception of the content in a x.properties file. The x.properties file is loaded with a class org.apache.struts.util.PropertyMessageResources using

      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      is = classLoader.getResourceAsStream(name);
      props.load(is);
      

      Checking the UnifiedLoadedRepository3 from the log or the jmx-console, as described in the excellent documentation, I find that org.apache.struts.util.PropertyMessageResources has two UCL associated with it. But I dont find the x.properties file UCL:ed anywhere and to my surprise the properties dont interfere as I expected they would. Doesnt the ULR3 cache properties? Or does the thread context class loader bypass the ULR3 mechanism?

      BR Niklas


        • 1. Re: classloading of properties file

          looks like ressources are not part of the repository - what happens, if you remove the properties file from one of the deployments?

          • 2. Re: classloading of properties file
            nobel

            After having had a closer look at the log I see that the properties file is loaded into the URL3. Thus there will be only one "version" of the properties file shared by both webapps. How come both webapps seem to use their own version?

            Taking a look at the Struts code I see that the properties file was loaded from an instance of PropertyMessageResources using the TCL which I assume will bypass the ULR3. Using class.getClassLoader() would have used the ULR3 and the shared properties file. Furthermore the properties file was luckily not loaded in the constructor of PropertyMessageResources.

            So due to a number of happy circumstances this particular properties file did not conflict with the same properties file in the other web archive. I guess that if you deploy several wars under the same JBoss instance you either have to be very careful when you load resources or turn off unified class loading for the war. BR Niklas.