2012-07-09 58 views
1

我是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。

弗朗西斯

+0

我更深入地研究了這個問題。當我將JBoss中的gwt .war和ejb .jar作爲.ear模塊部署時,一切正常。但是,如果我在JBoss下的Eclipse的嵌入式Jetty和ejb模塊下運行gwt模塊,我得到了_No EJB Receiver_異常。 – Francesco 2012-07-10 14:35:21

+0

有人嗎?也許我缺乏一些信息? – Francesco 2012-07-13 06:47:18

回答

2

這可能是使用本地VS遠程接口或連接問題的問題。

嘗試在org.jboss.ejb.client軟件包上啓用TRACE日誌級別。如果你已經在你的classpath中有log4j.properties,加入這一行:

log4j.logger.org.jboss.ejb.client=TRACE 

This post包括其他線索進行調試JBoss的EJB客戶端。

0

有一個我必須包括在我的mavens pom.xml文件中的依賴關係列表。這些措施包括

  1. 的JBoss的EJB客戶端
  2. xnio-NIO
  3. 的jboss-遠程命名
  4. 的jboss-SASL
  5. 的jboss-交易-AP
  6. 的jboss-編組
  7. jboss-marshalling-river

I能夠成功地讓我的遠程請求從我的獨立Java客戶端,但是我確實看到了以下問題

的Jboss 7.1: 13:43:25028 INFO [標準輸出(EJB默認 - 6)世界,你好 13:43: 25,825錯誤[org.jboss.remoting.remote.connection](Remoting「mycomputername」read-1)JBREM000200:遠程連接失敗:java.io.IOException:現有連接被遠程主機強制關閉

我的java ejb客戶端: WARN [遠程處理]客戶端 - 端點任務-2](ChannelAssociation.java:320) - 收到的不支持的消息頭0xffffffff

在線閱讀的人似乎已經通過更新某些罐子的版本解決了這個問題。但是,我還沒有找到一個成功的解決方案。

更新:當我部署一個獨立的ejb客戶端時,我在我的classpath中包含了jboss-client.jar。很棒。

的java -classpath 「$ JBOSS_HOME/bin中/客戶/的jboss-client.jar中; ./我的EJB-client.jar的」 com.test.Myclient

0

在類MyAppServerDelegate,你將不得不實例在下面的方法中的屬性 「theSession」,而不是在構造:

  • getAllmyDataBy();

  • getCountmyDataBy();

  • getServiceMessage();

theSession方法調用的結果應該被存儲在臨時變量,事後調用getJndiContext()。close()方法,然後返回所述臨時值。

每個連接都必須明確關閉。事實上,當達到允許的最大連接數時會發生異常。