需要EJB帮助
问题描述:
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)
}
任何意见,将不胜感激。谢谢。
答
这是我的第一个想法。 你应该有类似
@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)
}