You will want to explicitly exclude the commons-logging jar from any dependency that requires it and additionally specify a dependency on SLF4J's 'jcl-over-slf4j' jar. The dependency will use the jcl-over-slfj4 jar and 'think' it is actually commons-logging. That jar in turn acts as a proxy and delegates all calls to the real SLF4J api.
SLF4J mentions this in their user manual here: http://www.slf4j.org/legacy.html and explicitly about commons-logging here: http://www.slf4j.org/faq.html#excludingJCL HTH! Cheers, Les On Thu, Jun 3, 2010 at 5:57 AM, armandoxxx <[email protected]> wrote: > > Hi .. I'm trying Shiro and I ran into a problem with dependencies. > > For my tests I'm just using Shiro-core and here's the exception I'm getting. > > > java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory > at > org.apache.commons.beanutils.ConvertUtilsBean.<init>(ConvertUtilsBean.java:130) > at > org.apache.commons.beanutils.BeanUtilsBean.<init>(BeanUtilsBean.java:110) > at > org.apache.commons.beanutils.BeanUtilsBean$1.initialValue(BeanUtilsBean.java:68) > at > org.apache.commons.beanutils.ContextClassLoaderLocal.get(ContextClassLoaderLocal.java:80) > at > org.apache.commons.beanutils.BeanUtilsBean.getInstance(BeanUtilsBean.java:78) > at > org.apache.commons.beanutils.PropertyUtilsBean.getInstance(PropertyUtilsBean.java:101) > at > org.apache.commons.beanutils.PropertyUtils.getPropertyDescriptor(PropertyUtils.java:309) > at > org.apache.shiro.config.ReflectionBuilder.isTypedProperty(ReflectionBuilder.java:241) > at > org.apache.shiro.config.ReflectionBuilder.applyProperty(ReflectionBuilder.java:349) > at > org.apache.shiro.config.ReflectionBuilder.applySingleProperty(ReflectionBuilder.java:200) > at > org.apache.shiro.config.ReflectionBuilder.applyProperty(ReflectionBuilder.java:161) > at > org.apache.shiro.config.ReflectionBuilder.buildObjects(ReflectionBuilder.java:121) > at > org.apache.shiro.config.IniSecurityManagerFactory.buildInstances(IniSecurityManagerFactory.java:171) > at > org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:120) > at > org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:98) > at > org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:84) > at > org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:42) > at > org.apache.shiro.config.IniFactorySupport.createInstance(IniFactorySupport.java:124) > at > org.apache.shiro.util.AbstractFactory.getInstance(AbstractFactory.java:48) > at > org.dropchop.jop.security.SecurityGuard.<init>(SecurityGuard.java:28) > at > org.dropchop.jop.security.SecurityGuardTest.testLoginLogout(SecurityGuardTest.java:146) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) > at > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) > at > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) > at > org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) > at > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) > at > org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46) > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180) > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41) > at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173) > at > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) > at > org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) > at org.junit.runners.ParentRunner.run(ParentRunner.java:220) > at > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) > at > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) > Caused by: java.lang.ClassNotFoundException: > org.apache.commons.logging.LogFactory > at java.net.URLClassLoader$1.run(URLClassLoader.java:202) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:190) > at java.lang.ClassLoader.loadClass(ClassLoader.java:307) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) > at java.lang.ClassLoader.loadClass(ClassLoader.java:248) > ... 45 more > > > My guess is that beanutils depends on commons-logging. Ok, BUT to handle > this the right way, what should I do ? Should I add dependency in my > pom.xml file for common-logging or is there any other way ? > > dependency in my POM > > <dependency> > <groupId>org.apache.shiro</groupId> > <artifactId>shiro-core</artifactId> > <version>1.0.0-incubating</version> > </dependency> > > > kind regards > > Armando Ota > -- > View this message in context: > http://shiro-user.582556.n2.nabble.com/java-lang-NoClassDefFoundError-org-apache-commons-logging-LogFactory-tp5135020p5135020.html > Sent from the Shiro User mailing list archive at Nabble.com. >
