I created an EJB 2. I deployed it on JBoss-IDE 1.6 and then, I created a JUnit test to access it. here's the code I used for the client :
public class DossierBeanTest extends TestCase {
protected DossierHome dossierHome;
protected Dossier dossier;
public DossierBeanTest(String argo){
super(arg0);
}
protected void setUp() throws Exception {
super.setUp();
Hashtable env=new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL,"jnp://localhost:1199");
Context context=new InitialContext(env);
Object finderRef=context.lookup(dossierHome.JNDI_NAME);
dossierHome=(DossierHome)PortableRemoteObject.narrow(finderRef,DossierHome.class);
dossier=dossierHome.create();
}
public void testGetString() throws RemoteException {
assertEquals("Test",dossier.getTest());
}
but the problem is that this client fails with the error :
javax.naming.CommunicationException: Could not obtain connection to any of these
urls: localhost:1199 and discovery failed with error :
javax.naming.CommunicationException: Receive timed out [Root Exception is
java.net.SocketTimeoutException: Receive timed out][Root exception is
javax.naming.CommunicationException: Failed to connect to server localhost:1199
....
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1416)
....