千野羽
   
發文: 5
積分: 0
|
於 2013-08-17 00:21
     
請問在使用session bean時,呼叫Local interface的回傳值 是否有任何的限制(例如回傳值必須是serializable)
最近遇到一個需求是要提供一個EJB,讓其他在同一個JVM上的Application 透過這個EJB去取得EntityManager,但是在呼叫Local interface時 會出現ClassNotFoundException,所以想請問是否EntityManager無法透過 EJB local interface去取得?
底下是我的程式碼和錯誤訊息,還麻煩各位解答,感謝 測試的環境是JBoss 7.1.1.Final,使用EclipseLink
Session Bean : @Stateless public class BasicBean implements BasicBeanLocal {
@PersistenceContext(unitName = "TESTDEV") private EntityManager em; public EntityManager getEntityManager() throws Exception{ return em; }
}
Local Interface: @Local public interface BasicBeanLocal { public EntityManager getEntityManager() throws Exception; }
Application程式碼(和EJB部屬在同一個JBoss上) public EntityManager getEntityManagerTest() throws Exception{ try{ InitialContext initCtx = new InitialContext(); BasicBeanLocal basic = (BasicBeanLocal)initCtx.lookup(BASICBEAN_JNDI); EntityManager em = basic.getEntityManager(); -->錯誤訊息出現在這一行 return em; }catch(Exception ex){ throw ex; } }
錯誤訊息: ClassNotFoundException marshaling EJB parameters,org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:229) org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:216) org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:188) org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:179) org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43) org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128) org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
  |