我有一个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代表域实体,T代表持久性实体,Gestor是将实体持久化到数据库的类,而Converter是将持久性实体转换为域实体的类。 Gestor有一个本地接口
这是我在ejb模块的pom文件中的构建
<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>
答案 0 :(得分:0)
也许你自己已经弄明白了,但你的EJB.jar
并没有(并且永远不会)包含你的依赖。
因此,您有两种选择:使用EAR
模块构建EJB
和实体/持久实体模块,或者直接将容器用于容器。我更喜欢第一种方法。