2 Replies Latest reply on Feb 20, 2008 1:02 PM by Brad Fach

    xml configuration file for application

    Brad Fach Newbie


      Does anyone have any information about how to place an XML file on the classpath within an .ear file in order to access using the getResourceAsStream call?

      I have attempted with the following ways:

      Inside the application jar
      Inside the ear
      Inside a WEB-INF directory

      Please if somebody knows the answer to this I would really appreciate it.



        • 1. Re: xml configuration file for application
          Andrew Rubinger Master

          Looks like the real issue you're asking is "How do I access the ClassLoader for a given XML file?"

          This would enable you to do cl.getResourceAsStream("whatever.xml");

          However, the JEE spec leaves room for vendors to plug in their own custom classloading strategies to enable features such as hot deployment. So you've got no hook to access the CL you need.

          Since classes are linked to the CL that defined them, you might try packaging your XML in an EJB JAR, and then attempting to get to it by saying something like:


          ...but this would assume that the same CL was used for all resources in your EJB JAR.

          I think a better question to ask is: what are you doing that requires you to access something packaged in your application's deployable units? Surely there's a more elegant way for you to get at this configuration?


          • 2. Re: xml configuration file for application
            Brad Fach Newbie


            Thanks for the reply. What I am attempting to do is get a few small pieces of information to a MDB packaged in an ear file. This information is bootstrap for the application and therefore needs to be given someone prior to deployment.

            I have packaged the XML in the .ear file however this has not solved the problem. Is there a better way to approach this?

            I attempted to configure using the deployment descriptor xml as you would do it with a .sar however this did not seem to work.

            Am I going about this the wrong way?