0 Replies Latest reply on Feb 29, 2012 1:00 PM by mreinhardt

    Nested OSGi Bundle Problem

    mreinhardt

      I've got a problem with my app migrating from JBoss 4.2.3 to 7.1. My Code does't load the bundle any more:

      public void start(ClassLoader classLoader, String bundlePath) throws IOException, BundleException {
          // check that the directory where the bundles are deployed is valid
          AssertionUtil.assertNotNull("bundlePath", bundlePath);
          AssertionUtil.assertNotNull("classLoader", classLoader);
          classLoader.getResource("HLRPos-EJB.jar");
          URL bundleURL = classLoader.getResource(bundlePath);
          if (bundleURL == null) {
            throw new FileNotFoundException("'" + bundlePath + "' cannot be found in the classloader '" + classLoader + "'");
          }
          
          if (bundleURL.getProtocol().equals("file")) {
            File bundleDirAsFile;
            try {
              bundleDirAsFile = new File(bundleURL.toURI());
            } catch (URISyntaxException ex) {
              throw new IOException(ex);
            }
            start(bundleDirAsFile);
            
          } else if (bundleURL.getProtocol().equals("jar")) {
            /* A JAR path */
            Collection < String > jarBundles = new ArrayList < String >();
            String jarPath = bundleURL.getPath().substring(5, bundleURL.getPath().indexOf("!")); //strip out only the JAR file
            JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"));
            Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
            while(entries.hasMoreElements()) {
              JarEntry entry = entries.nextElement();
              String name = entry.getName();
              if (name.startsWith(bundlePath) && name.endsWith(".jar")) {
                jarBundles.add( "jar:file:" + jarPath + "!/" + name);
              }
            }
            start(jarBundles);
          } else {
            throw new IOException("cannot handle URL: " + bundleURL);
          }
      

       

      bundleURL is always null. Any ideas?

       

      My App-Structure is the following

       

       

      MyApp.ear
      --> lib
                --> *.jar
                --> plugins
                     --> myPlug.jar
      
      -->MyApp-EJB.war
      -->MyApp-Web.war
                --> lib
                          -->ajax4jsf-1.1.1.jar
                          -->commons-el-1.0.jar
                          -->jdbc2_0-stdext.jar
                          -->jettison-1.1.jar
                          -->jsr311-api-1.1.1.jar
                          -->myfaces-api-1.2.11.jar
                          -->oscache-2.3.2.jar
                          -->standard.jar
                          -->asm-3.1.jar
                          -->flexjson-2.1.jar
                          -->jersey-bundle-1.6.jar
                          -->jsf-facelets-1.1.15-seam.jar
                          -->jstl-1.1.0.jar
                          -->myfaces-impl-1.2.11.jar
                          -->saxon9he.jar
                          -->tomahawk-1.1.11.jar
      
      

       

      myPlug.jar is an OSGI bundle...

       

      Any ideas?