Skip to main content

Resolving ambiguous dependencies with ejb-jar.xml (Glassfish v3)

2 replies [Last post]
atomicknight
Offline
Joined: 2010-03-14
Points: 0

I have just recently started using EJBs and have run into a bit of a problem with regard to resolving ambiguous dependencies (for injection). I've attached a test application (containing source files [in WEB-INF/classes] as well as compiled class files and relevant deployment descriptors) that exhibits the problem I'm encountering.

To summarize, I have a local business interface named Greeter and two stateless session beans that implement that interface; the beans are named GreeterBeanA and GreeterBeanB. There is a third stateless session bean named HelperBean that contains an injection point for Greeter. I'm trying to use the ejb-jar.xml deployment descriptor to manually resolve the dependency (i.e. specify that one of GreeterBeanA and GreeterBeanB should be used to satisfy the Greeter dependency in HelperBean); however, Glassfish always gives me this error:

Exception while deploying the app : java.lang.RuntimeException: Cannot resolve reference Local ejb-ref name=com.example.HelperBean/greeter,Local 3.x interface =com.example.Greeter,ejb-link=null,lookup=null,mappedName=,jndi-name=,refType=Session because there are 2 ejbs in the application with interface com.example.Greeter

The same application works just fine on the latest JBoss release (6.0.0.M2). This seems to suggest that Glassfish ignores the deployment descriptor prior to scanning for annotations and effectively "short-circuits" the validation process by immediately exiting if there's an ambiguous dependency, whereas JBoss considers both the annotations and the deployment descriptor before determining whether there is an ambiguous dependency.

Is this the intended behavior? In other words, is JBoss doing something non-standard to allow the application to deploy properly? Or am I just doing something totally wrong?

I'm using the latest release of Glassfish v3 with all available updates installed. The ejb-jar.xml deployment descriptor is configured for EJB 3.1.

Thanks in advance for your help!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ksak
Offline
Joined: 2005-05-20
Points: 0

This looks like a bug in the annotation override processing within the .war. Please file an issue for it. The easiest workaround is to just remove the @EJB annotation from the source file, since the ejb-jar.xml includes the injection information. Of course you can also just directly lookup any EJB reference in the same module using java:module/. Thanks for reporting this.

atomicknight
Offline
Joined: 2010-03-14
Points: 0

Thanks for the reply. I've filed the issue here: https://glassfish.dev.java.net/issues/show_bug.cgi?id=11684

Thanks again!