Results 1 to 7 of 7

Thread: Asynchronous JMS queue MessageListener throws NameNotfoundException

  1. #1
    Join Date
    May 2007
    Posts
    7

    Question Asynchronous JMS queue MessageListener throws NameNotfoundException

    I have problem with a JMS MessageListener. My bean (MessageQueueListener) implements the MessageListener interface. I then have a remote queue that my bean should listen for new messages on. However, when I start my application (a webapp in JBoss 4), I get a the following error:

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsDestination' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Invocation
     of init method failed; nested exception is javax.naming.NameNotFoundException:  not bound
    Caused by:
    javax.naming.NameNotFoundException:  not bound
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
            at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
    The strange thing is that when I do all the lookup programmatically (with the same values as below) and query the queue synchronously, everything works. My Spring configuration for the asynchronous message listener looks like this:

    Code:
    <bean id="messageListener" class="com.company.jms.MessageQueueListener">
        <property name="chId" value="84527"/>
        <property name="manager" ref="managerProxy"/>
    </bean>
    
    <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiEnvironment">
            <props>
                <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
                <prop key="java.naming.provider.url">jnp://remote.server.com:1099</prop>
                <prop key="java.naming.factory.url.pkgs">org.jnp.interfaces:org.jboss.naming</prop>
                <prop key="java.naming.security.principal">username</prop>
                <prop key="java.naming.security.credentials">password</prop>
            </props>
        </property>
        <property name="jndiName" value="java:/ConnectionFactory"/>
        <property name="resourceRef" value="true"/>
    </bean>
    
    <bean id="jmsDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="/queue/RemoteQueue"/>
        <property name="resourceRef" value="true"/>
    </bean>
    
    <bean id="listenerContainer" class="org.springframework.jms.listener.SimpleMessageListenerContainer">
        <property name="concurrentConsumers" value="1"/>
        <property name="connectionFactory" ref="connectionFactory"/>
        <property name="destination" ref="jmsDestination"/>
        <property name="messageListener" ref="messageListener"/>
    </bean>
    Anyone have any idea what I'm doing wrong?

    Thanks in advance!

    // Erik

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    You could try setting the "lookupOnStartup" flag of your JndiObjectFactoryBeans to "false". Maybe the JNDI entries are not fully initialized yet on context loading.

    Hope that helps,
    Andreas

  3. #3
    Join Date
    May 2007
    Posts
    7

    Smile

    Ok, I tried that but I get a different exception at startup:

    Code:
    java.lang.IllegalArgumentException: Cannot deactivate 'lookupOnStartup' 
    or 'cache' without specifying a 'proxyInterface'
    I added a proxyInterface property to my JndiObjectFactoryBeans also, but I'm a bit unsure. I set the value to "javax.jms.ConnectionFactory" for the connectionFactory bean and to "javax.jms.Destination" for the jmsDestination bean, but that resulted in the following exception at startup:

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'listenerContainer' defined in ServletContext 
    resource [/WEB-INF/applicationContext-hibernate.xml]: Invocation of init 
    method failed; nested exception 
    is java.lang.reflect.UndeclaredThrowableException
    Caused by: java.lang.reflect.UndeclaredThrowableException
    Tried searching on the proxyInterface-property with little success. Any suggestion on what I should use?

    Thanks!

  4. #4
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    You may try javax.jms.Queue instead of Destination. Besides that: Is there probably more information in the stacktrace? The excerpt seems a little bit short.

    Regards,
    Andreas

  5. #5
    Join Date
    May 2007
    Posts
    7

    Default

    Quote Originally Posted by Andreas Senft View Post
    You may try javax.jms.Queue instead of Destination.
    My bad. Changed to javax.jms.Queue instead and got a bit further. Now I'm getting:

    Code:
    2007-05-04 13:52:36,766 ERROR [org.springframework.jms.listener.DefaultMessageListenerContainer] Setup of JMS message listener invoker failed - trying to recover
    java.lang.reflect.UndeclaredThrowableException
            at $Proxy60.toString(Unknown Source)
            at java.lang.String.valueOf(String.java:2827)
            at java.lang.StringBuffer.append(StringBuffer.java:219)
            at org.jboss.jms.client.JBossSession.createConsumer(JBossSession.java:243)
            at org.jboss.jms.client.JBossSession.createConsumer(JBossSession.java:231)
            at org.springframework.jms.listener.DefaultMessageListenerContainer.createConsumer(DefaultMessageListenerContainer.java:810)
            at org.springframework.jms.listener.DefaultMessageListenerContainer.createListenerConsumer(DefaultMessageListenerContainer.java:443)
            at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.initResourcesIfNecessary(DefaultMessageListenerContainer.java:903)
            at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:888)
            at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:842)
            at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:203)
            at java.lang.Thread.run(Thread.java:619)
    Caused by: javax.naming.NameNotFoundException:  not bound
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
            at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
            at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
            at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:716)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
            at javax.naming.InitialContext.lookup(InitialContext.java:392)
            at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:124)
            at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:86)
            at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:122)
            at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:147)
            at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:90)
            at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:101)
            at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:121)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:184)
            ... 12 more
    This exception repeats itself every 2-3 seconds. When I use tcpdump to see if any communication occurs between my server and the remote server where the queue is located I see that both sides sends data, so at least there is not a connection issue.

  6. #6
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    I just see that you provide a jndi environment for looking up the ConnectionFactory but not for the queue.
    Further you prefix one jndi name with "java:" and the other not.

    As the underlying reason seems to be a "NameNotFoundException" I would check these settings.

    Regards,
    Andreas

  7. #7
    Join Date
    Apr 2012
    Posts
    1

    Default

    try starting your jboss by ./run.sh -c messaging

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •