You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by "Francois Papon (JIRA)" <ji...@apache.org> on 2019/01/04 05:24:00 UTC

[jira] [Assigned] (SHIRO-537) Class load issue in OSGI in ClassUtils

     [ https://issues.apache.org/jira/browse/SHIRO-537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Francois Papon reassigned SHIRO-537:
------------------------------------

    Assignee: Francois Papon

> Class load issue in OSGI in ClassUtils
> --------------------------------------
>
>                 Key: SHIRO-537
>                 URL: https://issues.apache.org/jira/browse/SHIRO-537
>             Project: Shiro
>          Issue Type: Bug
>    Affects Versions: 1.2.3
>         Environment: OSGi Felix 4.0.3
>            Reporter: Tom Nelson
>            Assignee: Francois Papon
>            Priority: Major
>
> 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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)