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);
}
}