【发布时间】:2016-05-15 12:25:23
【问题描述】:
我的测试豆
@Stateless
public class TestBean implements TestLocal {
public String getMessage(String name) {
return "Test "+ name;
}
}
我的界面
@Local
public interface TestLocal {
public String getMessage(String name);
}
我正在使用它
@EJB
private TestLocal testLocal;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String result;=testLocal.getMessage("ASDASD");
req.getSession().setAttribute("Test1",result);
RequestDispatcher rd=req.getRequestDispatcher("Index.jsp");
rd.forward(req,resp);
}
我在结果行上得到 NullPointerException。
【问题讨论】:
-
您应该在同一个 EAR 项目中拥有 ejb 和 servlet。否则,使用远程访问。