steinarb commented on issue #2083: URL: https://github.com/apache/shiro/issues/2083#issuecomment-2799994599
The core of the problem is this: ``` Caused by: org.apache.shiro.lang.util.UnknownClassException: Unable to load class named [org.apache.shiro.subject.SimplePrincipalCollection] from the thread context, current, or system/application ClassLoaders. All heuristics have been exhausted. Class could not be found. at org.apache.shiro.lang.io.ClassResolvingObjectInputStream.resolveClass(ClassResolvingObjectInputStream.java:55) ~[!/:2.0.2] ``` The class ClassResolvingObjectInputStream is in the shiro-lang OSGi bundle (i.e. jar file with import-package and export-package declarations in the MANIFEST.MF). For a class to be loaded and, found by ClassResolvingObjectInputStream, the package the class resides (i.e. org.apache.shiro.subject for SimplePrincipalCollection) in needs to be imported into shiro-lang. And the package org.apache.shiro.subject (found in shiro-core) is not listed in the Import-Package declaration of the shiro-lang MANIFEST.MF (formatted for readability): ``` Import-Package: javax.servlet.jsp;resolution:=optional, java.beans, java.io, java.lang, java.lang.annotation, java.lang.invoke, java.lang.ref, java.lang.reflect, java.net, java.text, java.util, java.util.concurrent, java.util.concurrent.locks, org.apache.shiro.lang;version="[2.0,3)", org.apache.shiro.lang.codec;version="[2.0,3)", org.apache.shiro.lang.util;version="[2.0,3)", org.slf4j;version="[2.0,3)" ``` Below is the export-package of the MANIFEST.MF of shiro-core, also reformatted for readability, and I see one obvious problem: packages in shiro-core require packages from shiro-lang (which means shiro-lang can't import packages from shiro-core, because then you would have a loop). So this requires changes to shiro to fix. There are two ways of breaking the loop: 1. Put everything in one huge jar (the quick and dirty and wrong way) 2. Split out the stuff included both places into a separate bundle and import its packages in the bundles that need it Export-package of the MANIFEST.MF of shiro-core, reformatted for readability: ``` Export-Package: org.apache.shiro;version="2.0.2";uses:="org.apache.shiro.lang,org.apache.shiro.mgt,org.apache.shiro.subject", org.apache.shiro.aop;version="2.0.2";uses:="org.apache.shiro.subject",org.apache.shiro.authc;version="2.0.2";uses:="org.apache.shiro.authz,org.apache.shiro.lang,org.apache.shiro.lang.util,org.apache.shiro.subject", org.apache.shiro.authc.credential;version="2.0.2";uses:="org.apache.shiro.authc,org.apache.shiro.crypto.hash,org.apache.shiro.crypto.hash.format,org.apache.shiro.lang.codec,org.apache.shiro.lang.util", org.apache.shiro.authc.pam;version="2.0.2";uses:="org.apache.shiro.authc, org.apache.shiro.realm,org.apache.shiro.subject", org.apache.shiro.authz;version="2.0.2";uses:="org.apache.shiro.authz.permission,org.apache.shiro.lang,org.apache.shiro.realm,org.apache.shiro.subject", org.apache.shiro.authz.annotation;version="2.0.2", org.apache.shiro.authz.aop;version="2.0.2";uses:="org.apache.shiro.aop,org.apache.shiro.authz", org.apache.shiro.authz.permission;version="2.0.2";uses:="org.apache.shiro.authz,org.apache.shiro.lang", org.apache.shiro.concurrent;version="2.0.2";uses:="org.apache.shiro.subject", org.apache.shiro.dao;version="2.0.2";uses:="org.apache.shiro.lang",org.apache.shiro.env;version="2.0.2";uses:="org.apache.shiro.config,org.apache.shiro.lang,org.apache.shiro.lang.util,org.apache.shiro.mgt", org.apache.shiro.ini;version="2.0.2";uses:="org.apache.shiro.config,org.apache.shiro.config.ogdl,org.apache.shiro.mgt,org.apache.shiro.realm,org.apache.shiro.util", org.apache.shiro.jndi;version="2.0.2";uses:="javax.naming,org.apache.shiro.lang.util", org.apache.shiro.ldap;version="2.0.2";uses:="org.apache.shiro.dao", org.apache.shiro.mgt;version="2.0.2";uses:="org.apache.shiro.authc,org.apache.shiro.authz,org.apache.shiro.cache,org.apache.shiro.crypto.cipher,org.apache.shiro.event,org.apache.shiro.lang.io,org.apache.shiro.lang.util,org.apache.shiro.realm,org.apache.shiro.session,org.apache.shiro.session.mgt,org.apache.shiro.subject", org.apache.shiro.realm;version="2.0.2";uses:="org.apache.shiro.authc,org.apache.shiro.authc.credential,org.apache.shiro.authz,org.apache.shiro.authz.permission,org.apache.shiro.cache,org.apache.shiro.lang.util,org.apache.shiro.subject", org.apache.shiro.realm.activedirectory;version="2.0.2";uses:="javax.naming,javax.naming.ldap,org.apache.shiro.authc,org.apache.shiro.authz,org.apache.shiro.realm.ldap,org.apache.shiro.subject", org.apache.shiro.realm.jdbc;version="2.0.2";uses:="javax.sql,org.apache.shiro.authc,org.apache.shiro.authz,org.apache.shiro.realm, org.apache.shiro.subject", org.apache.shiro.realm.jndi;version="2.0.2";uses:="org.apache.shiro.jndi,org.apache.shiro.realm", org.apache.shiro.realm.ldap;version="2.0.2";uses:="javax.naming,javax.naming.directory,javax.naming.ldap,org.apache.shiro.authc,org.apache.shiro.authz,org.apache.shiro.realm,org.apache.shiro.subject", org.apache.shiro.realm.text;version="2.0.2";uses:="org.apache.shiro.config,org.apache.shiro.lang.util,org.apache.shiro.realm", org.apache.shiro.session;version="2.0.2";uses:="org.apache.shiro.lang", org.apache.shiro.session.mgt;version="2.0.2";uses:="org.apache.shiro.authz,org.apache.shiro.cache,org.apache.shiro.event,org.apache.shiro.lang.util,org.apache.shiro.session,org.apache.shiro.session.mgt.eis,org.apache.shiro.util", org.apache.shiro.session.mgt.eis;version="2.0.2";uses:="org.apache.shiro.cache,org.apache.shiro.session", org.apache.shiro.subject;version="2.0.2";uses:="org.apache.shiro.authc,org.apache.shiro.authz,org.apache.shiro.lang,org.apache.shiro.mgt,org.apache.shiro.session", org.apache.shiro.subject.support;version="2.0.2";uses:="org.apache.shiro.authc,org.apache.shiro.authz,org.apache.shiro.mgt,org.apache.shiro.session,org.apache.shiro.session.mgt,org.apache.shiro.subject,org.apache.shiro.util", org.apache.shiro.util;version="2.0.2";uses:="org.apache.shiro.authz,org.apache.shiro.authz.permission,org.apache.shiro.lang.util,org.apache.shiro.mgt,org.apache.shiro.subject!" ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@shiro.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@shiro.apache.org For additional commands, e-mail: issues-h...@shiro.apache.org