I'm trying running JMS application using hornetq on tomcat! I tried following this article. I put jndi.properties in my client class path; jndi.properties:
java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory
java.naming.factory.url.pkgs=org.apache.naming
I added these dependencies to pom.xml:
<dependency>
<groupId>tomcat</groupId>
<artifactId>naming-factory</artifactId>
<version>5.5.23</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>naming-resources</artifactId>
<version>5.5.23</version>
<scope>test</scope>
</dependency>
My JMS spring beans:
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">org.apache.naming.java.javaURLContextFactory</prop>
<prop key="java.naming.factory.url.pkgs">org.apache.naming</prop>
</props>
</property>
</bean>
<!-- Connection Factory -->
<bean id="hornetqConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate"/>
<property name="jndiName" value="/ConnectionFactory" />
</bean>
<!-- Destinations -->
<bean id="annotationDeleteCommandDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate"/>
<property name="jndiName" value="/queue/command/annotation/deleteQueue" />
</bean>
I'm using HornetQ default server (standalone, non-clustered)
hornetq-jms.xml:
<queue name="annotationDeleteCommandQueue">
<entry name="/queue/command/annotation/deleteQueue"/>
</queue>
<connection-factory name="NettyConnectionFactory">
<xa>false</xa>
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="/ConnectionFactory"/>
</entries>
</connection-factory>
But when i starting tomcat i get this error:
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 .........
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?