3 Replies Latest reply on Nov 19, 2010 6:32 AM by Robson Ximenes

    Duplicate Interceptor, class hierarch in several jars

    Robson Ximenes Newbie

      Weld is raising an exception: Duplicate interceptor class definition...


      I have only 3 Jars... each on has its own beans.xml empty, except one tha has the interceptor registered;


      core.jar
      persistence.jar
      view.jar


      The only thing i note is that have an class in core and then an subclass of it in persistence.jar;


      In core:



      @PersistenceController // It is annotated with @Controller
      MyClass{}



      In persistence



      MySubClass extends MyClass{}




      The interceptor intercepts @Controller... what could be wrong????

        • 1. Re: Duplicate Interceptor, class hierarch in several jars
          Alexander Bell Newbie

          how looks your beans.xml regarding interceptor declaration?

          • 2. Re: Duplicate Interceptor, class hierarch in several jars
            Robson Ximenes Newbie

            This is my core beans.xml where i defined the interceptor and where is located the @Controller class...




            <?xml version="1.0"?>
            <beans 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://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
            
                 <interceptors>
                      <class>my.package.TransactionInterceptor</class>
                 </interceptors>
            
            </beans>



            And here comes the same beans.xml that are in the others jars and webapp;




            <?xml version="1.0"?>
            <beans 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://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
            
            </beans> 



            The problem i believe is that i have an class in the webapp project that extends one from my jars, so the interceptors get confused...

            • 3. Re: Duplicate Interceptor, class hierarch in several jars
              Robson Ximenes Newbie

              Correcting: the beans.xml from core is like this:



              <?xml version="1.0"?>
              <beans 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://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
              
                   <interceptors>
                        <class>my.package.ExceptionHandlerInterceptor</class>
                   </interceptors>
              
              </beans>




              This is the interceptor:



              @Interceptor
              @Controller
              public class ExceptionHandlerInterceptor implements Serializable{
              
                   @AroundInvoke
                   public Object manage(final InvocationContext ctx) throws Exception {
                        ....
                   }
              
              }




              And this is the @Controller:



              @InterceptorBinding
              @Inherited
              @Target({ TYPE, METHOD })
              @Retention(RUNTIME)
              public @interface Controller {
              }