我創建了一個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