带有activemq客户端的ClassLoader classcastexception

时间:2015-02-03 22:53:51

标签: java tomcat7 activemq

我一直在努力解决这个问题,现在决定向社区提问,希望得到一些提示/答案。

我使用tomcat 7.0.54作为我的J2EE容器,它部署了一个依赖于activemq-all的WAR。

除此之外,我还通过实现ServletContainerInitializer接口,在类路径中放置一个jar来以编程方式注册监听器。这初始化了一个活动mq客户端的简单实现,JvmMessageProducerImpl(我将activemq-client作为pom中的依赖项)。

通过上面的设置,当我尝试启动tomcat时,我得到以下异常。似乎不是独立加载类,而是在Web应用程序启动时调用的侦听器,它正在查找TcpTransportFactory的现有实例并抛出ClassCastException。我已经多次阅读了tomcat的类加载器手册,我的理解是每个war文件都应该有独立的类加载器 - 但是不完全理解为什么会抛出异常?

javax.jms.JMSException: Could not create Transport. Reason: java.io.IOException: Transport scheme NOT recognized: [tcp]
    at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36)
    at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:317)
    at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:330)
    at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:251)
    at com.monitoreverywhere.jvmmon.mq.JvmMessageProducerImpl.setup(JvmMessageProducerImpl.java:66)
    at com.monitoreverywhere.jvmmon.mq.JvmMessageProducerImpl$Runner.run(JvmMessageProducerImpl.java:163)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.io.IOException: Transport scheme NOT recognized: [tcp]
    at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)
    at org.apache.activemq.transport.TransportFactory.findTransportFactory(TransportFactory.java:181)
    at org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java:63)
    at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:315)
    ... 5 more
Caused by: java.lang.ClassCastException: org.apache.activemq.transport.tcp.TcpTransportFactory cannot be cast to org.apache.activemq.transport.TransportFactory
    at org.apache.activemq.transport.TransportFactory.findTransportFactory(TransportFactory.java:178)
    ... 7 more    

0 个答案:

没有答案