activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brad steiner <bstei...@thehungersite.com>
Subject Connecting from Tomcat 5.5.15
Date Wed, 17 May 2006 22:35:36 GMT
ActiveMQ Users

We are exploring the use of ActiveMQ as part of our IT infrastructure  
but have run into some difficulties connecting to a standalone AMQ  
server from Tomcat 5.5.15 with both the 4.0 release and the May 8th  
2006 build (on MacOS X, JVM 1.5, using Struts 1.2.9). Using the  
latter, I've added incubator-activemq-4.0.jar to $CATALINA_HOME/ 
common/lib, included it in my class path, and added the following code:

<< in META-INF/context.xml >>

<Context antiJARLocking="true">
     <Resource
         name="jms/ConnectionFactory"
         auth="Container"
         type="org.apache.activemq.ActiveMQConnectionFactory"
         description="JMS Connection Factory"
         factory="org.apache.activemq.jndi.JNDIReferenceFactory"
         brokerURL="tcp://localhost:61616"
         brokerName="LocalActiveMQBroker"
         useEmbeddedBroker="false"/>

     <Resource name="jms/someTopic"
         auth="Container"
         type="org.apache.activemq.command.ActiveMQTopic"
         factory="org.apache.activemq.jndi.JNDIReferenceFactory"
         physicalName="TEST_TOPIC.FOO"/>

     <Resource name="jms/aQueue"
         auth="Container"
         type="org.apache.activemq.command.ActiveMQQueue"
         factory="org.apache.activemq.jndi.JNDIReferenceFactory"
         physicalName="TEST.FOO"/>
</Context>


<< in my struts action class >>

Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:comp/env");
ActiveMQConnectionFactory connectionFactory =  
(ActiveMQConnectionFactory) envContext.lookup("jms/ConnectionFactory");
ActiveMQConnection connection = (ActiveMQConnection)  
connectionFactory.createConnection();

connection.start();

ActiveMQSession session = (ActiveMQSession) connection.createSession 
(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQDestination dest = (ActiveMQDestination) session.createQueue 
("TEST.FOO");
ActiveMQMessageProducer producer = (ActiveMQMessageProducer)  
session.createProducer(dest);	/* throws Threw Error  
java.lang.LinkageError: loader constraints violated when linking  
javax/jms/Destination */

producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
ActiveMQTextMessage message = (ActiveMQTextMessage)  
session.createTextMessage("Struts Action Sent This Message");
producer.send(message);
session.close();
connection.close();

The result is that session.createProducer(dest) throws 'Error  
java.lang.LinkageError: loader constraints violated when linking  
javax/jms/Destination'. I've spent several days tracking down javax/ 
jms/Destination declarations in jars on my classpath and removing  
them but continue to get the same result. I've also tried declaring  
my ActiveMQXxx variables as the javax/jms superclass of each, as in  
many of the examples I've seen, but get ClassCastExceptions on the  
connection factory lookup. ActiveMQ would be great addition to our  
infrastructure so I'm hopeful that someone knows of a solution to  
this little bump in the road.

Thanks in Advance,

Brad Steiner
Senior Software Engineer
The GreaterGood Network


Mime
View raw message