Calling Craig .... help please. I am trying to deploy a client web-application to a distributed app which relies on ActiveMQ as its core async messaging medium.
I have declared the appropriate resources in the GlobalNamingResources section of server.xml and referenced them via ResourceLinks in the context.xml. The org.activemq.jndi.JNDIReferenceFactory and all it's dependencies are available to the server in jars copied to ${tomcat.home}/common/lib. When tomcat starts org.activemq.jndi.JNDIReferenceFactory methods are called to create the resource references as expected. They are bound in the JNDI tree afterwards as expected. However they cannot be retrieved. Attempts to look them up in the deployed webapp result in NamingExceptions being thrown with the message "Cannot create resource instance". Interestingly, when debugging tomcat during this process it seems the references' "factory" attributes are null, causing NamingManager to use the tomcat default ResourceFactory instead of the ActiveMQ factory when looking up the references - as is clear in the stack trace. Unless I have made a simple configuration error, I think that org.apache.catalina.core.NamingContextListener.addResource calls the wrong ResourceRef constructor, not specifying a factory parameter. This is real frustrating and if I dont sort it out soon I'm gonna get my arse kicked. Any help would be much appreciated. server.xml: <GlobalNamingResources> ... <Resource name="jms/MessageBusConnectionFactory" auth="Container" type="org.activemq.ActiveMQConnectionFactory" description="MessageBus Connection Factory" factory="org.activemq.jndi.JNDIReferenceFactory" brokerURL="tcp://localhost:61616" brokerName="LocalActiveMQBroker" useEmbeddedBroker="false" /> <Resource name="jms/MessageBus" auth="Container" type="org.activemq.message.ActiveMQTopic" description="MessageBus Topic" factory="org.activemq.jndi.JNDIReferenceFactory" physicalName="FOO.BAR" /> </GlobalNamingResources> context.xml under WAR META-INF: <?xml version="1.0" encoding="UTF-8"?> <Context path="search" antiJARLocking="true"> <ResourceLink name="jms/MessageBusConnectionFactory" global="jms/MessageBusConnectionFactory" type="javax.jms.ConnectionFactory" /> <ResourceLink name="jms/MessageBus" global="jms/MessageBus" type="javax.jms.Topic" /> </Context> Excerpt from java class where the resource is looked up: private synchronized void tryToSubscribe() throws JMSException, NamingException { if (! subscribed) { try { InitialContext initCtx = getInitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); ConnectionFactory connectionFactory = lookupConnectionFactory(envCtx); Topic destination = lookupTopic(envCtx); connection = connectionFactory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = Session.createDurableSubscriber( destination, DURABLE_SUBSCRIPTION_NAME); consumer.setMessageListener(this); connection.start(); subscribed = true; } catch (JMSException e) { LOG.log( Level.SEVERE, "Caught JMSException during agent destination subscription", e); throw e; } catch (NamingException e) { LOG.log( Level.SEVERE, "Caught NamingException during agent destination subscription"); throw e; } } } private ConnectionFactory lookupConnectionFactory(Context namingContext) throws NamingException { try { return (ConnectionFactory) namingContext.lookup("jms/MessageBusConnectionFactory"); } catch (NamingException e) { LOG.log( Level.SEVERE, "Could not retrieve MessageBus connection factory via JNDI: ", e); throw e; } } Stack trace excerpt: 21/12/2005 18:56:20 com.wotif.jaguar.search.util.MessageBusAgent lookupConnectionFactory SEVERE: Could not retrieve MessageBus connection factory via JNDI: javax.naming.NamingException: Cannot create resource instance at org.apache.naming.factory.ResourceFactory. getObjectInstance(ResourceFactory.java:132) at javax.naming.spi.NamingManager. getObjectInstance(NamingManager.java:304) at org.apache.naming.NamingContext.lookup(NamingContext.java:792) at org.apache.naming.NamingContext.lookup(NamingContext.java:139) at org.apache.naming.NamingContext.lookup(NamingContext.java:780) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at blah.MessageBusAgent.lookupConnectionFactory(MessageBusAgent.java:96) at blah.MessageBusAgent.tryToSubscribe(MessageBusAgent.java:139) at blah.MessageBusAgent.access$200(MessageBusAgent.java:35) at blah.MessageBusAgent$Subscriber.run(MessageBusAgent.java:181) at java.lang.Thread.run(Thread.java:595) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]