I am attempting to run ActiveMQ in a servlet (GWT-based) on Tomcat6.   I
actually have it working, but in my catalina.log file, I get a frequent
stream of IllegalStateExceptions (see stacktrace, below).  The code in my
servlet looks like the following:

  ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(_url);

        try {
            _connection = factory.createConnection();
            _session = _connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);

            _commandQueue =
_session.createQueue("automation.insteon.command");
            _responseTopic =
_session.createTopic("automation.insteon.response");

            _publisher = _session.createProducer(_commandQueue);
            _publisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

            _consumer = _session.createConsumer(_responseTopic);
            _consumer.setMessageListener(this);

            _connection.start();

            _publisher.send(_session.createTextMessage("STATUS"));

        } catch (JMSException e) {
            System.out.println("JMS error: " + e.getMessage());
        }

Interesting, I get the exception every time a new message arrives.  The
message is actually processed correctly, I just get the exception in the log
file.

One thing I am wondering about is how this is all working anyway.  I assume
that the servlet I have created keeps running, and that ActiveMQ starts a
new thread that is processing messages in the background.  Is this correct? 
If the servlet were to shutdown for some reason, I don't know what would
happen to this thread.  Overall, is this the correct way to have a servlet
receive and send JMS messages with ActiveMQ?

Thanks for your help.

Error stacktrace:

Sep 22, 2007 3:26:10 PM org.apache.catalina.loader.WebappClassLoader
loadClass
INFO: Illegal access: this web application instance has been stopped
already.  Could not load com.siegel.insteon.MessageSetOnLevel.  The eventual
following stack trace is caused by an error thrown for debugging purposes as
well as to attempt to terminate the thread which caused the illegal access,
and has no functional impact.
java.lang.IllegalStateException
        at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1244)
        at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
        at org.apache.activemq.util.ClassLoading.load(ClassLoading.java:112)

-- 
View this message in context: 
http://www.nabble.com/Using-ActiveMQ-with-Tomcat-6---IllegalStateException-problem-tf4502972s2354.html#a12842495
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to