Dear all, In short: I'm having difficulties setting up an initial context factory to acces resources defined in context.xml . The complete story is as follows:
I'm trying to let send messages from Adobe lcds to JMS. I'm running into jndi issues (I think) however. It says: INFO: [LCDS] [INFO] JMS consumer for JMS destination 'java:comp/env/jmz/topic/flex/simpletopic ' is being removed from the JMS adapter due to the following error: Name TopicConnectionFactory is not bound in this Context I've seen in the Tomcat JNDI Datasource HOW-TO that I would normally get the tomcat jndi context with 'Context ctx = new InitialContext();'. But the configuration of the lcds jms adapter requires me to fill in a inititalcontextfactory. In order to get the correct settings I've made an adapter myself with the following code: ctx = new InitialContext(); System.out.println("my env = " + ctx.getEnvironment()); ..... factory = (TopicConnectionFactory)ctx.lookup("java:comp/env/jms/flex/TopicConnectionFa ctory"); It's output is: my env = {java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory, java.naming.provider.url=vm://localhost, topic.MyTopic=example.MyTopic, java.naming.factory.url.pkgs=org.apache.naming, queue.MyQueue=example.MyQueue} With this context I'm able to connect to my JMS implementation (activemq), so I tried to copy this environment to the JMS adapter configuration and got the error message above. To figure out what's going on, I tried the following in my self made adapter: Context ctx; InitialContextFactory initFac = new javaURLContextFactory(); Hashtable env = new Hashtable(); env.put(Context.PROVIDER_URL, "vm://localhost"); // env.put(Context.PROVIDER_URL, "tcp://localhost:61616"); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory"); env.put(Context.URL_PKG_PREFIXES, "org.apache.naming"); // env.put(Context.URL_PKG_PREFIXES, "java:org.apache.naming"); ctx = initFac.getInitialContext(env); ..... factory = (TopicConnectionFactory)ctx.lookup("java:comp/env/jms/flex/TopicConnectionFa ctory"); But I was unable to retrieve the TopicConnectionFactory (I've also tried the commented code with the same result). The error is the same as the error I get from the adobe JMS adapter so I'm doing something wrong here. I'm also puzzled about the topic.MyTopic=example.MyTopic and queue.MyQueue=example.MyQueue in the context environment. I haven't specified that. I'm afraid that there may be some other resource specification somewhere. I've searched for files with those texts but haven't found them. My tomcat/conf/context.xml contains: <Resource name="jms/flex/TopicConnectionFactory" auth="Container" type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory" factory="org.apache.activemq.jndi.JNDIReferenceFactory" brokerURL="tcp://localhost:61616" brokerName="LocalActiveMQBroker"/> <Resource name="jmz/topic/flex/simpletopic" auth="Container" type="org.apache.activemq.command.ActiveMQTopic" description="my topic" factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="APP.STOCK.MARKETDATA"/> my web.xml contains: <resource-ref> <description>JMS Connection Factory</description> <res-ref-name>jms/flex/TopicConnectionFactory</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> <description>Simple Topic</description> <res-ref-name>jmz/topic/flex/simpletopic</res-ref-name> <res-type>org.apache.activemq.command.ActiveMQTopic</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> I hope that if I know how to solve this in code I will also be able to solve it in the adobe lcds configuration. For completeness, my current messaging-config.xml contains: <destination id="chat-topic-jms"> <properties> <jms> <destination-type>Topic</destination-type> <message-type>javax.jms.TextMessage</message-type> <connection-factory>java:comp/env/jms/flex/TopicConnectionFactory </connection-factory> <destination-jndi-name>java:comp/env/jmz/topic/flex/simpletopic </destination-jndi-name> <destination-name>APP.STOCK.MARKETDATA </destination-name> <delivery-mode>NON_PERSISTENT</delivery-mode> <message-priority>DEFAULT_PRIORITY</message-priority> <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode> <transacted-sessions>false</transacted-sessions> <initial-context-environment> <property> <name>Context.PROVIDER_URL</name> <value>vm://localhost</value> </property> <property> <name>Context.INITIAL_CONTEXT_FACTORY</name> <!-- <value>org.apache.activemq.jndi.ActiveMQInitialContextFactory</value> --> <value>org.apache.naming.java.javaURLContextFactory</value> </property> <property> <name>Context.URL_PKG_PREFIXES</name> <value>org.apache.naming</value> </property> </initial-context-environment> </jms> </properties> <channels> <channel ref="my-rtmp"/> <!-- <channel ref="samples-amf-polling"/> --> </channels> <adapter ref="jms"/> </destination> I hope anyone has an idea... Best regards, Bas Vermeulen --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org