2009-11-11 312 views
0
public void runTest() throws Exception { 
     InitialContext ctx = new InitialContext(); 
     ResourceManager bean = (ResourceManager) ctx.lookup("ejb/ResourceManagerJNDI"); 
     System.out.println(bean.DummyText()); 
} 

你好。所以我試圖創建一個EJB應用程序,這是它的測試客戶端。 JNDI查找是成功的,但調用「DummyText」方法時,我得到以下錯誤:需要EJB幫助

javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
    java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB; nested exception is: 
    javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB (...) 

這是bean類的樣子:

@Stateless(name="ResourceManager", mappedName="ejb/ResourceManagerJNDI") 
@Remote 
@Local 
public class ResourceManagerBean implements ResourceManager 
{ 
    @EJB 
    private AccessDAO accessDAO; 
    @EJB 
    private ResourceDAO resourceDAO; 
    @EJB 
    private DepartmentDAO departmentDAO; 

    (list of methods) 
} 

任何意見,將不勝感激。謝謝。

回答

1

這是我的第一個想法。 你應該有類似

@Remote 
public interface ResourceManagerSessionRemote { 

    (list of methods) 

} 

打破你的遠程和本地接口出

@Stateless(name="ResourceManager", mappedName="ejb/ResourceManagerJNDI") 
public class ResourceManagerBean implements ResourceManagerSessionRemote 
{ 
    @EJB 
    private AccessDAO accessDAO; 
    @EJB 
    private ResourceDAO resourceDAO; 
    @EJB 
    private DepartmentDAO departmentDAO; 

    (list of methods) 
}