【问题标题】:Wildfly: Error getting reflective information for classWildfly:获取类的反射信息时出错
【发布时间】: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


【解决方案1】:

参考这个article。 JBoss AS7+ 中的类加载与以前的 JBoss AS 版本有很大不同。
类加载基于 JBoss Modules 项目。与更熟悉的分层类加载环境不同,AS7 的类加载基于必须明确定义对其他模块的依赖关系的模块。

Ear 部署 是多模块部署。这意味着并非耳朵中的所有类都必须访问耳朵中的所有其他类,除非已定义明确的依赖关系。 默认情况下EAR/lib 目录是一个单独的模块,每个 WAR 或 EJB jar 部署也是一个单独的模块。

请参阅文章中的jboss-deployment-structure.xml 进行耳部部署。

【讨论】:

    猜你喜欢
    • 2017-06-19
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多