我创建了一个EJB 2.我将它部署在JBoss-IDE 1.6上,然后创建了一个JUnit测试来访问它。这里是我使用的客户端代码:EJB客户端错误
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());
}
但问题是,这个客户端失败,出现错误:
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)
....
应该更改哪个配置文件? – Attilah 2009-10-07 17:12:21
查看文件“jboss-service.xml”,然后在 。 –
tangens
2009-10-07 18:19:08