Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-5563

Adding extension bundles causes wildfy/tomcat server to fail

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Abandoned
    • framework-5.6.2
    • None
    • File Install, Framework
    • None
    • wildfly - 10.0, tomcat - 8.5

    Description

      I am trying to implement extension bundles in the osgi container. We are using a wildfly and tomcat server. Starting the wildfly server with the added extension bundle causes the following errors:

      1:

      2017-02-22 14:36:55,916 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) Failed to install artifact: C:\ws\Servers\jboss\standalone\bundles\planon\ch.meschberger.sample.extension-0.0.1.jar: org.osgi.framework.BundleException: Could not create bundle object.

      2017-02-22 14:36:55,917 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) org.osgi.framework.BundleException: Could not create bundle object.

      2017-02-22 14:36:55,917 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) at org.apache.felix.framework.Felix.installBundle(Felix.java:2960)

      2017-02-22 14:36:55,917 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:165)

      2017-02-22 14:36:55,917 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) at org.apache.felix.fileinstall.internal.DirectoryWatcher.installOrUpdateBundle(DirectoryWatcher.java:1027)

      2017-02-22 14:36:55,917 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:941)

      2017-02-22 14:36:55,917 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:854)

      2017-02-22 14:36:55,917 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:483)

      2017-02-22 14:36:55,918 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:291)

      2017-02-22 14:36:55,918 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) Caused by: java.lang.UnsupportedOperationException: Unable to add extension bundle to FrameworkClassLoader - Maybe not an URLClassLoader?

      2017-02-22 14:36:55,918 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) at org.apache.felix.framework.ExtensionManager.addExtensionBundle(ExtensionManager.java:397)

      2017-02-22 14:36:55,918 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) at org.apache.felix.framework.Felix.installBundle(Felix.java:2926)

      2017-02-22 14:36:55,918 INFO [stdout] (fileinstall-C:\ws\Servers\jboss\standalone\bundles\planon) ... 6 more

      2:

      2017-02-22 14:29:46,307 INFO [stdout] (FelixStartLevel) Failed to install artifact: C:\ws\Servers\jboss\standalone\bundles\planon\ch.meschberger.sample.extension-0.0.1.jar: org.osgi.framework.BundleException: Could not create bundle object.

      2017-02-22 14:29:46,308 INFO [stdout] (FelixStartLevel) org.osgi.framework.BundleException: Could not create bundle object.

      2017-02-22 14:29:46,308 INFO [stdout] (FelixStartLevel) at org.apache.felix.framework.Felix.installBundle(Felix.java:2960)

      2017-02-22 14:29:46,308 INFO [stdout] (FelixStartLevel) at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:165)

      2017-02-22 14:29:46,309 INFO [stdout] (FelixStartLevel) at org.apache.felix.fileinstall.internal.DirectoryWatcher.installOrUpdateBundle(DirectoryWatcher.java:1027)

      2017-02-22 14:29:46,309 INFO [stdout] (FelixStartLevel) at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:941)

      2017-02-22 14:29:46,309 INFO [stdout] (FelixStartLevel) at org.apache.felix.fileinstall.internal.DirectoryWatcher.install(DirectoryWatcher.java:854)

      2017-02-22 14:29:46,309 INFO [stdout] (FelixStartLevel) at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:483)

      2017-02-22 14:29:46,309 INFO [stdout] (FelixStartLevel) at org.apache.felix.fileinstall.internal.DirectoryWatcher.start(DirectoryWatcher.java:224)

      2017-02-22 14:29:46,309 INFO [stdout] (FelixStartLevel) at org.apache.felix.fileinstall.internal.FileInstall.updated(FileInstall.java:252)

      2017-02-22 14:29:46,309 INFO [stdout] (FelixStartLevel) at org.apache.felix.fileinstall.internal.FileInstall.start(FileInstall.java:139)

      2017-02-22 14:29:46,309 INFO [stdout] (FelixStartLevel) at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)

      2017-02-22 14:29:46,310 INFO [stdout] (FelixStartLevel) at org.apache.felix.framework.Felix.activateBundle(Felix.java:2154)

      2017-02-22 14:29:46,310 INFO [stdout] (FelixStartLevel) at org.apache.felix.framework.Felix.startBundle(Felix.java:2072)

      2017-02-22 14:29:46,310 INFO [stdout] (FelixStartLevel) at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1299)

      2017-02-22 14:29:46,310 INFO [stdout] (FelixStartLevel) at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)

      2017-02-22 14:29:46,310 INFO [stdout] (FelixStartLevel) at java.lang.Thread.run(Thread.java:745)

      2017-02-22 14:29:46,310 INFO [stdout] (FelixStartLevel) Caused by: java.lang.UnsupportedOperationException: Unable to add extension bundle to FrameworkClassLoader - Maybe not an URLClassLoader?

      2017-02-22 14:29:46,311 INFO [stdout] (FelixStartLevel) at org.apache.felix.framework.ExtensionManager.addExtensionBundle(ExtensionManager.java:397)

      2017-02-22 14:29:46,311 INFO [stdout] (FelixStartLevel) at org.apache.felix.framework.Felix.installBundle(Felix.java:2926)

      2017-02-22 14:29:46,311 INFO [stdout] (FelixStartLevel) ... 14 more

      It seems that it goes wrong in the extensionManager class around here:

      ExtensionManager.class
      try
                  {
                      extensionManager = new ExtensionManager();
      
                      Felix.m_secureAction.addURLToURLClassLoader(Felix.m_secureAction.createURL(
                          Felix.m_secureAction.createURL(null, "http:", extensionManager),
                          "http://felix.extensions:9/", extensionManager),
                          Felix.class.getClassLoader());
                  }
      

      And in the the addURLtoIRLClassLoader it expects a urlclassloader but this is not provided because of wildfly/tomcat. That happens here:

      SecureAction.class
      public void addURLToURLClassLoader(URL extension, ClassLoader loader) throws Exception
          {
              if (System.getSecurityManager() != null)
              {
                  Actions actions = (Actions) m_actions.get();
                  actions.set(Actions.ADD_EXTENSION_URL_ACTION, extension, loader);
                  try
                  {
                      AccessController.doPrivileged(actions, m_acc);
                  }
                  catch (PrivilegedActionException e)
                  {
                      throw e.getException();
                  }
              }
              else
              {
                  Method addURL =
                      URLClassLoader.class.getDeclaredMethod("addURL",
                      new Class[] {URL.class});
                  addURL.setAccessible(true);
                  addURL.invoke(loader, new Object[]{extension});
              }
          }
      

      If you have any questions, let me know.

      Attachments

        1. extensionbundletest.zip
          260 kB
          Frank Blom
        2. com.planon.sample.extension-0.0.1.jar
          0.5 kB
          Frank Blom

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Frank Blom Frank Blom
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: