title: JNDI does not work with HornetQ and tomcat
body: <p>I'm trying running JMS application using hornetq on tomcat! I tried following <a href="http://wash-inside-out.blogspot.com/2010/08/hornetq-jms-integration-with-tomcat.html" rel="nofollow">this article</a>. I put jndi.properties in my client class path;  jndi.properties: </p>
  
  <pre><code>java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory 
  java.naming.factory.url.pkgs=org.apache.naming
  </code></pre>
  
  <p>I added these dependencies to pom.xml:</p>
  
  <pre><code>&lt;dependency&gt; 
      &lt;groupId&gt;tomcat&lt;/groupId&gt; 
      &lt;artifactId&gt;naming-factory&lt;/artifactId&gt; 
      &lt;version&gt;5.5.23&lt;/version&gt; 
      &lt;scope&gt;test&lt;/scope&gt; 
  &lt;/dependency&gt; 
  &lt;dependency&gt; 
       &lt;groupId&gt;tomcat&lt;/groupId&gt; 
       &lt;artifactId&gt;naming-resources&lt;/artifactId&gt; 
       &lt;version&gt;5.5.23&lt;/version&gt; 
       &lt;scope&gt;test&lt;/scope&gt; 
   &lt;/dependency&gt;
  </code></pre>
  
  <p>My JMS spring beans:</p>
  
  <pre><code>&lt;bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"&gt;
          &lt;property name="environment"&gt;
              &lt;props&gt;
                  &lt;prop key="java.naming.factory.initial"&gt;org.apache.naming.java.javaURLContextFactory&lt;/prop&gt;
                  &lt;prop key="java.naming.factory.url.pkgs"&gt;org.apache.naming&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;!-- Connection Factory --&gt;
  &lt;bean id="hornetqConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
      &lt;property name="jndiTemplate" ref="jndiTemplate"/&gt;
      &lt;property name="jndiName" value="/ConnectionFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;!-- Destinations --&gt;
  &lt;bean id="annotationDeleteCommandDestination" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
      &lt;property name="jndiTemplate" ref="jndiTemplate"/&gt;
      &lt;property name="jndiName" value="/queue/command/annotation/deleteQueue" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I'm using HornetQ default server (standalone, non-clustered)</p>
  
  <p>hornetq-jms.xml:</p>
  
  <pre><code>&lt;queue name="annotationDeleteCommandQueue"&gt;
      &lt;entry name="/queue/command/annotation/deleteQueue"/&gt;
  &lt;/queue&gt;
  
  &lt;connection-factory name="NettyConnectionFactory"&gt;
        &lt;xa&gt;false&lt;/xa&gt;
        &lt;connectors&gt;
           &lt;connector-ref connector-name="netty"/&gt;
        &lt;/connectors&gt;
        &lt;entries&gt;
           &lt;entry name="/ConnectionFactory"/&gt;
        &lt;/entries&gt;
     &lt;/connection-factory&gt;
  </code></pre>
  
  <p>But when i starting tomcat i get this error:</p>
  
  <pre><code> org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hornetqConnectionFactory' defined in ServletContext resource [/WEB-INF/classes/config/spring/applicationContext-jms.xml]: 
  Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name ConnectionFactory is not bound in this Context .........
  </code></pre>
  
  <p>What is wrong?
  Should i put any jar files in the tomcat classpath? (which jars?)
  Should i put queues and connection factories definitions in the tomcat configs? (how?)
  Can i disable JNDI in tomcat and use hornetq standalone JNDI instead?</p>