I have an EAR file containing 2 ejb jar files. Each of the jar files has one EJB3.0
Stateless bean each:
MyApp.ear
| |
| |--- META-INF
| | |
| | |--- application.xml
| | |
| | |--- jboss-app.xml
| |
| |
| |--- appOneEjb.jar
| | |
| | |--- org/myapp/AppManagerBean.class
| |
| |
| |--- appTwoEjb.jar
| | |
| | |--- org/myapp/AppManagerBeanV2.class
| |
| |
| |--- common.jar
| | |
| | |--- org/myapp/AppManager.class
|
|
Both these stateless beans (AppManagerBeanV2.class and AppManagerBean.class) implement the
same AppManager.class and more importantly the "name" attribute of the
@Stateless annotation for both these beans is the same. However, these 2 beans are
packaged in different jar files inside an EAR:
@Stateless (name="mybean")
| @Remote (AppManager.class)
| public class AppManagerBeanV2 implements AppManager {
|
| public String getVersion() {
| return "2.0";
| }
|
| }
|
@Stateless (name="mybean")
| @Remote (AppManager.class)
| public class AppManagerBean implements AppManager {
|
| public String getVersion() {
| return "1.0";
| }
|
| }
|
I could not find much documentation on the name attribute of @Stateless. But since the
"name" is equivalent to the ejb-name in the ejb-jar.xml, i guess, the following
(from the ejb-jar.xml dtd) holds true:
anonymous wrote : The ejb-name element specifies an enterprise bean's name. ... The
name must be unique among the names of the enterprise beans in the same ejb-jar file.
|
So as per this definition, i guess i can have multiple EJBs with the same name, but in
different jar files (as in my sample application). But when i deploy, this on JBoss-5 CR2
i get the following exception during deployment:
17:01:35,311 INFO [JBossASKernel] Created KernelDeployment for: another_ejb3.jar
| 17:01:35,311 INFO [JBossASKernel] installing bean:
jboss.j2ee:ear=ZEJB3Persistence.ear,jar=another_ejb3.jar,name=mybean,service=EJB3
| 17:01:35,311 INFO [JBossASKernel] with dependencies:
| 17:01:35,311 INFO [JBossASKernel] and demands:
| 17:01:35,311 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
| 17:01:35,311 INFO [JBossASKernel] and supplies:
| 17:01:35,311 INFO [JBossASKernel] jndi:AppManagerRemoteV2
| 17:01:35,311 INFO [JBossASKernel] Class:org.myapp.ejb.AppManager
| 17:01:35,311 INFO [JBossASKernel]
jndi:ZEJB3Persistence/mybean/remote-org.myapp.ejb.AppManager
| 17:01:35,311 INFO [JBossASKernel] jndi:ZEJB3Persistence/mybean/remote
| 17:01:35,311 INFO [JBossASKernel] Added
bean(jboss.j2ee:ear=ZEJB3Persistence.ear,jar=another_ejb3.jar,name=mybean,service=EJB3) to
KernelDeployment of: another_ejb3.jar
| 17:01:35,779 INFO [JBossASKernel] Created KernelDeployment for: myapp_ejb3.jar
| 17:01:35,795 INFO [JBossASKernel] installing bean:
jboss.j2ee:ear=ZEJB3Persistence.ear,jar=myapp_ejb3.jar,name=mybean,service=EJB3
| 17:01:35,795 INFO [JBossASKernel] with dependencies:
| 17:01:35,795 INFO [JBossASKernel] and demands:
| 17:01:35,795 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
| 17:01:35,795 INFO [JBossASKernel] and supplies:
| 17:01:35,795 INFO [JBossASKernel] Class:org.myapp.ejb.AppManager
| 17:01:35,795 INFO [JBossASKernel]
jndi:ZEJB3Persistence/mybean/remote-org.myapp.ejb.AppManager
| 17:01:35,795 INFO [JBossASKernel] jndi:AppManagerRemote
| 17:01:35,795 INFO [JBossASKernel] jndi:ZEJB3Persistence/mybean/remote
| 17:01:35,795 INFO [JBossASKernel] Added
bean(jboss.j2ee:ear=ZEJB3Persistence.ear,jar=myapp_ejb3.jar,name=mybean,service=EJB3) to
KernelDeployment of: myapp_ejb3.jar
| 17:01:35,795 INFO [JBossASKernel] installing bean:
jboss.j2ee:ear=ZEJB3Persistence.ear,jar=myapp_ejb3.jar,name=UserManagerBean,service=EJB3
| 17:01:35,795 INFO [JBossASKernel] with dependencies:
| 17:01:35,795 INFO [JBossASKernel] and demands:
| 17:01:35,795 INFO [JBossASKernel]
jboss.j2ee:ear=ZEJB3Persistence.ear,name=mybean,service=EJB3,*
| 17:01:35,795 INFO [JBossASKernel]
persistence.unit:unitName=ZEJB3Persistence.ear/myapp_ejb3.jar#EJB3Persistence
| 17:01:35,795 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
| 17:01:35,795 INFO [JBossASKernel] and supplies:
| 17:01:35,795 INFO [JBossASKernel] Class:org.myapp.ejb.UserManagerRemote
| 17:01:35,795 INFO [JBossASKernel]
jndi:ZEJB3Persistence/UserManagerBean/local-org.myapp.ejb.UserManagerLocal
| 17:01:35,795 INFO [JBossASKernel] Class:org.myapp.ejb.UserManagerLocal
| 17:01:35,795 INFO [JBossASKernel] jndi:ZEJB3Persistence/UserManagerBean/local
| 17:01:35,795 INFO [JBossASKernel] jndi:RemoteUserManagerBean
| 17:01:35,795 INFO [JBossASKernel]
jndi:ZEJB3Persistence/UserManagerBean/remote-org.myapp.ejb.UserManagerRemote
| 17:01:35,795 INFO [JBossASKernel] jndi:testMappedNameJai
| 17:01:35,795 INFO [JBossASKernel] Added
bean(jboss.j2ee:ear=ZEJB3Persistence.ear,jar=myapp_ejb3.jar,name=UserManagerBean,service=EJB3)
to KernelDeployment of: myapp_ejb3.jar
| 17:01:37,186 INFO [SessionSpecContainer] Starting
jboss.j2ee:ear=ZEJB3Persistence.ear,jar=another_ejb3.jar,name=mybean,service=EJB3
| 17:01:37,201 INFO [EJBContainer] STARTED EJB: org.myapp.ejb.impl.AppManagerBeanV2
ejbName: mybean
| 17:01:37,217 WARN [SessionSpecContainer] Populating JBoss-specific annotation
metadata manually until done by deployers:
jboss.j2ee:ear=ZEJB3Persistence.ear,jar=another_ejb3.jar,name=mybean,service=EJB3
| 17:01:37,608 INFO [SessionSpecContainer] Starting
jboss.j2ee:ear=ZEJB3Persistence.ear,jar=myapp_ejb3.jar,name=mybean,service=EJB3
| 17:01:37,608 INFO [EJBContainer] STARTED EJB: org.myapp.ejb.impl.AppManagerBean
ejbName: mybean
| 17:01:37,608 WARN [SessionSpecContainer] Populating JBoss-specific annotation
metadata manually until done by deployers:
jboss.j2ee:ear=ZEJB3Persistence.ear,jar=myapp_ejb3.jar,name=mybean,service=EJB3
| 17:01:37,639 INFO [SessionSpecContainer] Stopping
jboss.j2ee:ear=ZEJB3Persistence.ear,jar=myapp_ejb3.jar,name=mybean,service=EJB3
| 17:01:37,639 INFO [EJBContainer] STOPPED EJB: org.myapp.ejb.impl.AppManagerBean
ejbName: mybean
| 17:01:37,670 ERROR [AbstractKernelController] Error installing to Start:
name=jboss.j2ee:ear=ZEJB3Persistence.ear,jar=myapp_ejb3.jar,name=mybean,service=EJB3
state=Create
| java.lang.RuntimeException: Could not bind Reference Class Name: Proxy for:
org.myapp.ejb.AppManager
| Type: ProxyFactoryKey
| Content: ProxyFactory/AppManagerRemote
| Type: EJB Container Name
| Content:
jboss.j2ee:ear=ZEJB3Persistence.ear,jar=myapp_ejb3.jar,name=mybean,service=EJB3
| Type: Remote Business Interface
| Content: org.myapp.ejb.AppManager
| Type: Remoting Host URL
| Content: socket://ps3346:3873/?
| into JNDI at "ZEJB3Persistence/mybean/remote-org.myapp.ejb.AppManager"
| at
org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase.bind(JndiSessionRegistrarBase.java:694)
| at
org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase.bind(JndiSessionRegistrarBase.java:674)
| at
org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase.bind(JndiSessionRegistrarBase.java:641)
| at
org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase.bindEjb(JndiSessionRegistrarBase.java:165)
| at
org.jboss.ejb3.session.SessionSpecContainer.lockedStart(SessionSpecContainer.java:706)
| at
org.jboss.ejb3.stateless.StatelessContainer.lockedStart(StatelessContainer.java:220)
| at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:858)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at
org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
| at
org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
| at
org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
| at
org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
| at
org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
| at
org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
| at
org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
| at
org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
| at
org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
| at
org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
| at
org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
| at
org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
| at
org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
| at
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
| at
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
| at
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
| at
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
| at
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
| at
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
| at
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
| at
org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:124)
| at
org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)
| at
org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
| at
org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
| at
org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:169)
| at
org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1285)
| at
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1003)
| at
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1024)
| at
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1056)
| at
org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:944)
| at
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
| at
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
| at
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
| at
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
| at
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
| at
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
| at
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
| at
org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:627)
| at
org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:541)
| at
org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:265)
| at
org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:143)
| at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:409)
| at org.jboss.Main.boot(Main.java:209)
| at org.jboss.Main$1.run(Main.java:544)
| at java.lang.Thread.run(Thread.java:595)
| Caused by: javax.naming.NameAlreadyBoundException
| at org.jnp.server.NamingServer.bind(NamingServer.java:165)
| at org.jnp.server.NamingServer.bind(NamingServer.java:130)
| at org.jnp.server.NamingServer.bind(NamingServer.java:130)
| at org.jnp.interfaces.NamingContext.bind(NamingContext.java:593)
| at org.jnp.interfaces.NamingContext.bind(NamingContext.java:554)
| at org.jboss.util.naming.Util.bind(Util.java:105)
| at org.jboss.util.naming.Util.bind(Util.java:91)
| at
org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase.bind(JndiSessionRegistrarBase.java:689)
| ... 55 more
|
|
Am i doing the right thing by having multiple beans with the same name? If yes, then it
looks like when creating the jndi names for the interface specific proxies, we might even
have to include the jar name in the jndi name to avoid this exception.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4179545#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...