0 Replies Latest reply on Apr 1, 2002 2:41 PM by R. Wang

    How to deploy multiple Session Beans referencing to one Enti

    R. Wang Newbie

      Hi,

      I am having difficulty to deploy one single JAR file that contains
      two Session beans and one Entity bean. Both of the Session Beans
      reference the entity bean by the JNDI name ejb/EntityA.
      ejb-jar.xml and jboss.xml are as following:
      ---------------ejb-jar.xml------------------------------
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
      <ejb-jar>
      <enterprise-beans>

      <ejb-name>EntityA</ejb-name>
      EntityAHome
      EntityARemote
      <ejb-class>EntityABean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>EntityAPK</prim-key-class>
      False
      <cmp-version>1.x</cmp-version>
      <cmp-field>
      <field-name>field_1</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>field_2</field-name>
      </cmp-field>


      <ejb-name>SessionA</ejb-name>
      SessionAHome
      SessionARemote
      <ejb-class>SessionABean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <ejb-ref>
      <ejb-ref-name>ejb/EntityA</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      EntityAHome
      EntityARemoe
      <ejb-link>EntityA</ejb-link>
      </ejb-ref>


      <ejb-name>SessionB</ejb-name>
      SessionBHome
      SessionBRemote
      <ejb-class>SessionBBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <ejb-ref>
      <ejb-ref-name>ejb/EntityA</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      EntityAHome
      EntityARemote
      <ejb-link>EntityA</ejb-link>
      </ejb-ref>

      </enterprise-beans>
      </ejb-jar>
      -------------------jboss.xml-----------------------
      <?xml version="1.0"?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss_2_4.dtd">

      <enforce-ejb-restrictions>true</enforce-ejb-restrictions>
      <enterprise-beans>

      <ejb-name>EntityA</ejb-name>
      <jndi-name>ejb/EntityA</jndi-name>
      <configuration-name>Standard CMP EntityBean</configuration-name>


      <ejb-name>SessionA</ejb-name>
      <jndi-name>ejb/SessionA</jndi-name>
      <configuration-name>Standard Stateless SessionBean</configuration-name>


      <ejb-name>SessionB</ejb-name>
      <jndi-name>ejb/SessionBr</jndi-name>
      <configuration-name>Standard Stateless SessionBean</configuration-name>

      </enterprise-beans>

      ----------------end of config xml-------------------

      Once I started JBoss 2.4.4, it first deployed EntityA, then, SessionA being deployed, but
      it throws following exception when deploying SessionB.
      [10:28:26,413,StatelessSessionContainer] Could not set up environment
      javax.naming.NameAlreadyBoundException
      at org.jnp.server.NamingServer.bind(NamingServer.java:130)
      at org.jnp.server.NamingServer.bind(NamingServer.java:95)
      at org.jnp.server.NamingServer.bind(NamingServer.java:95)
      at org.jnp.interfaces.NamingContext.bind(NamingContext.java:314)
      at org.jnp.interfaces.NamingContext.bind(NamingContext.java:286)
      at org.jboss.ejb.Container.bind(Container.java:689)
      at org.jboss.ejb.Container.setupEnvironment(Container.java:543)
      at org.jboss.ejb.Container.init(Container.java:359)
      at org.jboss.ejb.StatelessSessionContainer.init(StatelessSessionContainer.java:152)
      at org.jboss.ejb.Application.init(Application.java:202)
      at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:372)
      at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:306)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:487)
      at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:459)
      at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:190)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.deployment.AutoDeployer.deploy(AutoDeployer.java:395)
      at org.jboss.deployment.AutoDeployer.run(AutoDeployer.java:233)
      at org.jboss.deployment.AutoDeployer.startService(AutoDeployer.java:371)
      at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:103)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(ConfigurationService.java:967)
      at $Proxy0.start(Unknown Source)
      at org.jboss.util.ServiceControl.start(ServiceControl.java:79)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.Main.(Main.java:208)
      at org.jboss.Main$1.run(Main.java:110)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.jboss.Main.main(Main.java:106)
      [10:28:26,418,ContainerFactory] DeploymentError
      org.jboss.deployment.DeploymentException: Could not set up environment, Cause: javax.naming.NameAlreadyBoundException
      at org.jboss.ejb.Container.setupEnvironment(Container.java:653)
      at org.jboss.ejb.Container.init(Container.java:359)
      at org.jboss.ejb.StatelessSessionContainer.init(StatelessSessionContainer.java:152)
      at org.jboss.ejb.Application.init(Application.java:202)
      at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:372)
      at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:306)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:487)
      at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:459)
      at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:190)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.deployment.AutoDeployer.deploy(AutoDeployer.java:395)
      at org.jboss.deployment.AutoDeployer.run(AutoDeployer.java:233)
      at org.jboss.deployment.AutoDeployer.startService(AutoDeployer.java:371)
      at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:103)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(ConfigurationService.java:967)
      at $Proxy0.start(Unknown Source)
      at org.jboss.util.ServiceControl.start(ServiceControl.java:79)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.Main.(Main.java:208)
      at org.jboss.Main$1.run(Main.java:110)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.jboss.Main.main(Main.java:106)