views:

642

answers:

2

I am trying to configure a JMS server (OpenJMS) into a Spring application and when I refer the resources using the notation "jms/<> I get a "name" not bound exception.

Any clue what is missing?

javax.naming.NameNotFoundException: Name jms is not bound in this Context
    at org.apache.naming.NamingContext.lookup(NamingContext.java:768)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:138)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:779)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:138)

The bean is defined as:

<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
 <property name="jndiTemplate" ref="jmsProvider"/>
 <property name="jndiName" value="jms/RefreshTopic_CF"/>
 <property name="resourceRef" value="true" />
</bean>

I have the JMS lib in class path and the openjms server is running.

+2  A: 

It seems you either

  • Didn't configured the OpenJMS to use the same JNDI tree the spring is looking at - have a look here
  • Looking for the wrong path in the JNDI. As a hunch, drop the "jms/" from the jndiName.
David Rabinowitz
A: 

In the web.xml we couldn't refer the as an interface (javax.jms.Topic) we had to use the exact class. This was a problem with OpenJMS and not with Websphere.

Not allowed:

<resource-ref id="ResourceRef_125180">
 <description>Topic</description>
 <res-ref-name>jms/MyTopic</res-ref-name>

 <res-type>javax.jms.Topic</res-type>

 <res-auth>Container</res-auth>
 <res-sharing-scope>Shareable</res-sharing-scope>  
</resource-ref>

allowed:

<resource-ref id="ResourceRef_125180">
 <description>Topic</description>
 <res-ref-name>jms/MyTopic</res-ref-name>

 <res-type>org.exolab.jms.client.JmsTopic</res-type>

 <res-auth>Container</res-auth>
 <res-sharing-scope>Shareable</res-sharing-scope>  
</resource-ref>
lud0h