users@glassfish.java.net

RE: Multiple Bean Implementations of the same Remote Interface causes error

From: Martin Gainty <mgainty_at_hotmail.com>
Date: Wed, 13 Apr 2011 21:08:27 -0400

> To: users_at_glassfish.java.net
> Subject: Multiple Bean Implementations of the same Remote Interface causes error
> From: forums_at_java.net
> Date: Wed, 13 Apr 2011 16:50:52 -0500
>
> We're getting an exception when trying to have multiple beans implement the
> same remote interface. Following is a description of our set-up. This is
> using Glassfish v3.1
>
> We have a jar that gets copied into the lib/applibs directory of our
> glassfish domain which contains the Remote Interface for an EJB.
>
> @Remote public interface RemoteInterfaceBean { public void
> remoteBusinessMethod(); }
> Then we have an EAR project with to EJB projects inside. Each EJB project
> has an implementation of the Remote Interface. Like so:
>
> SomeEAR contains: SomeEJBProject1 which contains:
> @Stateless(name="BeanImplementation1") public class BeanImplementation1
> implements RemoteInterfaceBean { @Overrides public void
> remoteBusinessMethod() { //some code } } SomeEJBProject2 which contains:
> @Stateless(name="BeanImplementation2") public class BeanImplementation2
> implements RemoteInterfaceBean { @Overrides public void
> remoteBusinessMethod() { //some code } }
> When attempting to deploy the EAR with both EJB projects inside, we're
> getting an exception like:
>
> javax.naming.NameAlreadyBoundException: Use rebind to override
>
> Further up in the log it's telling us that it can't bind to the
> RemoteInterfaceBean.
>
> So we have a few questions:
>
> 1) Can we not have multiple bean implementations of the same remote
> interface?

MG>one Remote Interface for each accessed bean
MG>for Beans with a 3.x Remote Business interface :

MG>EJB 3.x, assuming a global JNDI name
of "com.acme.FooRemoteBusiness"
:

MG>

MG> FooRemoteBusiness foo =
(FooRemoteBusiness)
ic.lookup("com.acme.FooRemoteBusiness");

http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB



> 2) Why is glassfish using the remote interface bean class name to do the
> JNDI binding? Shouldn't it be using the bean implementation class?
MG>All session beans require a session bean class. All enterprise
beans that permit remote access must have a home and remote interface.
MG>The SessionBean interface extends the EnterpriseBean interface, which in turn extends the Serializable interface.
MG>The SessionBean interface declares the ejbRemove, ejbActivate, ejbPassivate, and setSessionContext methods.
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Session2.html

>
> Thanks in advance.
>
>
> --
>
> [Message sent by forum member 'samlclient_user']
>
> View Post: http://forums.java.net/node/791654
>
>