Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven doesn't recognize EJB as dependency of project when trying to define module

Tags:

Today I upgraded my local Glassfish server to 3.1.1 in preparation for my company's upgrading of the servers to the same version. I am attempting to convert my web service project to play nice with the new server, and have hit a road block.

In my ear's pom file, I previously had both the webapp and the ejb listed as dependencies. In the webapp's pom, I had the ejb listed as a dependency as well. When attempting to deploy this configuration to Glassfish 3.1.1, I received this error:

Error occurred during deployment: Exception while deploying the app [ear] : Cannot resolve reference Local ejb-ref name=name,Local 3.x interface =interface,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session because there are 2 ejbs in the application with interface interface. Some of the possible causes: 1. The EJB bean class was packaged in an ear lib library (or through any other library mechanism which makes the library visible to all component modules), this makes all the component modules include this bean class indirectly. 2. The EJB bean class was packaged in a component module which references the EJB, either directly or indirectly through Manifest, WEB-INF/lib. The EJB bean class should only be packaged in the declaring ejb module and not the referencing modules. The referencing modules should only include EJB interfaces.. Please see server.log fo .... msg.seeServerLog

Essentially I believe it is saying that because I have the EJB listed as a dependency in two different areas, Glassfish 3.1.1 doesn't know which dependency to look to. This wasn't an issue in 2.1.1. Because of this, I removed the dependency in the ear, seeing as it would still be part of the ear's effective pom.

However, now when the ear generates the application.xml file, it omits all the ejb information from the file. I can deploy the application just fine now, but when I try to run anything I get NameNotFoundExceptions regarding the ejbs.

I attempted to add the ejb modules to the ear pom manually with the tag, but when I try to build the project I get the error message:

Artifact[ejb] is not a dependency of the project.

This despite the fact that when I look at the effective pom for the ear I can see the ejb listed as a dependency.

How can I generate the application.xml file properly while still conforming to Glassfish 3.1.1's more rigid ruleset?

Let me know if you need any more information, and thanks for the help!

like image 621
lowell Avatar asked Nov 18 '11 22:11

lowell


1 Answers

The answer ended up being pretty simple, and I'm kicking myself a bit for it. In the webapp's pom file, I just had to add the scope line to the ejb dependency:

<dependency>     <groupId>com.groupId</groupId>     <artifactId>webservice-service-ejbs</artifactId>     <version>${project.version}</version>     <type>ejb</type>     <scope>provided</scope> </dependency> 

With this, I could keep the ejb dependency in the ear pom, application.xml generated properly and glassfish 3.1.1 didn't get confused thinking there were multiple ejb classes with the same name.

EDIT: Here's what the ejb dependency looks like in the ear pom

<dependency>     <groupId>com.groupId</groupId>     <artifactId>webservice-service-ejbs</artifactId>     <type>ejb</type> </dependency> 

Thanks to those who helped me out.

like image 92
lowell Avatar answered Dec 08 '22 15:12

lowell