2 Replies Latest reply on Apr 24, 2008 3:13 AM by jaikiran

    How to intercept EJBs residing in another jar-file?

    raoul.schmidiger

      Hi all

      I have got an ear-file with the following structure:

      - myapp.ear
      ----- app1.jar
      ----- mylib.jar

      Both jar-files contain a bunch of EJBs. However, the EJBs in app1.jar use some EJBs residing in mylib.jar. They get injected where needed with the @EJB annotation.
      In order to have all EJBs in the two jar-files deployed the two jar files are defined as modules in the application.xml file, residing in the META-INF folder of the ear-file.

      So far so good. The issue that I have got now is that I would like to intercept any method call to any of the EJBs within my project. The interception should be performed by a class which is in the app1.jar file. For this purpose I added the following definition in the ejb-jar.xml file of the app1.jar file:

      <assembly-descriptor>
       <interceptor-binding>
       <ejb-name>*</ejb-name>
       <interceptor-class>
       com.myApp.GlobalInterceptor
       </interceptor-class>
       </interceptor-binding>
       </assembly-descriptor>


      This works fine for all EJBs that are in the same jar like the ejb-jar.xml file (app1.jar). However, any method call to an EJB in mylib.jar is not intercepted at all.
      What do I have to change in order the have also the method calls with the EJBs in the mylib.jar file intercepted? An extensive search on google and in the jBoss forum did not reveal any solution for my problem. Either nobody has ever tried to do this, or I am just missing something!

      Any help is highly appreciated!

      Thank you very much!



        • 1. Re: How to intercept EJBs residing in another jar-file?
          jaikiran

          I haven't tried using the interceptors with ejb-jar.xml files. I have tried them with annotations. Why don't you use annotations for this? Something like:

          Bean1 in app1.jar containing this:

          @Stateless
          @Interceptors (GlobalInterceptor.class)
          public class Bean1 implements MyBean1 {
          


          And a similar one in

          Bean2 in mylib.jar

          @Stateless
          @Interceptors (GlobalInterceptor.class)
          public class Bean2 implements MyBean2 {




          • 2. Re: How to intercept EJBs residing in another jar-file?
            jaikiran

             

            "raoul.schmidiger" wrote:

            This works fine for all EJBs that are in the same jar like the ejb-jar.xml file (app1.jar). However, any method call to an EJB in mylib.jar is not intercepted at all.
            What do I have to change in order the have also the method calls with the EJBs in the mylib.jar file intercepted? An extensive search on google and in the jBoss forum did not reveal any solution for my problem. Either nobody has ever tried to do this, or I am just missing something!


            An ejb-jar.xml represents on single ejb deployment unit. So, in your case, you will have to create another ejb-jar.xml file with similar contents for mylib.jar.