2
votes

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?

1

1 Answers

3
votes

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.