@EJB 注释是否适用于远程调用? [英] does @EJB Annotation work for remote call?
本文介绍了@EJB 注释是否适用于远程调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class Servlet2Stateless extends HttpServlet {
@EJB private HelloUserLocal helloUser;
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
out.println(newSess.getName());
}
当我在不同的服务器上部署 EJB 和 Servlet 时,上面的代码行会起作用吗?或者我需要通过传统方式调用它????
will above line of code work when I have EJB and Servlet deployed on different servers? or I need to call it through traditional way????
推荐答案
如果 EJB 与您的客户端 (Servlet) 驻留在不同的服务器上,则您不能使用带有 @EJB 注释的依赖注入.
If the EJB resides on the different server than your client (Servlet) than you cannot use the dependency injection with @EJB annotation.
我猜您需要采用旧的 JNDI 方式.
I guess that you'll need to go with the old JNDI way.
这篇关于@EJB 注释是否适用于远程调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文