activemq jndi tomcat错误
我正在尝试通过 JNDI 使用 ActiveMQ,在 Tomcat 7.0 服务器中部署应用程序。 我已经在 Tomcat context.xml
配置文件中对 ActiveMQ 连接工厂和队列进行了设置,它们看起来像这样:
<Resource
auth="Container"
brokerName="LocalActiveMQBroker"
brokerURL="vm://localhost"
clientID="TomcatClientID"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
name="jms/ConnectionFactory"
password="password"
type="org.apache.activemq.ActiveMQConnectionFactory"
userName="user"/>
<Resource
auth="Container"
description="Order Queue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
name="jms/orderQ"
physicalName="orderQ"
type="org.apache.activemq.command.ActiveMQQueue"/>
我尝试以这种方式获取连接工厂:
nnectionFactory connectionFactory = (ConnectionFactory) context
.lookup("java:comp/env/jms/ConnectionFactory");
但出现异常
java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:230)
:试图找出异常的原因,但我发现它可能来自 commons-logging jar,我已将其添加到 tomcat lib 文件夹中。
我哪里错了?
I am trying to use ActiveMQ via JNDI, deploying the application in Tomcat 7.0 server.
I have made the settings for ActiveMQ connection factory and queue in Tomcat context.xml
configuration file, and they look like this:
<Resource
auth="Container"
brokerName="LocalActiveMQBroker"
brokerURL="vm://localhost"
clientID="TomcatClientID"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
name="jms/ConnectionFactory"
password="password"
type="org.apache.activemq.ActiveMQConnectionFactory"
userName="user"/>
<Resource
auth="Container"
description="Order Queue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
name="jms/orderQ"
physicalName="orderQ"
type="org.apache.activemq.command.ActiveMQQueue"/>
and I try to get the connection factory this way:
nnectionFactory connectionFactory = (ConnectionFactory) context
.lookup("java:comp/env/jms/ConnectionFactory");
but I get an exception:
java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:230)
I tried to find out the cause of the exception, but I found only that it could come from commons-logging jar, which I have added to tomcat lib folder.
Where am I wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
commons-logging 是一个确实与日志记录有关的库,但它来自 Apache。另外 slf4j 只是一个外观,您需要为 slf4j 提供实际的实现。我建议使用 logback,这是在 java 中进行日志记录的“更好”方法。因此,您的类路径上需要 3 个 jar:slf4j-api.jar、logback-core.jar 和 logback-classic.jar。
另一方面,如果您不想使用 logback,那么任何其他实现都可以。
commons-logging is a library that has to do with logging indeed, but it's from Apache. Also slf4j is just a facade, you need to provide an actual implementation for slf4j. I would suggest logback, which is a "better" way to do logging in java. So you are going to need 3 jars on your classpath: slf4j-api.jar, logback-core.jar and logback-classic.jar.
If on the other hand you do not want to use logback then any other implementation will work.