• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic