Uploaded image for project: 'Shiro'
  1. Shiro
  2. SHIRO-537

Class load issue in OSGI in ClassUtils

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.2.3
    • 2.0.0-alpha
    • None
    • None
    • OSGi Felix 4.0.3

    Description

      I had the same issue that is described in:
      http://stackoverflow.com/questions/20653146/how-to-load-class-in-an-osgi-e4-environment-while-using-shiro where it was suggested a bug was entered but never was, so here it is. A similar workaround worked for me:

      Thread currentThread = Thread.currentThread();
      ClassLoader originalCl = currentThread.getContextClassLoader();
      try

      { Class<?> clazz = ((InfrastructureServer) server).getBundleContext().getBundle() .loadClass(CustomRolePermissionResolver.class.getName()); ClassLoader bundleClassLoader = clazz.getClassLoader(); currentThread.setContextClassLoader(bundleClassLoader); webappContext.deploy(httpServer); }

      catch (ClassNotFoundException e)

      { // TODO Auto-generated catch block e.printStackTrace(); }

      finally

      { currentThread.setContextClassLoader(originalCl); }

      In addition, commons-collections 3.2.1 must be used in an OSGi environment, I suggest bumping your dependency.

      Attachments

        Issue Links

          Activity

            People

              fpapon Francois Papon
              tomnelson178 Tom Nelson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: