0 Replies Latest reply on Jan 4, 2012 1:04 PM by Mandar Kulkarni

    How to resolve circular dependency

    Mandar Kulkarni Newbie

      I have 2 EARs deployed in the server : library.ear and application.ear.Later(application.ear) already have dependencies from former(library.ear).

       

      Scenario:

      The library.ear performs some action and publishes an event that is processed by a MessageListenerBean class in application.ear.The MessageListenerBean in turn publishes events using libray's EventPublisher that are processed by MessageListenerBean2.

       

      Trying to summarize the workflow with the stacktrace,

       

      at com.library.Action(Action.java:59)
      at com.library.EventPublisher.publish(EventPublisher.java:132)
      at com.application.ear.MessageListenerBean.onMessage
      at com.library.EventPublisher.publish(EventPublisher.java:132)
      at com.application.ear.MessageListenerBean2.onMessage

       

      The MessageListenerBean2 refers to many classes from application.ear/lib.Following Exception is thrown by JBoss,

       

      com.emc.application.AssignationEvent from [Module "org.hornetq:main" from local module loader @5464ea66 (roots: C:\JBoss7Migration\jboss-as-7.1.0.CR1b\modules)]

      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Unknown Source)

       

      Please note that all these MessageListeners are synchronous listeners and not MDBs.

       

      How exactly the classloading works ?

       

      A.jar --> B.jar --> C.jar.

      Assume that each of these jars contain jboss-deployment-structure.xml

      1) Class CA1 in A.jar invokes a method of an Object(CB1) in B.jar

      2) Now, when CB1 invokes a method of an object in C.jar, which module dependecies(which deployment XML) will be considered during method invocation ?