2 Replies Latest reply on May 29, 2009 5:19 AM by ws ws

    Jboss 5 - InstanceAlreadyExistsException - already registere

    ws ws Newbie

      I am using JBoss 5.1.0 and EJB 3.0. Before I used JBoss 4.2.2 where the following error did not happen.

      I am using a base.jar which contains reusable code (Stateless and Entity Beans). So I include the base.jar in some other application-jar-archives:

      The base-app.jar and the base-session-app.jar include the base.jar and have both the following structure, the deployment descriptors however are different:
      /META-INF
      /META-INF/ejb-jar.xml
      /META-INF/orm.xml
      /META-INF/persistence.xml
      /base.jar

      First I deploy the base-app.jar. When I then deploy the base-session-app.jar, I get the following deployment error:

      ERROR [EJBModule] Could not create JSR-77 EJBModule: base.jar
      javax.management.InstanceAlreadyExistsException: jboss.management.local:j2eeType=EJBModule,J2EEServer=Local,J2EEApplication=null,name=base.jar already registered.
      


      However after this error I can access the stateless session beans of both deployments, of base-app.jar and of base-session-app.jar.

      I deploy only statless session beans and entity beans. I have no @Stateless, no @Remote and no @Entity annotations in the source code, I am using the deployment descriptors so that I can load exaclty those EJBs what I want.

      The ejb-jar.xml in base-app.jar/META-INF is:
      <?xml version="1.0" encoding="UTF-8"?>
      <ejb-jar
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
      version="3.0">
      <enterprise-beans>
      <session>
       <ejb-name>UserEntityHandler</ejb-name>
       <business-remote>pte.base.users.user.IUserEntityHandlerRemote</business-emote>
       <ejb-class>pte.base.baseasc.users.user.UserEntityHandler</ejb-class>
       <session-type>Stateless</session-type>
      </session>
      ...
      </enterprise-beans>
      


      The ejb-jar.xml in base-session-app.jar/META-INF/ is:
      <ejb-jar
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
      version="3.0">
      <enterprise-beans>
      <session>
       <ejb-name>WebSessionClientHandler</ejb-name>
       <business-remote>pte.base.sessions.IWebSessionClientHandlerRemote</business-remote>
       <ejb-class>pte.base.baseasc.sessions.WebSessionClientHandler</ejb-class>
       <session-type>Stateless</session-type>
      </session>
      </enterprise-beans>
      


      I have found some similar problems in this forum with the comment that in JBoss 5 this should be solved. Sorry if this issue has often been discussed before, but I did not found an answer concerning JBoss5.

      Does anyone have an idea why this error happens?
      Is this really an error (as I said, I can access the beans of both deployments)?

        • 1. Re: Jboss 5 - InstanceAlreadyExistsException - already regis
          jaikiran pai Master

           

          The base-app.jar and the base-session-app.jar include the base.jar


          You have a jar within another jar?

          • 2. Re: Jboss 5 - InstanceAlreadyExistsException - already regis
            ws ws Newbie

            Yes. The base.jar has reusable code. That's why I use the base.jar in many different other application-jars (e.g. base-app.jar and base-session-app.jar).

            I also develop the base.jar, so the base.jar is very often overworked. That's why I do not put the base.jar in the lib directory of the JBoss server (because as far as I know I have to restart the server when a jar in the lib directory is changed). That's why I put the base.jar into the other application-jars (e.g. base-app.jar, base-session-app.jar) so that I can deploy changes in base.jar by deploying the application-jar without restarting the server.

            At JBoss 4 this worked fine. However in JBoss 5 I get the described error.