@EJB(name=...) fails to start when more than one EJB implements the same interface in JBoss EAP 7.2

Solution Unverified - Updated -

Issue

@EJB(name=...) fails to start when more than one EJB implements the same interface

When 2 EJBs implement the same interface but have different names specified and a client uses @EJB and specifies the name, it is failing because there are 2 EJBs implementing the same interface, but it should use the name to distinguish between the 2.

@javax.ejb.Stateless(name="SLSB1")
public class MyStateless1 implements MyLocal {
...
}

@javax.ejb.Stateless(name="SLSB2")
public class MyStateless2 implements MyLocal {
...
}

@javax.ejb.Startup
@javax.ejb.Singleton
public class MyTestSingleton {  
  @javax.ejb.EJB(name="SLSB1")
  private MyLocal myStateless1;

  @javax.ejb.EJB(name="SLSB2")
  private MyLocal myStateless2;
}
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service jboss.deployment.unit."jbeap.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."jbeap.jar".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "jbeap.jar"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:151)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1738)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1700)
    at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1558)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0052: Failed to install component MyTestSingleton
    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.deploy(ComponentInstallProcessor.java:109)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:144)
    ... 8 more
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEJB0408: More than one EJB found with interface of type 'reproducer.MyLocal' for binding SLSB1. Found: [View of type reproducer.MyLocal for org.jboss.as.ejb3.component.stateless.StatelessComponentDescription{serviceName=service jboss.deployment.unit."jbeap.jar".component.SLSB2}@1347b10e, View of type reproducer.MyLocal for org.jboss.as.ejb3.component.stateless.StatelessComponentDescription{serviceName=service jboss.deployment.unit."jbeap.jar".component.SLSB1}@40fc693f]
    at org.jboss.as.ejb3.deployment.processors.EjbInjectionSource.getResourceValue(EjbInjectionSource.java:90)
    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.processBindings(ComponentInstallProcessor.java:263)
    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.access$000(ComponentInstallProcessor.java:80)
    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor$1.handle(ComponentInstallProcessor.java:215)
    at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.deployComponent(ComponentInstallProcessor.java:218)
    at org.jboss.as.ee.component.deployers.ComponentInstallProcessor.deploy(ComponentInstallProcessor.java:101)
    ... 9 more

Environment

Red Hat JBoss Enterprise Application Platform (EAP) 7.2.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content