2 Replies Latest reply on Apr 14, 2008 10:30 AM by neil1967

    ClassLoader.getSystemResource() failing in a jar inside a wa

    neil1967

      Hello,

      JBoss newbie here. I have been handed a java web app to deploy on jboss 5.0.0.Beta4 with jdk 1.6.

      In a class file inside a jar inside a war, the code calls ClassLoader.getSystemResource() to access a wsdl file. The wsdl file is copied into the jar file in the directory meta-inf/wsdl. Because of that, the call inside the class to the getSystemResource() method is passed the string passed "meta-inf/wsdl/filename.wsdl" but this fails to find the wsdl file. The war file containing the jar file is dropped into the server/default/deploy directory on jboss, and inside the war, the jar is in the WEB-INF/lib directory.

      Here's what I tried:

      1) changing where the wsdl gets copied to, setting it in the WEB-INF/lib directory where the jar is so that I just did ClassLoader.getSystemResource("filename.wsdl"). This doesn't work.

      2) In the web.xml file that goes along with the web app, setting to the <JBOSS_HOME>/server/default/deploy directory, where the war file is. This doesn't work.

      Any help would be great.

      Thanks!!

      Neil

        • 1. Re: ClassLoader.getSystemResource() failing in a jar inside
          peterj

          Try:

          Thread.currrentThread().getContextClassLoader().getResource("META-INF/wsdl/filename.wsdl");

          If that doesn't work, move the wsdl file to wsdl/filename.wsdl and try:

          Thread.currrentThread().getContextClassLoader().getResource("wsdl/filename.wsdl");

          (Not sure if getResource will look within META-INF.)

          • 2. Re: ClassLoader.getSystemResource() failing in a jar inside
            neil1967

            The first call you suggested worked. Just so I understand the difference between what the code I'd been handed was trying to do and what you suggested, did this work because the way java handles getSystemResource is such that it doesn't know which class loader to use and it has to use the one for the current context? Thanks for your help.