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

Class load issue in OSGI in ClassUtils

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.3
    • Fix Version/s: 2.0.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: