2011-09-13 127 views
0

我們一直在使用ActiveMQ 5.2,並且正在考慮升級到ActiveMQ 5.5。升級到ActiveMQ 5.5會拋出java.lang.ClassNotFoundException:org.slf4j.Logger

在開發模式下運行時,我們使用spring framework(2.5.6)並使用Jetty(6.1.2)。

我還沒有對applicationContext文件做任何修改,但改變了類路徑,以便包含新的jar文件(activemq-core-5.5.0.jar,xbean-spring-3.7.jar)。

然而,開發實例失敗與以下錯誤消息:

org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext-activemq.xml]; nested exception is java.lang.NoClassDefFoundError: org/slf4j/Logger at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:543) at org.mortbay.jetty.servlet.Context.startContext(Context.java:136) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448) at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:447) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.jetty.Server.doStart(Server.java:222) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:543) at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:421) at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1035) at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:783) at com.google.gwt.dev.DevMode.main(DevMode.java:275) Caused by: java.lang.NoClassDefFoundError: org/slf4j/Logger at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.getDeclaredMethods(Unknown Source) at java.beans.Introspector$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.beans.Introspector.getPublicDeclaredMethods(Unknown Source) at java.beans.Introspector.getTargetMethodInfo(Unknown Source) at java.beans.Introspector.getBeanInfo(Unknown Source) at java.beans.Introspector.getBeanInfo(Unknown Source) at java.beans.Introspector.getBeanInfo(Unknown Source) at java.beans.Introspector.(Unknown Source) at java.beans.Introspector.getBeanInfo(Unknown Source) at org.apache.xbean.spring.context.v2c.XBeanQNameHelper.getBeanInfo(XBeanQNameHelper.java:78) at org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.getPropertyDescriptor(XBeanNamespaceHandler.java:581) at org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.addAttributeProperties(XBeanNamespaceHandler.java:333) at org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseBeanFromExtensionElement(XBeanNamespaceHandler.java:225) at org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseBeanFromExtensionElement(XBeanNamespaceHandler.java:276) at org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:156) at org.apache.xbean.spring.context.v2.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:49) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398) ... 31 more Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload$WebAppClassLoaderExtension.findClass(JettyLauncher.java:354) at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:366) at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 56 more

我想除了額外的罐子(SLF4J-API 1.5.11.jar),其中包含的記錄器接口的類路徑,但仍然得到了同樣的異常。 ApplicationContext中

隊列定義是這樣的

`

<bean id="connectionFactory" 
    class="org.apache.activemq.spring.ActiveMQConnectionFactory"> 
    <property name="brokerURL" value="vm://localhost?async=false" /> 
    <property name="redeliveryPolicy" ref="redeliveryPolicy"/> 
</bean> 

<bean id="jmsTemplate" 
    class="org.springframework.jms.core.JmsTemplate"> 
    <property name="connectionFactory" ref="connectionFactory" /> 
    <property name="defaultDestination" ref="httpPostQueue" /> 
</bean> 

<!-- brokers --> 
<amq:broker id="broker" start="false" useJmx="false"> 
    <amq:destinationPolicy> 
     <amq:policyMap> 
      <amq:policyEntries> 
       <amq:policyEntry queue="emailQueue"> 
        <amq:deadLetterStrategy> 
         <amq:individualDeadLetterStrategy queuePrefix="DLQ."/> 
        </amq:deadLetterStrategy> 
       </amq:policyEntry> 
      </amq:policyEntries> 
     </amq:policyMap> 
    </amq:destinationPolicy> 
    <amq:persistenceAdapter> 
     <amq:jdbcPersistenceAdapter dataSource="#dataSource" useDatabaseLock="false"/> 
    </amq:persistenceAdapter> 
</amq:broker>` 

我需要什麼其他的變化,以ActiveMQ的升級到5.5做?

謝謝你們提前。

回答

0

AMQ 5.5使用SLF4J,並提供在ActiveMQ中,所有SLF4J的API,但您的應用程序應包括粘合劑之一(見http://www.slf4j.org/codes.html#StaticLoggerBinder

+0

其實我有添加所有需要的jar(SLF4J-API-1.5.11,SLF4J-log4j12-1.5.11.jar)用於在SLF4J Jetty的WEB-INF/lib。這有點奇怪,但我們遇到了一些情況,我們不得不在classpath中指定jar文件夾。 – user941479

0

我升級到5.5的ActiveMQ時有同樣的問題。事實證明,ActiveMQ 5.5使用更新版本的slf4j。我們仍在使用1.4.2,這太舊了。在我們的Maven POM文件,我更新了SLF4J依賴於:

<dependency> 
    <groupId>org.slf4j</groupId> 
    <artifactId>slf4j-log4j12</artifactId> 
    <version>1.6.4</version> 
</dependency> 
相關問題