java 无法加载 EJB 模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12414526/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 08:48:31  来源:igfitidea点击:

Unable to load EJB module

javaglassfish

提问by jslamka

I am taking a course in Enterprise Application Development. I am new to JSF. I am trying to deploy my app using Glassfish 3.1 using JSF and Netbeans IDE.

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

The error I get is listed below.

下面列出了我得到的错误。

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.

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.

Below are the references to EJB I have made.

下面是我对 EJB 的引用。

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

Any help would be appreciated.

任何帮助,将不胜感激。

EDIT: This is a Java Web Application.

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

EDITWAR FILE STRUCTURE TREE

编辑War文件结构树

  • META-INF/MANIFEST.MF
  • WEB-INF/classes
  • WEB-INF/lib/primefaces-2.1.1.jar
  • WEB-INF/web.xml
  • index.shtml
  • 元信息/清单.MF
  • WEB-INF/类
  • WEB-INF/lib/primefaces-2.1.1.jar
  • WEB-INF/web.xml
  • 索引.shtml

My file does not have an EJB tag in teh xhtml document. it has what is listed below.

我的文件在 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">

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

回答by rnsammeta

Changing the web.xmlweb-appattribute version to 2.5or higher resolved this issue.

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

Updated web-app element of web.xmlwill be,

更新的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">

回答by Ilya

So you have web application, it's not ejb-jar, it's web module that sould be packeged to *.wararchive.
Structure should be

所以你有 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/ - compiled classes in packages
  • *.war/WEB-INF/lib/ - libs
  • *.war/index.jsp - home page
  • *.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 - 主页

example of sun-web.xml

的例子 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>  

if you are using Maven, you can use maven-war-plugin

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

回答by jslamka

Turns out the issue was a typo in a SQL statement (1 and l [lower case L]) and I needed to do a "Clean and build" on the project. Thank you for those who put effort into helping me solve my issue.

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