2 Replies Latest reply on Jan 29, 2009 9:51 AM by Grégory Joseph

    Why is the classloader different if my webapp is deployed as

    Grégory Joseph Newbie

      If I do this

      URLClassLoader cl = (URLClassLoader) Thread.currentThread().getContextClassLoader();
      URL[] urls = cl.getURLs();

      (I *know* I shouldn't be assuming this will get me a URLClassLoader, but unless I move to Java 1.6, there is no proper way to discover resources unless I know all their names, which I don't)

      Anyway - why is this code returning either an array of URLs pointing to WEB-INF/classes and each jar of my WEB-INF/lib when my webapp is deployed as an archive (which is how it behaved in jboss4, and how i expect it to behave indeed), while when my webapp is deployed as an exploded .war directory, all I get is ONE URL to WEB-INF/classes ?
      JBoss 4 behaves the same way for both cases, which is only reasonable.

      Not saying what I expect is the correct behaviour, but I'm really puzzled as to why to behavior is different at all depending on how the webapp is deployed.

      Is there even some hack I could do to get it to "work" the way I hoped it would ? Or some configuration I could change ?

      Thanks for any tip.