1

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

<?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 ":interceptors, " http://java.sun.com/xml/ns/javaee ":relationships, " http://java.sun.com/xml/ns/javaee ":assembly-descriptor, " http:// /java.sun.com/xml/ns/javaee ":ejb-client-jar}' 是预期的(对我来说它是法语的,我找不到改变在 netbeans 中记录 glassfish 的方法)

Grave: Exception lors du déploiement de l'application [tunmecanique-ear-1.0-SNAPSHOT] : org.xml.sax.SAXParseException; 行号:16;列号:24;Fichier descripteur de déploiement META-INF/ejb-jar.xml dans l'archive [tunmecanique-ejb-1.0-SNAPSHOT_jar]。cvc-complex-type.2.4.a : Contenu non valide trouvé à partir de l'élément 'enterprise-beans'。L'une des valeurs ' { " http://java.sun.com/xml/ns/javaee":interceptors,"http://java.sun.com/xml/ns/javaee":relationships,"http : //java.sun.com/xml/ns/javaee ":assembly-descriptor, " http://java.sun.com/xml/ns/javaee":ejb-client-jar}' est 出席。org.xml.sax.SAXParseException; lineNumber: 16; columnNumber: 24; Fichier de descripteur de déploiement META-INF/ejb-jar.xml dans l'archive [tunmecanique-ejb -1.0-SNAPSHOT_jar].cvc-complex-type.2.4.a : Contenu non valide trouvé à partir de l'élément 'enterprise-beans'.L'une des valeurs '{" http://java.sun.com/ xml/ns/javaee ":interceptors, " http://java.sun.com/xml/ns/javaee ":relationships, " http://java.sun.com/xml/ns/javaee ":assembly-descriptor , " 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) at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:232) at 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) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run( CommandRunnerImpl.java:523) 在 java.security.AccessController.doPrivileged(Native Method) 在 javax.security.auth.Subject.doAs(Subject.java:356) 在 com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute (CommandRunnerImpl.java:522)执行(CommandRunnerImpl.java:522)执行(CommandRunnerImpl.java:522)

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

感谢帮助 !

4

1 回答 1

0

问题可能是您在最后两个声明中的session-type顺序不同。transaction-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>
于 2013-10-23T18:48:55.080 回答