3 Replies Latest reply on Jul 25, 2005 5:06 AM by Kannan Ekanath

    Simple class loading issue

    Kannan Ekanath Newbie

      I am having an xml file "sonic-config.xml" and in my java code i am reading that file from the class path as follows,

      InputStream is = new ClassLoaderProvider() .getResourceAsStream(configResource); //here configResource is "sonic-config.xml"

      I have to put this sonic-config.xml . In fact i have put it in {JBOSS_HOME}/server/default/lib folder. But it does not pick it from there.

      I found the jboss-service.xml including the jars from the lib folder. I added an entry like this,

      //this line is to add lib directory itself to class path.

      But this doesnt seem to work. Is there any way, i can get this working?

        • 1. Re: Simple class loading issue
          jaikiran pai Master

          Change your code to:

          InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(configResource);

          instead of:

          InputStream inputStream = new ClassLoaderProvider().getResourceAsStream(configresource);

          • 2. Re: Simple class loading issue
            Kannan Ekanath Newbie

            The line will solve the issue but the call that i gave u was the one i debugged and the method call is in a CoreUtils library class which is reused across all apps+platforms implying that i cannot change the line.

            I was looking for some setting that is required in jboss-service to load it.

            I am using jboss-4.0.2 (I think jboss have reloaded the class loading fundamentals in this release).

            Any thoughts again? I apologise for not saying in my earlier post, that the code-piece was part of a Core Library that i cannot presently change?

            • 3. Re: Simple class loading issue
              Kannan Ekanath Newbie

              InputStream inputStream = new ClassLoaderProvider().getResourceAsStream(configresource);

              Basically this method call is part of a generic service locator library. I wanted to know if there is a fix at my application level, for this?