5 Replies Latest reply on Apr 29, 2008 9:04 AM by Albert Fernández

    javax.naming.CommunicationException

    sarath Kumar Newbie

      sir,

      I got the javax.naming.CommunicationException when I

      started writing my first JMS program.

      The code snippet is given below

      Properties properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      properties.put(Context.PROVIDER_URL, "jnp://192.168.17.101:1099");
      InitialContext jndiContext = new InitialContext(properties);
      TopicConnectionFactory conFactory =
      (TopicConnectionFactory)jndiContext.lookup("TopicConnectionFactory");

      Error is there in JNDI lookup operation . If the client is there on the same machine it works fine.But if the client is Remote,it is showing the following error message


      Error Message

      Exception in thread "main" javax.naming.CommunicationException: Receive timed ou
      t [Root exception is java.net.SocketTimeoutException: Receive timed out]
      at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:12
      80)
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1360)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:575)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:568)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at Client.main(Client.java:27)
      Caused by: java.net.SocketTimeoutException: Receive timed out
      at java.net.PlainDatagramSocketImpl.receive(Native Method)
      at java.net.DatagramSocket.receive(DatagramSocket.java:711)
      at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:12
      50)
      ... 5 more

      would you please help me in correcting this error.

        • 1. Re: javax.naming.CommunicationException
          Frank Hauptlorenz Newbie

          Hi,

          do you have solved your issue?
          I've the same problem.

          Thank you,
          Frank

          • 2. Re: javax.naming.CommunicationException
            jaikiran pai Master

            Post the exception stacktrace that you are seeing and also more details about your application

            • 3. Re: javax.naming.CommunicationException
              tnine Newbie

              I'm also experiencing this. I'm using JBoss 4.0.5, and trying to look up a remote JMS Queue. I can start the server on my localhost, and use the following properties.

              java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
              java.naming.factory.url.pkgs= org.jboss.naming:org.jnp.interfaces
              java.naming.provider.url=jnp://localhost:1100
              


              It works like a champ. I then copied the same JBoss installation over the Linux server, and changed my JDBC connection for the MQ data source. The server initializes so the data source is correct. When I change my properties to the following, everything fails. I've included my stack trace. I know the port is available, if I telnet using "telnet testjboss1 1100", I can connect to the socket and I get data in my window from JBoss.

              java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
              java.naming.factory.url.pkgs= org.jboss.naming:org.jnp.interfaces
              java.naming.provider.url=jnp://testjboss1:1100
              


              Stacktrace

              org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inputReader' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'inputReaderTarget' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inputReaderTarget' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'dataHandler' while setting bean property 'dataHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataHandler' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'inputJmsTemplate' while setting bean property 'template'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inputJmsTemplate' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'inputQueueConnectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inputQueueConnectionFactory' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'remoteJMSQueue' while setting bean property 'targetConnectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteJMSQueue' defined in class path resource [reader-context.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable.]
              Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inputReaderTarget' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'dataHandler' while setting bean property 'dataHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataHandler' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'inputJmsTemplate' while setting bean property 'template'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inputJmsTemplate' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'inputQueueConnectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inputQueueConnectionFactory' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'remoteJMSQueue' while setting bean property 'targetConnectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteJMSQueue' defined in class path resource [reader-context.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable.]
              Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataHandler' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'inputJmsTemplate' while setting bean property 'template'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inputJmsTemplate' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'inputQueueConnectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inputQueueConnectionFactory' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'remoteJMSQueue' while setting bean property 'targetConnectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteJMSQueue' defined in class path resource [reader-context.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable.]
              Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inputJmsTemplate' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'inputQueueConnectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inputQueueConnectionFactory' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'remoteJMSQueue' while setting bean property 'targetConnectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteJMSQueue' defined in class path resource [reader-context.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable.]
              Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inputQueueConnectionFactory' defined in class path resource [reader-context.xml]: Cannot resolve reference to bean 'remoteJMSQueue' while setting bean property 'targetConnectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteJMSQueue' defined in class path resource [reader-context.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable.]
              Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteJMSQueue' defined in class path resource [reader-context.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable.]
              Caused by: javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable.]
               at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:707)
               at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
               at javax.naming.InitialContext.lookup(InitialContext.java:351)
               at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:123)
               at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:85)
               at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:121)
               at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:146)
               at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:93)
               at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
               at org.springframework.jndi.JndiObjectTargetSource.afterPropertiesSet(JndiObjectTargetSource.java:96)
               at org.springframework.jndi.JndiObjectFactoryBean$JndiObjectProxyFactory.createJndiObjectProxy(JndiObjectFactoryBean.java:276)
               at org.springframework.jndi.JndiObjectFactoryBean$JndiObjectProxyFactory.access$000(JndiObjectFactoryBean.java:265)
               at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:173)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428)
               at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
               at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1100)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424)
               at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
               at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1100)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424)
               at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
               at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1100)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424)
               at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
               at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1100)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424)
               at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
               at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
               at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1100)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
               at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424)
               at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
               at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
               at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
               at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284)
               at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
               at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
               at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
               at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
               at com.purdueefcu.statements.reader.Reader.readFile(Reader.java:50)
               at com.purdueefcu.statements.reader.Reader.main(Reader.java:107)
              Caused by: java.rmi.RemoteException: Service unavailable.
               at org.jboss.ha.framework.interfaces.HARMIClient.invokeRemote(HARMIClient.java:158)
               at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:196)
               at $Proxy20.lookup(Unknown Source)
               at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
               ... 71 more
              
              
              
              




              • 4. Re: javax.naming.CommunicationException
                Mohankumar G Newbie

                Hi,

                Any body resolved this, please let me know. We are also facing this issue.

                Thanks in advance

                • 5. Re: javax.naming.CommunicationException
                  Albert Fernández Newbie

                  start jboss with

                  run -b 0.0.0.0

                  That will make jboss bind to all available addresses. Otherwise it only binds to localhost.