lud0h
lud0h

Reputation: 2390

JNDI Context :: Name jms not bound in this Context

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.

Upvotes: 2

Views: 20039

Answers (4)

yasin
yasin

Reputation: 49

    **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>

Upvotes: 0

Sahil
Sahil

Reputation: 1983

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.

Upvotes: 0

lud0h
lud0h

Reputation: 2390

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>

Upvotes: 4

David Rabinowitz
David Rabinowitz

Reputation: 30448

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.

Upvotes: 2

Related Questions