无法加载EJB模块

jsl*_*mka 8 java glassfish

我正在参加企业应用程序开发课程.我是JSF的新手.我正在尝试使用GlassF 3.1使用JSF和Netbeans IDE部署我的应用程序.

我得到的错误如下所示.

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
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

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

编辑 战争文件结构树

  • META-INF/MANIFEST.MF
  • WEB-INF/classes目录
  • WEB-INF/lib目录/ primefaces-2.1.1.jar
  • WEB-INF/web.xml文件
  • index.shtml

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

小智 6

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">
Run Code Online (Sandbox Code Playgroud)


Ily*_*lya 1

因此,您有 Web 应用程序,它不是 ejb-jar,而是需要打包存档的 Web 模块*.war
结构应该是

  • *.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>  
Run Code Online (Sandbox Code Playgroud)

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