java.lang.ClassNotFoundException: net.spy.memcached.compat.log.SLF4JLogger
java.lang.ClassNotFoundException: net.spy.memcached.compat.log.SLF4JLogger
我添加到 Java opts -Dnet.spy.log.LoggerImpl=net.spy.memcached.compat.log.SLF4JLogger
将 spymemcached 设置为使用 slf4j 作为记录器。但是我在 tomcat6 日志中收到以下警告,我对错误
感到困惑
net.spy.memcached.compat.log.SLF4JLogger not found while initializing net.spy.compat.log.LoggerFactory java.lang.ClassNotFoundException: net.spy.memcached.compat.log.SLF4JLogger
怎么可能找不到class SLF4JLogger。它正在初始化 LoggerFactory 意味着 net.spy 包可用,更一般地说,间谍内存缓存 jar 可用。那怎么可能找不到另一个class.
log4j: setFile ended log4j: Adding appender named [SecurityAuditAppender] to category [SecurityAuditLogger]. Warning: net.spy.memcached.compat.log.SLF4JLogger not found while initializing net.spy.compat.log.LoggerFactory java.lang.ClassNotFoundException: net.spy.memcached.compat.log.SLF4JLogger
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at net.spy.memcached.compat.log.LoggerFactory.getConstructor(LoggerFactory.java:131)
at net.spy.memcached.compat.log.LoggerFactory.getNewInstance(LoggerFactory.java:115)
at net.spy.memcached.compat.log.LoggerFactory.internalGetLogger(LoggerFactory.java:98)
at net.spy.memcached.compat.log.LoggerFactory.getLogger(LoggerFactory.java:87)
at net.spy.memcached.compat.log.LoggerFactory.getLogger(LoggerFactory.java:73)
at net.spy.memcached.compat.SpyThread.getLogger(SpyThread.java:60)
at net.spy.memcached.MemcachedConnection.createConnections(MemcachedConnection.java:152)
at net.spy.memcached.MemcachedConnection.<init>(MemcachedConnection.java:128)
at net.spy.memcached.DefaultConnectionFactory.createConnection(DefaultConnectionFactory.java:176)
at net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:193)
at net.spy.memcached.spring.MemcachedClientFactoryBean.getObject(MemcachedClientFactoryBean.java:72)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1442)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
如果 WebAppClassLoader
抛出 ClassNotFoundException
,则 class 不在您的 Web 应用程序中。在撰写本文时获取 latest version of the spymemcached
client jar (2.12.1)并将其放入 Web 应用程序的 WEB-INF/lib
目录中。从该目录中删除任何其他 spymemcached
jar 以避免 class 加载冲突。
net.spy.memcached.compat.log.SLF4JLogger
直到版本 2.9.0 才被引入,所以如果您使用的是 net.spy:spymemcached
的旧版本,那就可以解释为什么它可以找到 LoggerFactory
但是不是 SLF4JLogger
.
您可以使用 Dependency Plugin
检查您的依赖关系树
mvn dependency:tree -Dverbose -Dincludes=spymemcached
如果您看到除 2.12.1 之外的任何其他版本,请检查它的顶级引用并将排除标记添加到它的 Maven 依赖项元素中,例如:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.0.3.RELEASE</version>
<exclusions>
<exclusion>
<groupId>net.spy</groupId>
<artifactId>spymemcached</artifactId>
</exclusion>
</exclusions>
</dependency
我添加到 Java opts -Dnet.spy.log.LoggerImpl=net.spy.memcached.compat.log.SLF4JLogger 将 spymemcached 设置为使用 slf4j 作为记录器。但是我在 tomcat6 日志中收到以下警告,我对错误
感到困惑net.spy.memcached.compat.log.SLF4JLogger not found while initializing net.spy.compat.log.LoggerFactory java.lang.ClassNotFoundException: net.spy.memcached.compat.log.SLF4JLogger
怎么可能找不到class SLF4JLogger。它正在初始化 LoggerFactory 意味着 net.spy 包可用,更一般地说,间谍内存缓存 jar 可用。那怎么可能找不到另一个class.
log4j: setFile ended log4j: Adding appender named [SecurityAuditAppender] to category [SecurityAuditLogger]. Warning: net.spy.memcached.compat.log.SLF4JLogger not found while initializing net.spy.compat.log.LoggerFactory java.lang.ClassNotFoundException: net.spy.memcached.compat.log.SLF4JLogger
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at net.spy.memcached.compat.log.LoggerFactory.getConstructor(LoggerFactory.java:131)
at net.spy.memcached.compat.log.LoggerFactory.getNewInstance(LoggerFactory.java:115)
at net.spy.memcached.compat.log.LoggerFactory.internalGetLogger(LoggerFactory.java:98)
at net.spy.memcached.compat.log.LoggerFactory.getLogger(LoggerFactory.java:87)
at net.spy.memcached.compat.log.LoggerFactory.getLogger(LoggerFactory.java:73)
at net.spy.memcached.compat.SpyThread.getLogger(SpyThread.java:60)
at net.spy.memcached.MemcachedConnection.createConnections(MemcachedConnection.java:152)
at net.spy.memcached.MemcachedConnection.<init>(MemcachedConnection.java:128)
at net.spy.memcached.DefaultConnectionFactory.createConnection(DefaultConnectionFactory.java:176)
at net.spy.memcached.MemcachedClient.<init>(MemcachedClient.java:193)
at net.spy.memcached.spring.MemcachedClientFactoryBean.getObject(MemcachedClientFactoryBean.java:72)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1442)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
如果 WebAppClassLoader
抛出 ClassNotFoundException
,则 class 不在您的 Web 应用程序中。在撰写本文时获取 latest version of the spymemcached
client jar (2.12.1)并将其放入 Web 应用程序的 WEB-INF/lib
目录中。从该目录中删除任何其他 spymemcached
jar 以避免 class 加载冲突。
net.spy.memcached.compat.log.SLF4JLogger
直到版本 2.9.0 才被引入,所以如果您使用的是 net.spy:spymemcached
的旧版本,那就可以解释为什么它可以找到 LoggerFactory
但是不是 SLF4JLogger
.
您可以使用 Dependency Plugin
检查您的依赖关系树mvn dependency:tree -Dverbose -Dincludes=spymemcached
如果您看到除 2.12.1 之外的任何其他版本,请检查它的顶级引用并将排除标记添加到它的 Maven 依赖项元素中,例如:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.0.3.RELEASE</version>
<exclusions>
<exclusion>
<groupId>net.spy</groupId>
<artifactId>spymemcached</artifactId>
</exclusion>
</exclusions>
</dependency