slf4j - When trying to initiate Shiro SecurityManager from INI resource, encountered java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory -
i've started trialling shiro , trying code securitymanager ini resource when encountered
java.lang.classnotfoundexception: org.apache.commons.logging.logfactory
extended message:
exception in thread "main" java.lang.noclassdeffounderror: org/apache/commons/logging/logfactory @ org.apache.commons.beanutils.convertutilsbean.<init>(convertutilsbean.java:154) @ org.apache.commons.beanutils.beanutilsbean.<init>(beanutilsbean.java:113) @ org.apache.commons.beanutils.beanutilsbean$1.initialvalue(beanutilsbean.java:64) @ org.apache.commons.beanutils.beanutilsbean$1.initialvalue(beanutilsbean.java:60) @ org.apache.commons.beanutils.contextclassloaderlocal.get(contextclassloaderlocal.java:154) @ org.apache.commons.beanutils.beanutilsbean.getinstance(beanutilsbean.java:76) @ org.apache.commons.beanutils.propertyutilsbean.getinstance(propertyutilsbean.java:107) @ org.apache.commons.beanutils.propertyutils.getpropertydescriptor(propertyutils.java:498) @ org.apache.shiro.config.reflectionbuilder.istypedproperty(reflectionbuilder.java:409) @ org.apache.shiro.config.reflectionbuilder.applyproperty(reflectionbuilder.java:702) @ org.apache.shiro.config.reflectionbuilder.applysingleproperty(reflectionbuilder.java:364) @ org.apache.shiro.config.reflectionbuilder.applyproperty(reflectionbuilder.java:325) @ org.apache.shiro.config.reflectionbuilder$assignmentstatement.doexecute(reflectionbuilder.java:955) @ org.apache.shiro.config.reflectionbuilder$statement.execute(reflectionbuilder.java:887) @ org.apache.shiro.config.reflectionbuilder$beanconfigurationprocessor.execute(reflectionbuilder.java:765) @ org.apache.shiro.config.reflectionbuilder.buildobjects(reflectionbuilder.java:260) @ org.apache.shiro.config.inisecuritymanagerfactory.buildinstances(inisecuritymanagerfactory.java:167) @ org.apache.shiro.config.inisecuritymanagerfactory.createsecuritymanager(inisecuritymanagerfactory.java:130) @ org.apache.shiro.config.inisecuritymanagerfactory.createsecuritymanager(inisecuritymanagerfactory.java:108) @ org.apache.shiro.config.inisecuritymanagerfactory.createinstance(inisecuritymanagerfactory.java:94) @ org.apache.shiro.config.inisecuritymanagerfactory.createinstance(inisecuritymanagerfactory.java:46) @ org.apache.shiro.config.inifactorysupport.createinstance(inifactorysupport.java:123) @ org.apache.shiro.util.abstractfactory.getinstance(abstractfactory.java:47) @ core.server.testshiro(server.java:121) @ core.server.main(server.java:57) caused by: java.lang.classnotfoundexception: org.apache.commons.logging.logfactory @ java.net.urlclassloader.findclass(urlclassloader.java:381) @ java.lang.classloader.loadclass(classloader.java:424) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:331) @ java.lang.classloader.loadclass(classloader.java:357) ... 25 more
my code stated core.server.testshiro(server.java:121)
is:
org.apache.shiro.mgt.securitymanager securitymanager = factory.getinstance();
my guess is, there issue shiro.ini file specified in previous line of code factory<org.apache.shiro.mgt.securitymanager> factory = new inisecuritymanagerfactory("classpath:shiro.ini");
, based on error message, seems beanutils
library needs org.apache.commons.logging.logfactory
class
my question not how correct shiro.ini, rather how solve classnotfoundexception.
note using log4j2 , have included log4j2 jars, slf4j bridging adapters (my understanding shiro need these) jars in library:
- log4j-api-2.8.2.jar
- log4j-core-2.8.2.jar
- log4j-slf4j-impl-2.8.2.jar
- slf4j-api-1.7.25.jar
as hibernate jars
i've done search , saw les hazlewood's response shiro user site's question java.lang.noclassdeffounderror: org/apache/commons/logging/logfactory @ explicitly excluding jcl. 3 options stated directed site doesn't apply not using maven-ized project, standalone java project in netbeans. however, i've tried including commons-logging-1.2.jar
, jcl-over-slf4j-1.7.25.jar
in lib folder (which gathered similar "provide scope" instruction site) doesn't solve exception.
i've tried including log4j-jcl-2.8.2.jar
in lib folder, same exception still doesn't go away.
any , guidance appreciated. in advance! cheers.
i got same error when using shiro-web. since use slf4j add runtime dependency jcl-over-slf4j. did , resolved exception. if still error not doing right - e.g. placing jars correct location, ...
do not include commons-logging jcl bridge. either use jcl bridge slf4j or use commons-logging both not make sense.
wiki
Comments
Post a Comment