0 Replies Latest reply on Aug 13, 2002 7:07 PM by Jeffrey Goetsch

    Local Reference - Bug?

    Jeffrey Goetsch Newbie

      We are wanting to release the same EJB jar with a different name and configuration onto the same JBoss instance. The reason we want to do this is because we are writing an application that will be released on the same server, but have different configuration and data source for each customer. The code base will remain identical between the jars.

      Killing the Dragon
      We started by creating a complex hello world application using two EJBs: Front and Back. Front has two hello world methods. The first, helloFront(), gets an environment varible out of "java:comp/env/Hello", and returns it. The second method, helloBack(), references Back, which has a method, hello(), which gets an environment varible out of "java:comp/env/Hello".

      We created a jar called Test1 which had the descriptors listed at the end of this doc. The test went great. We then created a second jar called Test2 with the jndi names changed to test2 and add 2 to the end of the hello statements.

      We got this error:
      15:56:15,972 ERROR [EjbModule] Initialization failed

      javax.management.InstanceAlreadyExistsException: jboss.j2ee:service=EJB,jndiName=Back already registered.


      which was repeated three times with stack traces which I did not include for readability.

      Are we not doing this correctly? Or is this a bug?

      Thanks,
      Jeffrey Goetsch

      P.S. We will send code to anyone who wants a copy.

      Descriptors
      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>

      <display-name>Front</display-name>
      <ejb-name>Front</ejb-name>
      dragon.FrontHome
      dragon.Front
      <ejb-class>dragon.FrontBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <env-entry>

      <env-entry-name>Hello</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>Hello From the Front End</env-entry-value>
      </env-entry>
      <ejb-local-ref>

      <ejb-ref-name>ejb/Back</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      <local-home>dragon.BackLocalHome</local-home>
      dragon.BackLocal
      <ejb-link>Back</ejb-link>
      </ejb-local-ref>


      <display-name>Back</display-name>
      <ejb-name>Back</ejb-name>
      <local-home>dragon.BackLocalHome</local-home>
      dragon.BackLocal
      <ejb-class>dragon.BackBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <env-entry>

      <env-entry-name>Hello</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>Hello World from the Backend</env-entry-value>
      </env-entry>

      </enterprise-beans>
      <assembly-descriptor>
      <container-transaction>

      <ejb-name>Front</ejb-name>
      <method-name>*</method-name>


      <ejb-name>Back</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>


      jboss.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss PUBLIC '-//JBoss//DTD JBOSS 3.0//EN' 'http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd'>

      <enterprise-beans>

      <ejb-name>Front</ejb-name>
      <jndi-name>test1/Front</jndi-name>
      <ejb-local-ref>
      <ejb-ref-name>ejb/Back</ejb-ref-name>
      <local-jndi-name>test1/Back</local-jndi-name>
      </ejb-local-ref>


      <ejb-name>Back</ejb-name>
      <local-jndi-name>test1/Back</local-jndi-name>

      </enterprise-beans>