Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-5345

Class loading issue in Eclipse Equinox OSGi container

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 7.37.0.Final
    • Fix Version/s: None
    • Component/s: core engine
    • Labels:
      None
    • Sprint:
      2020 Week 22-24 (from May 25)
    • Steps to Reproduce:
      Hide

      Use Drools inside Eclipse Equinox.

      Show
      Use Drools inside Eclipse Equinox.
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      When using Drools inside an Equinox OSGi container (Oxygen, org.eclipse.osgi-3.12.0.v20170512-1932.jar) the logic inside org.drools.relective.classloader.ProjectClassLoader#isOsgiClassLoader does not work properly, i.e. the OSGi runtime is not detected. This leads to "The Eclipse JDT Core jar is not in the classpath" because the shaded and packed compiler classes cannot be found.

      Cause of the problem seems to be the fact that the EquinoxClassLoader does not implement BundleReference directly but so does its superclass. I tried and patched ProjectClassLoader with the following snippet and this seems to work:

      private static boolean isOsgiClassLoader(final ClassLoader cl) {
          Class<?> clc = cl.getClass();
          while (clc != null && !clc.equals(ClassLoader.class)) {
              if (Stream.of(clc.getInterfaces()).map(Class::getSimpleName).anyMatch(name -> name.equals("BundleReference"))) {
                  return true;
              }
              clc = clc.getSuperclass();
          }
          return false;
      }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mfusco Mario Fusco
                Reporter:
                rschurig Richard Schurig
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: