我是JBoss 7的新手。我面临着奇怪的行为。有时,当我尝试调用会话bean时,我遇到以下异常:
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 org.jboss.ejb.client.EJBClientInvocationContext@3e23bd28
通常在从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-client看起来像:
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
业务代表:
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( “串行”)
public class MyGenericServiceImpl extends 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。
弗朗西斯
答案 0 :(得分:2)
这可能是使用本地与远程接口或连接问题的问题。
尝试在TRACE
包上启用org.jboss.ejb.client
日志级别。如果您的类路径中已有log4j.properties
,请包含以下行:
log4j.logger.org.jboss.ejb.client=TRACE
This post包含调试JBoss EJB客户端的其他线索。
答案 1 :(得分:0)
我必须在mavens pom.xml文件中包含一个依赖项列表。其中包括
我能够从我的独立Java客户端成功发出远程请求但是我确实看到了以下问题
Jboss 7.1: 13:43:25,028 INFO [stdout](EJB默认值 - 6)Hello world 13:43:25,825 ERROR [org.jboss.remoting.remote.connection](Remoting“mycomputername”read-1)JBREM000200:远程连接失败:java.io.IOException:远程主机强行关闭现有连接
我的java ejb客户端: WARN [Remoting“client-endpoint”task-2](ChannelAssociation.java:320) - 收到不支持的邮件,标题为0xffffffff
阅读在线人员似乎通过更新某些罐子的版本来解决这个问题。但是,我还没有找到一个成功的解决方案。
更新:在部署独立的ejb客户端时,我在类路径中包含了jboss-client.jar。效果很好。
java -classpath“$ JBOSS_HOME / bin / client / jboss-client.jar; ./ my-ejb-client.jar”com.test.Myclient
答案 2 :(得分:0)
在MyAppServerDelegate类中,您必须在以下方法中而不是在构造函数中实例化属性“theSession”:
getAllmyDataBy();
getCountmyDataBy();
getServiceMessage();
.Session方法调用的结果应存储在临时变量中,然后调用getJndiContext()。close(),然后返回临时值。
必须明确关闭每个连接。实际上,当达到允许的最大连接数时会发生异常。