【问题标题】:Unable to load EJB module无法加载 EJB 模块
【发布时间】:2012-09-07 00:41:30
【问题描述】:

我正在学习企业应用程序开发课程。我是 JSF 的新手。我正在尝试使用 JSF 和 Netbeans IDE 使用 Glassfish 3.1 部署我的应用程序。

我得到的错误如下所示。

Error occurred during deployment: Exception while preparing the app : Unable to load the EJB module. DeploymentContext does not contain any EJB. Check the archive to ensure correct packaging for F:\Seagate\docs backup\NetBeansProjects\ent-app-dev\Slamka_Project1\build\web. If you use EJB component annotations to define the EJB, and an ejb or web deployment descriptor is also used, please make sure that the deployment descriptor references a Java EE 5 or higher version schema, and that the metadata-complete attribute is not set to true, so the component annotations can be processed as expected. Please see server.log for more details.

以下是我对 EJB 的引用。

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.ejb.EJB;
@EJB

任何帮助将不胜感激。

编辑:这是一个 Java Web 应用程序。

编辑 战争文件结构树

  • META-INF/MANIFEST.MF
  • WEB-INF/类
  • WEB-INF/lib/primefaces-2.1.1.jar
  • WEB-INF/web.xml
  • index.shtml

我的文件在 xhtml 文档中没有 EJB 标记。它有下面列出的内容。

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsf/core">

【问题讨论】:

  • 贴出更多代码和jar结构
  • 似乎无法将目录结构转换为列表格式。

标签: java glassfish


【解决方案1】:

所以你有 web 应用程序,它不是 ejb-jar,它是应该打包到 *.war 存档的 web 模块。
结构应该是

  • *.war/META-INF/persistence.xml
  • *.war/META-INF/MANIFEST.MF
  • *.war/WEB-INF/sun-web.xml
  • *.war/WEB-INF/web.xml
  • *.war/WEB-INF/classes/ - 包中编译的类
  • *.war/WEB-INF/lib/ - 库
  • *.war/index.jsp - 主页

sun-web.xml 示例

<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app>
  <context-root>/app</context-root>
</sun-web-app>  

如果你使用Maven,你可以使用maven-war-plugin

【讨论】:

  • 我尝试用 ejb-jar 替换 html,但没有成功。不过可能做得不对。
  • 我正在使用 Facelets 和 GlassFish。我知道我没有使用 Maven。
【解决方案2】:

原来问题是 SQL 语句中的拼写错误(1 和 l [小写 L]),我需要对项目进行“清理和构建”。感谢那些努力帮助我解决问题的人。

【讨论】:

    【解决方案3】:

    web.xml web-app 属性版本更改为 2.5 或更高版本可解决此问题。

    web.xml 的更新 web-app 元素将是,

    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    

    【讨论】:

      猜你喜欢
      • 2011-03-08
      • 2021-01-11
      • 2015-02-09
      • 1970-01-01
      • 2016-10-09
      • 2012-10-10
      • 2017-09-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多