【发布时间】:2017-10-28 06:10:36
【问题描述】:
我正在处理两个 Eclipse 项目。前者包括一些我设法在 Wildfly Servr 上部署的会话 Bean。后者包括一个我需要注入和使用 bean 的 Servlet。
这是包含会话 bean 的项目的结构。 Projects 是我想用作 Session Facade 以与 Project JPA 实体交互的会话 bean。
这是注入会话 bean 的 servlet。 ProjectsLocal 是它的本地接口。
@EJB
private ProjectsLocal projects;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
projects.createProject("TestProject");
String res = projects.getAllProjects();
System.out.println(res);
request.getRequestDispatcher("/projects.jsp").forward(request,response);
}
这是 web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<ejb-local-ref>
<ejb-ref-name>Projects</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>entities.ProjectsLocal</local-home>
<local>myBeans.BeanA</local>
</ejb-local-ref>
<security-constraint>
<web-resource-collection>
<web-resource-name>administrator</web-resource-name>
<url-pattern>/twp/Login/*</url-pattern>
<http-method>POST</http-method>
<http-method>GET</http-method>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>ADMINISTRATOR</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>school</realm-name>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/error.xhtml</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>ADMINISTRATOR</role-name>
</security-role>
<security-role>
<role-name>USER</role-name>
</security-role>
</web-app>
我在部署 Web 应用程序时遇到了他的错误:Error getting reflection information for class servlet.Projects
【问题讨论】:
-
是否有理由不在 WAR 部署中包含 EJB 库?
标签: java servlets jakarta-ee wildfly