缺少ejb-jar.xml中的值

时间:2013-10-23 16:26:16

标签: java-ee glassfish ejb ejb-jar.xml

当试图在glassfish 4.0中部署一个mavenized企业应用程序(包括war和jar项目)时(使用netbeans 7.3.1),我遇到了与this question中类似的问题,说jar是无效的它包含零ejb(这不是真的,因为我的应用程序jar包含4个实体类及其对应的会话bean和本地接口)。由于该帖子中的解决方案是添加ejb-jar.xml,所以我通过添加我的deployement描述符来做同样的事情:

<?xml version="1.0" encoding="UTF-8"?>
   <ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee" 
         version = "3.1"
         xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" 
         xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">


    <enterprise-beans>

        <session>
            <ejb-name>EnginDao</ejb-name>
            <ejb-class>com.crystaleez.dao.EnginDao</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>
        </session>

        <session>
            <ejb-name>AdresseDao</ejb-name>
            <ejb-class>com.crystaleez.dao.AdresseDao</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>
        </session>

        <session>
            <ejb-name>AutomobilisteDao</ejb-name>
            <ejb-class>com.crystaleez.dao.AutomobilisteDao</ejb-class>
            <transaction-type>Container</transaction-type>
            <session-type>Stateless</session-type>
        </session>

        <session>
            <ejb-name>GaragisteDao</ejb-name>
            <ejb-class>com.crystaleez.dao.GaragisteDao</ejb-class>
            <transaction-type>Container</transaction-type>
            <session-type>Stateless</session-type>
        </session>


    </enterprise-beans>


</ejb-jar>

所以我得到以下异常,说在部署应用程序时发生此异常,ejb-jar.xml包含无效内容,其中一个值为{{http://java.sun.com/xml/ns/javaee“:拦截器,”{{ 3}}“:relationship,”http://java.sun.com/xml/ns/javaee“:assembly-descriptor,”http://java.sun.com/xml/ns/javaee“:ejb-client-jar}'是预期的(对我而言,它是法语,我找不到方法改变netbeans中的glassfish记录)

  

Grave:Exception lorsdudéploiementdel'application   [tunmecanique-ear-1.0-SNAPSHOT]:org.xml.sax.SAXParseException;   lineNumber:16; columnNumber:24; Fichier de descripteur de   déploiementMETA-INF / ejb-jar.xml dans l'archive   [tunmecanique-EJB-1.0-SNAPSHOT_jar]。 cvc-complex-type.2.4.a:Contenu   nonvalidetrouvéàpartirde l'élément'enterprise-beans'。 L'une des   valeurs'{“http://java.sun.com/xml/ns/javaee”:拦截器,   “http://java.sun.com/xml/ns/javaee”:关系,   “http://java.sun.com/xml/ns/javaee”:组件描述符,   “http://java.sun.com/xml/ns/javaee”:ejb-client-jar}'参加者。   org.xml.sax.SAXParseException; lineNumber:16; columnNumber:24;   Fichier de descripteurdedéploiementMETA-INF / ejb-jar.xml dans   l'archive [tunmecanique-ejb-1.0-SNAPSHOT_jar]。 CVC-复杂type.2.4.a   :Contenu nonvalidetrouvéàpartirde l'élément'enterprise-beans'。   L'une des valeurs'{“http://java.sun.com/xml/ns/javaee”:拦截器,   “http://java.sun.com/xml/ns/javaee”:关系,   “http://java.sun.com/xml/ns/javaee”:组件描述符,   “http://java.sun.com/xml/ns/javaee”:ejb-client-jar}'参加者。在   com.sun.enterprise.deployment.io.DeploymentDescriptorFile.read(DeploymentDescriptorFile.java:324)     在   com.sun.enterprise.deployment.io.DeploymentDescriptorFile.read(DeploymentDescriptorFile.java:245)     在   com.sun.enterprise.deployment.archivist.Archivist.readStandardDeploymentDescriptor(Archivist.java:665)     在   com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:391)     在   com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:271)     在   com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:280)     在   com.sun.enterprise.deployment.archivist.ApplicationArchivist.readModulesDescriptors(ApplicationArchivist.java:611)     在   com.sun.enterprise.deployment.archivist.ApplicationArchivist.openWith(ApplicationArchivist.java:229)     在   com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:232)     在   org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:188)     在   org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:222)     在   org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96)     在   com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:878)     在   com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:818)     在   com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:374)     在   com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)     在   org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl $ 2 $ 1.run(CommandRunnerImpl.java:527)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl $ 2 $ 1.run(CommandRunnerImpl.java:523)     在java.security.AccessController.doPrivileged(Native Method)at   javax.security.auth.Subject.doAs(Subject.java:356)at   com.sun.enterprise.v3.admin.CommandRunnerImpl $ 2.execute(CommandRunnerImpl.java:522)

我的项目中没有任何这些值(实际上我不知道什么是拦截器,也不知道异常所说的其他所需值)(我不知道为什么ejb-jar.xml是强制性的,为什么没有办法自动生成它我只需要让我的项目成功部署。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

问题可能是您在最后两个声明中对session-typetransaction-type有不同的顺序。请尝试以下方法:

    <session>
        <ejb-name>AutomobilisteDao</ejb-name>
        <ejb-class>com.crystaleez.dao.AutomobilisteDao</ejb-class>
        <session-type>Stateless</session-type>
        <transaction-type>Container</transaction-type>
    </session>

    <session>
        <ejb-name>GaragisteDao</ejb-name>
        <ejb-class>com.crystaleez.dao.GaragisteDao</ejb-class>
        <session-type>Stateless</session-type>
        <transaction-type>Container</transaction-type>
    </session>