我是 EJB 和 JBoss 世界的新手,在尝试通过其远程接口执行无状态 bean 时遇到问题。
我在 Struts ActionSupport 中这样做:
public String inscrire() {
System.out.println("########### Inscrire Action #############");
Candidat c = new Candidat(nom, prenom, mail, telephone, ecole);
try {
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
org.jboss.naming.remote.client.InitialContextFactory.class
.getName());
env.put(Context.PROVIDER_URL, "remote://localhost:4447");
env.put(Context.SECURITY_PRINCIPAL, "UserApp");
//env.put("jboss.naming.client.ejb.context", "true");
env.put(Context.SECURITY_CREDENTIALS, "password");
InitialContext remoteContext = new InitialContext(env);
System.out.println("########## Initial Context OK ##########");
servicecandidat = (CandidatSessionRemote) remoteContext
.lookup("java:global/EtestEAProject/EtestMetier/CandidatSession!sessions.candidat.CandidatSessionRemote");
System.out.println("########## LookUp OK ##########");
if (servicecandidat.inscrireCandidat(c))
return SUCCESS;
else
return ERROR;
}catch (Exception lookupError) {
System.out.println("########## LookUp Echec ##########");
lookupError.printStackTrace();
return ERROR;
}
尝试执行方法时,控制台会给出以下命名异常
15:01:45,474 INFO [stdout] (http-localhost-127.0.0.1-8080-1) ########## Initial Context OK ##########
15:01:45,680 INFO [stdout] (http-localhost-127.0.0.1-8080-1) ########## LookUp Exchec ##########
15:01:45,682 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) javax.naming.NameNotFoundException: global/EtestEAProject/EtestMetier/CandidatSession!sessions.candidat.CandidatSessionRemote -- service jboss.naming.context.java.jboss.exported.global.EtestEAProject.EtestMetier."CandidatSession!sessions.candidat.CandidatSessionRemote"
15:01:45,685 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
15:01:45,687 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)
...........................
ejb jar 部署说:
java:global/EtestEAProject/EtestMetier/CandidatSession!sessions.candidat.CandidatSessionRemote
java:app/EtestMetier/CandidatSession!sessions.candidat.CandidatSessionRemote
java:module/CandidatSession!sessions.candidat.CandidatSessionRemote
java:jboss/exported/EtestEAProject/EtestMetier/CandidatSession!sessions.candidat.CandidatSessionRemote
java:global/EtestEAProject/EtestMetier/CandidatSession!sessions.candidat.CandidatSessionLocal
java:app/EtestMetier/CandidatSession!sessions.candidat.CandidatSessionLocal
java:module/CandidatSession!sessions.candidat.CandidatSessionLocal