3 Replies Latest reply on Sep 7, 2009 5:51 AM by dode

    Cannot use @Depends in EJB depending on another EAR deployme

    dode

      We have an @Service EJB3 deployed as EAR that does not only depend on a service, but also on classes provided by another EAR deployment.

      We have declared the dependency using @Depends, but it seems that the annotation cannot take effect because already loading of the EJB class fails, since it uses classes provided by the other EAR which isn't deployed yet - a NoClassDefFoundError is thrown.

      The only solution we have found so far is having the EJB EAR deployed after the other EAR by renaming it to something like "xxx...".

      Is there another way to declare a dependency of an EJB3 to an EAR deployment than the @Depends annotation, i.e. by using some deployment descriptor like jboss.xml?
      We actually tried the latter but failed on the fact that in EJB 2.1 there is nothing like a "service" enterprise bean.

      We also tried to make the EJB an (X)MBean which has a dependency to the EAR deployment but that does not seem to affect the EJB - it is still deployed before the EAR it depends on.

      Any ideas?

      Cheers,
      Torsten

        • 1. Re: Cannot use @Depends in EJB depending on another EAR depl
          jaikiran

           

          We have an @Service EJB3 deployed as EAR that does not only depend on a service, but also on classes provided by another EAR deployment.


          There's no direct way of specifying a @Depends on a class. Are you adding a @Depends on the EAR "deployment"? Please post the @Depends you are using. I am not sure adding a @Depends on the EAR "deployment" is going to work because of the way deployers work in AS-5.

          • 2. Re: Cannot use @Depends in EJB depending on another EAR depl
            jaikiran

             

            "jaikiran" wrote:
            because of the way deployers work in AS-5.


            I forgot to ask this - Which version of JBoss AS are you using? :)

            • 3. Re: Cannot use @Depends in EJB depending on another EAR depl
              dode

              Thanks for your response.

              I forgot to mention that we are using JBoss 4.2.

              We were assuming that if we make a dependency of the service to the other EAR deployment, JBoss would even wait loading the classes of that service until the EAR it depends on is deployed.
              But it seems the classes are loaded as soon as the deployer sees the deployment and dependencies are handled after that.

              Regarding the XML deployment descriptor, we eventually saw that it actually is possible to replace @Depends of an @Service bean with a

              <depends> inside a <service>
              in jboss.xml, but it behaves exactly like the @Depends so we concluded the above: Classloading cannot be controlled with dependencies on services.

              It seems however that there are solutions for our problem is JBoss 5 with custom metadata files, but upgrading is not an option right now.

              We have solved the issue now by moving the deployment the service depends on to a separate EAR which is, due to its name, "classloaded" and deployed before the service.
              We actually use a @Depends on the EAR deployment, which works fine:
              @Depends(value="jboss.j2ee:service=EARDeployment,url='beans.ear'")

              I'm a bit surprised that this works because I read somewhere that EAR deployments cannot be used as dependencies since they are not services - but the JMX name clearly suggests that and it works.

              Cheers,
              Torsten