我试图按照Redbook示例(IBM WebSphere Application Server Liberty Profile Guide for Developers,5.2.3使用远程EJB开发应用程序)在Liberty Profile服务器中调用远程EJB。
所有编译和部署都没有问题,但在运行时会给出以下错误消息:
Error 404: javax.servlet.UnavailableException: SRVE0319E: For the [com.ibm.itso.ejbRemote.HelloRemoteServlet] servlet, com.ibm.itso.ejbRemote.HelloRemoteServlet servlet class was found, but a resource injection failure has occurred. CWNEN0030E: The server was unable to obtain an object instance for the java:comp/env/com.ibm.itso.ejbRemote.HelloRemoteServlet/helloRemoteBean reference. The exception message was: CWNEN1003E: The server was unable to find the java:global/ITSORemote/ITSORemoteEJB/HelloRemoteEJB!com.ibm.itso.ejbRemote.view.HelloRemoteEJBRemote binding with the com.ibm.itso.ejbRemote.view.HelloRemoteEJBRemote type for the java:comp/env/com.ibm.itso.ejbRemote.HelloRemoteServlet/helloRemoteBean reference.
有什么不对?本地EJB示例工作得很好。
是仅仅在客户端代码中指定远程EJB还是在其他地方(属性文件或server.xml)?
@EJB(lookup="java:global/ITSORemote/ITSORemoteEJB/HelloRemoteEJB!com.ibm.itso.ejbRemote.view.HelloRemoteEJBRemote")
private HelloRemoteEJBRemote helloRemoteBean;
只有具有@Local批注的界面才会绑定,并显示在日志中。带有@Remote注释的接口没有绑定,也没有显示在日志中。
可能是什么错误?
这个procedure确实有一些额外的配置,最后它被指定从你的应用程序配置ibm - * - bnd.xml:
<ejb-ref name="helloRemoteBean" binding-name="java:global/ITSORemote/ITSORemoteEJB/HelloRemoteEJB!com.ibm.itso.ejbRemote.view.HelloRemoteEJBRemote"/>
如果未绑定@Remote
接口,则server.xml要么不包含ejbRemote-3.2
功能,要么缺少ORB的配置(即如果ORB未正确启动,则ejbRemote功能将无法启动。例如,您的server.xml至少包含以下内容:
<server>
<featureManager>
<feature>ejbRemote-3.2</feature>
</featureManager>
<iiopEndpoint id="defaultIiopEndpoint" iiopPort="2809" iiopsPort="2810"/>
</server>