3 Replies Latest reply on Sep 17, 2009 2:50 AM by jaikiran pai

    jboss 5 and ClassLoader problem

    jin hanlin Newbie

      I would like to load jboss published in the EAR file jar all xml, but not to load path, Jboss 4 in the original path:the jar's file path = D: / Java/Jboss/server/default/tmp/deploy/tmp29312liveos.ear- contents / liveos.jar, but in jboss 5 :the jar's file path = D: / Java / Jboss / server / default / deploy / liveos.ear / liveos.jar, why not the jar's file path = D: \ Java \ Jboss \ server \ default \ tmp \ vfs-nested.tmp/02804a5d_liveos.jar, such JarFile jarFile = new JarFile (filename); can not find jar

      private void loadConfig() {
      try {
      String osName = System.getProperty("os.name");
      ClassLoader loader = Thread.currentThread().getContextClassLoader();
      String url = loader.getResource(BillConfigCache.class.getName().replace(".", "/") + ".class").toString();
      logger.debug("Current class's filepath : " + url);
      String filename;
      if (osName != null && osName.indexOf("Windows") != -1) {
      logger.debug("Current class begin : " + url.substring(url.indexOf("/")) +"/"+url.substring(url.indexOf(".jar/")+4));
      filename = url.substring(url.indexOf("/") + 1, url.indexOf(".jar/") + 4);
      //filename = url.substring(url.indexOf("/") + 1, url.indexOf("!"));//Jboss 4
      } else {
      filename = url.substring(url.indexOf("/"), url.indexOf(".jar/") + 4);
      //filename = url.substring(url.indexOf("/"), url.indexOf("!"));//Jboss 4
      }
      filename = filename.replace("%20", " ");
      logger.debug("jar's file path = " + filename);

      JarFile jarFile = new JarFile(filename);
      Enumeration entries = jarFile.entries();
      while (entries.hasMoreElements()) {
      JarEntry jarEntry = entries.nextElement();
      String configFile = jarEntry.getName();
      if (jarEntry.getName().toLowerCase().endsWith("xml")) {
      logger.debug("Bill Config File : " + configFile);
      InputStream inputStream = loader.getResourceAsStream(configFile);
      List templateList = createBillTemplate(inputStream);
      cacheBillTemplate(templateList);
      }
      }


      } catch (Exception e) {
      logger.error(e.getMessage(), e);
      throw new PAOSBusinessException(e.getMessage(), e);
      }
      }

      Any suggestions?thanks!