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.

lud0h
  • 2,370
  • 6
  • 33
  • 41

4 Answers4

4

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
  • 2,370
  • 6
  • 33
  • 41
2

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
  • 29,904
  • 14
  • 93
  • 125
0

In my case I had to move the resource i.e jms/XXX from server.xml of tomcat to context.xml and then restarting the tomcat did the trick.

Sahil
  • 1,959
  • 6
  • 24
  • 44
0
    **Create the file <webapp-root>/META-INF/context.xml**. 
here`Here is an example:
    <Context antiJARLocking="true">
        <Resource
            name="jms/ConnectionFactory"
            auth="Container"
            type="org.apache.activemq.ActiveMQConnectionFactory"
            description="JMS Connection Factory"
            factory="org.apache.activemq.jndi.JNDIReferenceFactory"
            brokerURL="tcp://localhost:61616"
            brokerName="LocalActiveMQBroker"
            useEmbeddedBroker="false"/>

        <Resource name="jms/topic/MyTopic"
            auth="Container"
            type="org.apache.activemq.command.ActiveMQTopic"
            factory="org.apache.activemq.jndi.JNDIReferenceFactory"
            physicalName="MY.TEST.FOO"/>
        <Resource name="jms/queue/MyQueue"
            auth="Container"
            type="org.apache.activemq.command.ActiveMQQueue"
            factory="org.apache.activemq.jndi.JNDIReferenceFactory"
            physicalName="MY.TEST.FOO.QUEUE"/>
    </Context>
yasin
  • 49
  • 1
  • 9