我是JBoss 7的新手。我面臨着奇怪的行爲。有時,當我嘗試調用會話bean時,我遇到以下異常:JBoss 7:沒有EJB接收器可用
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.util.List myServlet.getData() throws myException' threw an unexpected exception: java.lang.IllegalStateException: No EJB receiver available for handling [appName:myAppNameEE,modulename:myModuleEJB,distinctname:] combination for invocation context [email protected]
它通常在從Eclipse運行我的GWT應用程序時發生。該例外不會總是發生。有時候比其他人少。有時它會在我每次調用會話bean時發生,這很痛苦。我閱讀教程(https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI?_sscc=t),我非常確定有jboss- ejb-client.properties在正確的地方。
我的JBoss的EJB客戶端的樣子:
endpoint.name=myAppEE/myAppEJB remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false remote.connections=default remote.connection.default.host=localhost remote.connection.default.port = 4447 remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
它位於:
myAppEJB\ejbModule\com\myApp\ejb\conf
的的businness代表:
public class myAppServerDelegate extends ServerDelegate{
private Logger logger = Logger.getLogger(myAppServerDelegate.class.getName());
private myAppRemote theSession = null;
public myAppServerDelegate() throws Exception {
try {
theSession = (myAppRemote) getJndiContext().lookup(getJindiLookupName(myAppServerDelegate.class, myAppRemote.class));
} catch (NamingException e) {
throw (e);
}
}
public List<myDataDTO> getAllmyDataBy(String a, String b,
String c, String d,Integer e,
Integer f) throws ServerDelegateException {
return theSession.getAllmyDataBy(a, b, c, d,e,f);
}
public Integer getCountmyDataBy(String a, String b, String c, String d) throws ServerDelegateException {
return theSession.getCountmyDataBy(a, b, c, d);
}
...
public String getServiceMessage() {
return theSession.getServiceMessage();
}
...
}
會話bean :
@Stateless
public class myAppSession implements myAppRemote {
private Logger logger = Logger.getLogger(myAppSession.class.getName());
@PersistenceContext
protected EntityManager entityManager;
@EJB
private myAppHomeLocal beanmyApp;
...
public String getServiceMessage() {
return "MESSAGGIODISERVIZIO";
}
public List<myDataDTO> getAllmyDataBy(String a,String b,
String c, String d,Integer e,
Integer f) throws ServerDelegateException {
logger.info("myAppSession.getAllmyDataBy.");
List<myData> entityList = findByParms(a, b, c, d,e,f);
return myDataAssemblyDTO.getmyDataDTOList(entityList);
}
public Integer getCountmyDataBy(String a,String b, String c, String d) throws ServerDelegateException {
return findByParmsCount(a, b, c, d);
}
...
}
該servlet:
...
@SuppressWarnings( 「串行」)
公共類MyGenericServiceImpl延伸RemoteServiceServlet實現MyGenericService {
private MyAppServerDelegate myAppServerDelegate = null;
public MyGenericServiceImpl() throws Exception{
super();
myAppServerDelegate = new MyAppServerDelegate();
}
private MyAppServerDelegate getDelegate() {
return myAppServerDelegate;
}
private myGWTException buildLocalExceptionFromServerException(ServerDelegateException sde) {
myGWTException x = new myGWTException();
x.setParms(sde.guiMessage,sde.timestamp,sde.tipoEvento);
return x;
}
@Override
public PagingLoadResult<myDataBean> getAllmyDataBy(String a, String b, String c, PagingLoadConfig plc) throws MyGWTException {
try {
String cs = ((UserSessionBean)this.getThreadLocalRequest().getSession().getAttribute("user")).getCodiceStudio();
List<myDataBean> tsb = MyDataClientAssembly.getMyDataBeanList(myAppServerDelegate.getAllmyDataBy(cs, a, b, c, plc.getOffset(), plc.getLimit()));
return new BasePagingLoadResult<MyDataBean>(tsb, plc.getOffset(), myDataServerDelegate.getCountmyDataBy(cs, a, b, c));
} catch (ServerDelegateException sde) {
throw buildLocalExceptionFromServerException(sde);
}
}
@Override
public String getServiceMessage() {
return getDelegate().getServiceMessage();
}
@Override
public Integer getCountmyDataBy(String a, String b, String c) throws AmbrogioGWTException {
try {
String cs = ((UserSessionBean)this.getThreadLocalRequest().getSession().getAttribute("user")).getCs();
return myAppServerDelegate.getCountmtDataBy(cs, a, b, c);
} catch (ServerDelegateException sde) {
throw buildLocalExceptionFromServerException(sde);
}
}
}
的serverdelegate:
public class ServerDelegate {
static public String getJindiLookupName(Class<?> theBeanClass, Class<?> theSessionClass) throws NamingException {
String jbossServerName = System.getProperty("jboss.server.name");
if (jbossServerName== null || "".equals(jbossServerName)){
return "myAppEE/myAppEJB/"+ theBeanClass.getSimpleName() + "!" + theSessionClass.getName();
}else{
return "java:global/myAppEE/myAppEJB/" + theBeanClass.getSimpleName() + "!" + theSessionClass.getName();
}
}
static public Context getJndiContext() throws NamingException {
System.out.println("ServerDelegate.getJndiContext");
final Properties jndiProperties = new Properties();
String jbossServerName = System.getProperty("jboss.server.name");
if (jbossServerName== null || "".equals(jbossServerName)){
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:4447");
jndiProperties.put("jboss.naming.client.ejb.context", true);
jndiProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
}
return new InitialContext(jndiProperties);
}
}
我無法弄清楚發生了什麼事。 TIA。
弗朗西斯
我更深入地研究了這個問題。當我將JBoss中的gwt .war和ejb .jar作爲.ear模塊部署時,一切正常。但是,如果我在JBoss下的Eclipse的嵌入式Jetty和ejb模塊下運行gwt模塊,我得到了_No EJB Receiver_異常。 – Francesco 2012-07-10 14:35:21
有人嗎?也許我缺乏一些信息? – Francesco 2012-07-13 06:47:18