3 Replies Latest reply on Aug 22, 2005 6:06 AM by dorr

    Two applications having classes with the same name but total

    dorr

      hi
      i've got problem - two applications are standing on one jboss installation, lets say A and B. unfortunatelly both has EJB called User with local interface UserLocal. this classes are totally different.

      when deploying: if A starts first, then B, when session bean from A and B calls for UserLocal referenced bean, gets bean from B. when B starts first and then A, both applications gets User bean from A.

      problem occurs when using local reference UserLocal in session bean:
      UserLocalHome ulh = (UserLocalHome)context.lookup("java:comp/env/UserLocal");
      and application gets class cast exception

      how to resolve this problem? maybe attached code is wrong?

        • 1. Re: Two applications having classes with the same name but t
          jaikiran

          You will have to use <loader-repository> in each of your .ear files. Doing this will enable specifying different classloaders for each ear. Have a look at the following link:

          http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration

          • 2. Re: Two applications having classes with the same name but t
            jaikiran

            An example would be:

            In jboss-app.xml of your proj1.ear you would have the following:

            <jboss-app>
             <loader-repository>
             tap:loader=proj1.ear
             <loader-repository-config>
             java2ParentDelegation=false
             </loader-repository-config>
             </loader-repository>
            </jboss-app>


            In jboss-app.xml of proj2.ear, you would have:

            <jboss-app>
             <loader-repository>
             tap:loader=proj2.ear
             <loader-repository-config>
             java2ParentDelegation=false
             </loader-repository-config>
             </loader-repository>
            </jboss-app>





            • 3. Re: Two applications having classes with the same name but t
              dorr

              thank you for advice. i followed your suggestions but it didn't helped :(
              i created jboss-app.xml for both applications (and put them to bin/ejb/META-INF of projects). i also created jboss-web.xml files as is shown in http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration.
              i tried using Isolation and Isolation with Overriding and still i gets class cast exception when using the application deployed earlier :(
              i tried to create jboss.xml but i have problem. in ejb-jar.xml i have session bean UserManagement declared with ejb-ref as follows:
              <ejb-local-ref>
              <ejb-ref-name>UserLocal</ejb-ref-name>
              <ejb-ref-type>Entity</ejb-ref-type>
              ....
              and when i in jboss.xml define:

              <ejb-name>UserManagement</ejb-name>
              <ejb-ref>
              <ejb-ref-name>UserLocal</ejb-ref-name>
              <jndi-name>jnp://localhost:1099/User</jndi-name>
              </ejb-ref>
              i gets from jboss the following error:
              org.jboss.deployment.DeploymentException: Error in jboss.xml for Bean UserManagement: ejb-ref User found in jboss.xml but not in ejb-jar.xml
              what i am doing wrong?