wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Exception in thread "main" javax.naming.CommunicationException: Receive timed out [Root exception is" Watch "Exception in thread "main" javax.naming.CommunicationException: Receive timed out [Root exception is" New topic
Author

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

Aditya Narayan
Greenhorn

Joined: Sep 17, 2012
Posts: 17
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.namingrg.jnp.interfaces");
properties.setProperty("javax.naming.provider.url", "jnp://localhost:1099");
return new InitialContext(properties);
}


}
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1634
    
  23

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

Joined: Sep 17, 2012
Posts: 17
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
 
 
subject: Exception in thread "main" javax.naming.CommunicationException: Receive timed out [Root exception is
 
Similar Threads
what are the INTIAL_CONTEXT parameters
JNDI Configuration Query
EJB JNDI NoInitialContext Exception
EJB2.0 with JBOSS4.0
JNDI lookup errors