Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1087

ClassLoader problems when used as OSGI bundles

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Major Major
    • None
    • 2.3.0.Final
    • None
    • Hide

      Load the bundles and starts them.
      In your own bundle, try to create a configuration, and then use it to get a repository:

      JcrConfiguration conf = new JcrConfiguration(); // The code already breaks here

      Show
      Load the bundles and starts them. In your own bundle, try to create a configuration, and then use it to get a repository: JcrConfiguration conf = new JcrConfiguration(); // The code already breaks here

      When I try to do a new JcrConfiguration(), a NoClassDefFoundException is raised (it can't find the class org.modeshape.graph.mimetype.ExtensionBasedMimeTypeDetector).

      Seems to me that the Class.forName uses a ClassLoader that can't look into the installed bundles.

      The content of the current thread classloader is the following:

      interface org.apache.sling.launchpad.base.shared.Notifiable
      class org.apache.sling.launchpad.app.Main
      class org.apache.sling.launchpad.app.Main$2
      class org.apache.sling.launchpad.base.shared.Loader
      class org.apache.sling.launchpad.app.Main$1
      class org.apache.sling.launchpad.app.ControlListener
      class org.apache.sling.commons.osgi.bundleversion.BundleVersionInfo
      class org.apache.sling.commons.osgi.bundleversion.FileBundleVersionInfo
      class org.apache.sling.launchpad.base.shared.LauncherClassLoader
      class org.apache.sling.launchpad.base.shared.Loader$1
      class org.osgi.framework.Version
      interface org.apache.sling.launchpad.base.shared.Launcher
      interface org.apache.sling.launchpad.api.LaunchpadContentProvider

      I patched the code into the class ExecutionContext so that I could override the method getClassLoaderFactory and pass a new clf to the class org.modeshape.graph.mimetype.MimeTypeDetectors, but now I have another exception when trying to create a new instance of the found class:
      Could not initialize repository org.modeshape.common.SystemFailureException: java.lang.IllegalArgumentException: The stream argument may not be null
      at org.modeshape.common.component.ComponentLibrary.newInstance(ComponentLibrary.java:318)

      Thanks for any help you can give me.
      Ale

              Unassigned Unassigned
              a.novarini Alessandro Novarini (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: