wutzebaer
wutzebaer

Reputation: 14865

ActiveMQ as local JNDI tomcat ressource

i'm trying to set up ActiveMQ as Tomcat ressource with local JNDI. But when i add the config-file to the Broker URI "brokerConfig=xbean:activemq.xml" the broker isn't starting up without any error message.

it just keeps telling me:

Mrz 30, 2012 10:23:19 AM org.springframework.jms.listener.DefaultMessageListenerContainer refreshConnectionUntilSuccessful
Warnung: Could not refresh JMS Connection for destination 'FOO.QUEUE' - retrying in 5000 ms. Cause: Could not create Transport. Reason: java.io.IOException: Could not load xbean factory:java.lang.NoClassDefFoundError: Could not initialize class org.apache.activemq.xbean.XBeanBrokerFactory

I used the default config from http://svn.apache.org/repos/asf/activemq/trunk/assembly/src/release/conf/activemq.xml and is placed in the root of my src folder. i'm using "activemq-all_5.4.3.jar"

My web.xml in "WebContent\META-INF"

<resource-ref>
    <description>JMS Connection</description>
    <res-ref-name>jms/ConnectionFactory</res-ref-name>
    <res-type>org.apache.activemq.ActiveMQConnectionFactory</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

<resource-ref>
    <res-ref-name>jms/FooQueue</res-ref-name>
    <res-type>javax.jms.Queue</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

My applicationContext.xml in "WebContent\WEB-INF"

<jee:jndi-lookup id="fooQueue"
    jndi-name="java:comp/env/jms/FooQueue"
    cache="true"
    resource-ref="true"
    lookup-on-startup="true"
    expected-type="org.apache.activemq.command.ActiveMQQueue"
    proxy-interface="javax.jms.Queue" />


<bean id="singleConnectionFactory"
    class="org.springframework.jms.connection.SingleConnectionFactory"
    p:targetConnectionFactory-ref="connectionFactory"/>

<bean id="jmsTemplate" 
    class="org.springframework.jms.core.JmsTemplate"
    p:connectionFactory-ref="singleConnectionFactory" 
    p:defaultDestination-ref="fooQueue"/>

<bean id="messageSenderService" 
    class="by2.server.JmsMessageSenderService" 
    p:jmsTemplate-ref="jmsTemplate" /> 

<bean id="jmsMessageDelegate" 
    class="by2.server.JmsMessageDelegate" />

 <bean id="myMessageListener"
    class="org.springframework.jms.listener.adapter.MessageListenerAdapter" 
    p:delegate-ref="jmsMessageDelegate" 
    p:defaultListenerMethod="handleMessage">
</bean>

<jms:listener-container
    container-type="default" 
    connection-factory="singleConnectionFactory"
    acknowledge="auto">
        <jms:listener destination="FOO.QUEUE" ref="myMessageListener" />
</jms:listener-container>

My context.xml in "WebContent\META-INF"

<Context reloadable="true">
    <Resource auth="Container" name="jms/ConnectionFactory"
        type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory" brokerURL="vm://localhost?brokerConfig=xbean:activemq.xml"
        brokerName="FooBroker" />

    <Resource auth="Container" name="jms/FooQueue"
        type="org.apache.activemq.command.ActiveMQQueue" description="JMS queue"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="FOO.QUEUE" />
</Context>

Upvotes: 1

Views: 5546

Answers (1)

Naga
Naga

Reputation: 11

For me it looks like a classpath error. Did you have the xbean-spring-x.x.jar in your class path? If not copy this file also from activemq distribution and put it in your app server classpath.

Upvotes: 1

Related Questions