【问题标题】:How to deploy EJB module in Glassfish with jar dependencies如何在具有 jar 依赖关系的 Glassfish 中部署 EJB 模块
【发布时间】:2016-02-24 18:07:53
【问题描述】:

我有一个 Maven EJB 模块,它依赖于两个 SE 模块,一个是域实体,另一个是持久性实体。

<dependencies>
    <dependency>
        <groupId>com.mycompany.modules</groupId>
        <artifactId>entities</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>com.mycompany.modules</groupId>
        <artifactId>persistent-entities</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

我构建了 EJB 模块,当我尝试在 glassfish 中部署 ejb-module.jar 时,我得到一个依赖模块引用的错误:

Grave: Class [ com/mycompany/entities/EDSesion ] not found. Error while loading [ class com.mycompany.ejb.dataAccess.GestorADSesion ] Grave: Class [ com/mycompany/persistent/entities/TSesion ] not found. Error while loading [ class com.mycompany.ejb.converters.EDSesionConverter ] Grave: Cannot resolve reference Local ejb-ref name=com.mycompany.ejb.dataAccess.GestorADSesion/eDSesionFConverter,Local 3.x interface =com.mycompany.ejb.converters.interfaces.EDSesionConverterLocal,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session Grave: Excepción al desplegar la aplicación [app-ejb-1.0] Grave: Exception during lifecycle processing java.lang.RuntimeException: Cannot resolve reference Local ejb-ref name=com.mycompany.ejb.dataAccess.GestorADAreaF/eDAreaFConverter,Local 3.x interface =com.mycompany.ejb.converters.interfaces.EDAreaFConverterLocal,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session

注意:ED代表Domain Entities,T代表持久化实体,Gestor是将实体持久化到数据库的类,Converter是将持久化实体转换成域实体的类​​。 Gestor 有一个本地接口

这是我在 pom 文件中构建的 ejb 模块

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <ejbVersion>3.1</ejbVersion>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>7.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

【问题讨论】:

  • 也许您已经自己弄清楚了,但是您的 EJB.jar 没有(也永远不会)包含您的依赖项。因此,您有两种选择:使用您的 EJB 模块和您的实体/持久实体模块构建一个 EAR,或者使您的依赖项直接对容器可用。我更喜欢第一种方法。
  • @aribeiro,您的评论似乎更像是对我的回答,而不仅仅是评论。我会赞成它????
  • 感谢@aribeiro 成功

标签: deployment jar dependencies ejb glassfish-4


【解决方案1】:

也许您已经自己想通了,但您的 EJB.jar 没有(也永远不会)包含您的依赖项。

因此,您有两种选择:使用您的 EJB 模块和您的实体/持久实体模块构建一个 EAR,或者使您的依赖项直接对容器可用。我更喜欢第一种方法。

【讨论】:

    猜你喜欢
    • 2021-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-03
    • 2015-04-30
    • 1970-01-01
    • 2023-03-18
    • 2015-12-28
    相关资源
    最近更新 更多