确实@EJB注释工作,为远程调用?

确实@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());


}

将上述code的老本行,当我已经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.