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)不同的服务器上,则不能使用@EJB注释的依赖项注入.
我想你需要采用旧的JNDI方式.