4 Replies Latest reply on Dec 6, 2006 8:57 AM by nico67

    Cyclic depencies

    nico67

      Hi,

      I've got several Stateless beans which have cyclic dependencies between them. When deploying my .jar I get several errors saying me that kind of thing :

      ObjectName: jboss.j2ee:jar=escapek.jar,name=TestServiceBean,service=EJB3
       State: NOTYETINSTALLED
       I Depend On:
       jboss.j2ee:jar=escapek.jar,name=RegistryServiceBean,service=EJB3
      


      I've read that using @IgnoreDependency or specifying it in jboss.xml should fix the problem.
      As i would like my code to be independent as possible I choose to add a jboss.xml in META-INF/ of my .jar:

      <jboss>
       <enterprise-beans>
       <session>
       <ejb-name>TestServiceBean</ejb-name>
       <ejb-ref>
       <ejb-ref-name>RegistryServiceBean</ejb-ref-name>
       <ignore-dependency/>
       </ejb-ref>
       </session>
       <session>
       <ejb-name>CmdbServiceBean</ejb-name>
       <ejb-ref>
       <ejb-ref-name>RepositoryServiceBean</ejb-ref-name>
       <ignore-dependency/>
       </ejb-ref>
       <ejb-ref>
       <ejb-ref-name>SecurityServiceBean</ejb-ref-name>
       <ignore-dependency/>
       </ejb-ref>
       </session>
       <session>
       <ejb-name>RegistryServiceBean</ejb-name>
       <ejb-ref>
       <ejb-ref-name>RepositoryServiceBean</ejb-ref-name>
       <ignore-dependency/>
       </ejb-ref>
       <ejb-ref>
       <ejb-ref-name>SecurityServiceBean</ejb-ref-name>
       <ignore-dependency/>
       </ejb-ref>
       </session>
       </enterprise-beans>
      </jboss>
      


      This doesn't work. For example, TestServiceBean is not deployed even by having specified ignore-dependency in jboss.xml.

      I'm using EJB3-RC9 on Jboss 4.0.5.

        • 1. Re: Cyclic depencies
          nico67

          Hi,

          Sorry for this topic title, I mean "Cyclic dependencies" ...

          So I still can't make the dependecy ignored by using jboss.xml. So i wanted to try by specifying @IgnoreDependency in the source code. The problem is that i can't find the library which defines this annotation. I can't see it in EJB3-RC9 package not in the client/ directory of my jboss installation where EJB3 was installed.

          Also, i don't know if its related, but I've seen JIRA http://jira.jboss.com/jira/browse/EJBTHREE-792 , which sounds a bit like the same problem I have.

          Please, let me know if you have any ideas.

          • 2. Re: Cyclic depencies
            kgrjb


            to compile @IgnoreDependency - you need
            jboss-4.0.5.GA\client\jboss-annotations-ejb3.jar in your compile classpath.

            • 3. Re: Cyclic depencies
              nico67

               


              to compile @IgnoreDependency - you need
              jboss-4.0.5.GA\client\jboss-annotations-ejb3.jar in your compile classpath.

              I found jboss-annotations-ejb3.jar in ejb3.deployer directory which is in the deploy directory of my server, not the client/ directory as you specified.
              Note that to install EJB3 , I installed JBoss 4.0.5 , copied the default server configuration, then run the EJB3 ant script (install.xml) to install EJB3 stuffs in my server configuration.

              Current conclusion is that:
              - <ignore-dependency /> put in jboss.xml is ignored : i mean event if i specify it, the bean are not deployed;
              - @IgnoreDependency works fine. When specified, the bean is started even if dependencies are not.

              So, there may be a problem with my jboss.xml file and ignore-dependency. Has someone got it running ?

              I copy below my jboss.xml file content.

              <?xml version="1.0" encoding="UTF-8"?>
              <jboss
               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://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
               version="3.0">
               <enterprise-beans>
               <session>
               <ejb-name>CmdbServiceBean</ejb-name>
               <ejb-ref>
               <ejb-ref-name>RepositoryServiceBean</ejb-ref-name>
               <ignore-dependency/>
               </ejb-ref>
               <ejb-ref>
               <ejb-ref-name>SecurityServiceBean</ejb-ref-name>
               <ignore-dependency/>
               </ejb-ref>
               </session>
               <session>
               <ejb-name>RegistryServiceBean</ejb-name>
               <ejb-ref>
               <ejb-ref-name>RepositoryServiceBean</ejb-ref-name>
               <ignore-dependency/>
               </ejb-ref>
               <ejb-ref>
               <ejb-ref-name>SecurityServiceBean</ejb-ref-name>
               <ignore-dependency/>
               </ejb-ref>
               </session>
               <session>
               <ejb-name>TestServiceBean</ejb-name>
               <ejb-ref>
               <ejb-ref-name>RegistryServiceBean</ejb-ref-name>
               <ignore-dependency/>
               </ejb-ref>
               </session>
               </enterprise-beans>
              </jboss>
              


              • 4. Re: Cyclic depencies
                nico67

                Hi,

                I finally found out a syntax for jboss.xml to Ingnore dependency injection.

                The jboss.xml file from my previous posts now look like :

                <?xml version="1.0" encoding="UTF-8"?>
                <jboss 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://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
                 version="3.0">
                 <enterprise-beans>
                 <session>
                 <ejb-name>RegistryServiceBean</ejb-name>
                 <ignore-dependency>
                 <injection-target>
                 <injection-target-class>org.escapek.core.services.impl.RepositoryServiceBean</injection-target-class>
                 <injection-target-name>repository</injection-target-name>
                 </injection-target>
                 </ignore-dependency>
                 </session>
                 <session>
                 <ejb-name>SecurityServiceBean</ejb-name>
                 <ignore-dependency>
                 <injection-target>
                 <injection-target-class>org.escapek.core.services.impl.RegistryServiceBean</injection-target-class>
                 <injection-target-name>registryService</injection-target-name>
                 </injection-target>
                 </ignore-dependency>
                 </session>
                 <session>
                 <ejb-name>TestServiceBean</ejb-name>
                 <ignore-dependency>
                 <injection-target>
                 <injection-target-class>org.escapek.core.services.impl.RegistryServiceBean</injection-target-class>
                 <injection-target-name>registry</injection-target-name>
                 </injection-target>
                 </ignore-dependency>
                 </session>
                 </enterprise-beans>
                </jboss>
                


                For each bean, the ignore-dependency tag tell which class and which field name to ignore in the bean.

                Using this setup I managed to start my beans.

                Can someone from the dev. could tell me if there's another syntax as i saw it of others posts.