<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Multiple session beans with the same interface
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/feijtel">Leon Feijtel</a> in <i>EJB3</i> - <a href="https://community.jboss.org/message/827305#827305">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've searched the website and also tried finding an answer in the EJB3 spec, but haven't been able to find an answer.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Is it possible (is it even allowed??) to have multiple EJB3 session beans that implement the same interface? </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I'm currently migrating an application from JBoss 5 to JBoss 7.2.0 and running into the error: JBAS014546: more than one EJB found with a particular interface....</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've made a simple example to show you what is being done in the code of the application:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>[code]</p><p>@Local</p><p>public interface TestBean {</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Stateless</p><p>@EJB(name = "java:global/coo/TestBean1", beanInterface = TestBean.class)</p><p>public class TestBean1 implements TestBean{</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Stateless</p><p>@EJB(name = "java:global/coo/TestBean2", beanInterface = TestBean.class)</p><p>public class TestBean2 implements TestBean{</p><p>}</p><p>[/code]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>And the error I'm getting is this:</p><p>[code]</p><p>12:51:46,310 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.subunit."coo-ear.ear"."coo-ejb-2.3.2-SNAPSHOT.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."coo-ear.ear"."coo-ejb-2.3.2-SNAPSHOT.jar".INSTALL: JBAS018733: Failed to process phase INSTALL of subdeployment "coo-ejb-2.3.2-SNAPSHOT.jar" of deployment "coo-ear.ear"</p><p>&#160;&#160;&#160; at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:127) [jboss-as-server-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]</p><p>&#160;&#160;&#160; at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]</p><p>&#160;&#160;&#160; at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]</p><p>&#160;&#160;&#160; at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]</p><p>&#160;&#160;&#160; at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]</p><p>&#160;&#160;&#160; at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]</p><p>Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS014546: More than one EJB found with interface of type 'nl.makelaarsuite.coo.test.TestBean' for binding java:global/coo/TestBean2. Found: [View of type nl.makelaarsuite.coo.test.TestBean for org.jboss.as.ejb3.component.stateless.StatelessComponentDescription{serviceName=service jboss.deployment.subunit."coo-ear.ear"."coo-ejb-2.3.2-SNAPSHOT.jar".component.TestBean2}@4c08702a, View of type nl.makelaarsuite.coo.test.TestBean for org.jboss.as.ejb3.component.stateless.StatelessComponentDescription{serviceName=service jboss.deployment.subunit."coo-ear.ear"."coo-ejb-2.3.2-SNAPSHOT.jar".component.TestBean1}@5335bcdf]</p><p>&#160;&#160;&#160; at org.jboss.as.ejb3.deployment.processors.EjbInjectionSource.getResourceValue(EjbInjectionSource.java:97)</p><p>&#160;&#160;&#160; at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.addJndiBinding(ModuleJndiBindingProcessor.java:251)</p><p>&#160;&#160;&#160; at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:196)</p><p>&#160;&#160;&#160; at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)</p><p>&#160;&#160;&#160; at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:164)</p><p>&#160;&#160;&#160; at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:157)</p><p>&#160;&#160;&#160; at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120) [jboss-as-server-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]</p><p>&#160;&#160;&#160; ... 5 more</p><p>[/code]</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I can understand that it's not desirable to have the same interface being used on 2 session beans, but the interface in my application contains a number of methods and that interface is also used later on to perform actions on the session bean.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>A solution that works is to create a separate interface for each bean that inherit from the interface that has been used (TestBean in the example)...but in the application I'm migrating there are many beans that implement this interface, so that would require me to write a lot of "empty" interface classes just to get this work.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I guess if the spec (or JBoss) doesn't allow it, I have no other choice. Just wondering if there is an accaptable solution...</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Any help is greatly appreciated. Thanks!</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Leon</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/827305#827305">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB3 at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>