[jboss-user] [EJB3] - Re: Multiple session beans with the same interface

jaikiran pai do-not-reply at jboss.com
Wed Jul 10 07:10:37 EDT 2013


jaikiran pai [https://community.jboss.org/people/jaikiran] created the discussion

"Re: Multiple session beans with the same interface"

To view the discussion, visit: https://community.jboss.org/message/827308#827308

--------------------------------------------------------------
It's perfectly valid for multiple EJBs to implement the same interface. The error isn't because multiple EJBs are implementing the same interface, but it's because the usage of the @EJB in your application is such that the container has no idea which of the multiple EJB implementations you are trying to setup into the java:global namespace via the @EJB usage:

@Stateless
@EJB(name = "java:global/coo/TestBean1", beanInterface = TestBean.class)
public class TestBean1 implements TestBean{
}
 
@Stateless
@EJB(name = "java:global/coo/TestBean2", beanInterface = TestBean.class)
public class TestBean2 implements TestBean{


The spec allows you to narrow it down to the specific EJB implementation. You can do so by using the "beanName" attribute of the @EJB where you can specify the name of the bean (which by default is the bean implementation's simple class name). So you should change that above code to:

@Stateless
@EJB(name = "java:global/coo/TestBean1", beanInterface = TestBean.class, *beanName="TestBean1"*)
public class TestBean1 implements TestBean{
}

@Stateless
@EJB(name = "java:global/coo/TestBean2", beanInterface = TestBean.class, *beanName="TestBean2"*)
public class TestBean2 implements TestBean{
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/827308#827308]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130710/81ddab96/attachment.html 


More information about the jboss-user mailing list