• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception in thread "main" javax.naming.CommunicationException: Receive timed out [Root exception is

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,
I am new to EJB and working for it.
I have created two projects ANSessionBean and ANSessionBeanClient.
After deploying my ANSessionBean to Jboss6.1, I am trying to run ANSessionBeanClient.java from ANSessionBeanClient project , then I am getting an exception in the main thread which is

Exception in thread "main" javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1690)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1812)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:695)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)
at javax.naming.InitialContext.lookup(Unknown Source)
at ANSessionBeanClient.main(ANSessionBeanClient.java:10)
Caused by: java.net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
at java.net.PlainDatagramSocketImpl.receive(Unknown Source)
at java.net.DatagramSocket.receive(Unknown Source)
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1659)
... 5 more


I dont know how to solve this problem .

The sessionBean class is as follows:
package org.anc.com;


import javax.ejb.Stateless;

@Stateless
public class ANSessionBean implements ANSessionBeanRemote,ANSessionBeanLocal {

/**
*
*/
private static final long serialVersionUID = 1L;

@Override
public void anSessionBeanMethod() {
System.out.println("anSessionBeanMethod Executed");

}

}


and the client is

import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.anc.com.ANSessionBeanRemote;
public class ANSessionBeanClient {
public static void main(String[] args) throws NamingException {
Context context=ANSessionBeanClient.getContext();
ANSessionBeanRemote anSessionBean=(ANSessionBeanRemote)context.lookup("ANSessionBean/remote");
anSessionBean.anSessionBeanMethod();
}
public static Context getContext() throws NamingException{
Properties properties =new Properties();
properties.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
properties.setProperty( "java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
properties.setProperty("javax.naming.provider.url", "jnp://localhost:1099");
return new InitialContext(properties);
}


}
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

It just looks like your properties for the InitialContext are not good. Just check the Jboss docs or use a Servlet (because then you don't need the properties to be set)

Regards,
Frits
 
Aditya Narayan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I just found that I needed to set an extra property after which my project run succesfully .
The property set is as follows :

Properties prop = new Properties();
prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
prop.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
prop.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
prop.setProperty("j2ee.clientName", "ANSessionBeanClient"); //on adding this my project is running succesfully


On searching on web I found out at here the usage of this
 
reply
    Bookmark Topic Watch Topic
  • New Topic