glassfish
  1. glassfish
  2. GLASSFISH-19262

Deployment failure: Duplicate interceptor class definition when binding <interceptor-class-name> on AROUND_INVOKE

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.2
    • Fix Version/s: 4.0
    • Component/s: cdi
    • Labels:
      None
    • Environment:

      GlassFish Server Open Source Edition 3.1.2.2 (build 5)
      org.jboss.weld.Version=WELD-000900 1.1.8 (Final)

      Description

      Following bean forces a deployment error in glassfish, if the ejb module containing this bean uses cdi (and therefore has a META-INF/beans.xml)

      @Stateless
      @Interceptors(

      {Interceptor1.class, Interceptor2.class}

      )
      public class MyStatelessSessionBean {

      public void doSomething1() {
      }

      public void doSomething2() {
      }

      @ExcludeClassInterceptors
      @Interceptors(

      {Interceptor1.class}

      )
      public void doSomething3() {

      }
      }

      The server.log shows following errors:

      [#|2012-10-30T16:43:31.128+0100|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=121;_ThreadName=Thread-2;|Exception while loading the app|#]

      [#|2012-10-30T16:43:31.133+0100|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=121;_ThreadName=Thread-2;|Exception while loading the app : Duplicate interceptor class definition when binding com.tests.interceptors.Interceptor1 on AROUND_INVOKE
      org.jboss.weld.interceptor.proxy.InterceptorException: Duplicate interceptor class definition when binding com.tests.interceptors.Interceptor1 on AROUND_INVOKE

      If the the ejb-module has no beans.xml, the deployment is successful.

      The attachment contains a maven project for reproducing the error.

        Activity

        Hide
        tlcksnyder added a comment -

        Still fails with Weld Beta7:

        Exception while loading the app : CDI deployment failure:Duplicate interceptor class definition when binding com.tests.interceptors.Interceptor1 on AROUND_INVOKE
        org.jboss.weld.interceptor.proxy.InterceptorException: Duplicate interceptor class definition when binding com.tests.interceptors.Interceptor1 on AROUND_INVOKE
        at org.jboss.weld.interceptor.builder.InterceptionModelImpl.validateDuplicateInterceptors(InterceptionModelImpl.java:136)
        at org.jboss.weld.interceptor.builder.InterceptionModelImpl.appendInterceptors(InterceptionModelImpl.java:120)
        at org.jboss.weld.interceptor.builder.InterceptionModelBuilder$MethodInterceptorDescriptor.with(InterceptionModelBuilder.java:114)
        at org.jboss.weld.injection.producer.InterceptionModelInitializer.initMethodDeclaredEjbInterceptors(InterceptionModelInitializer.java:285)
        at org.jboss.weld.injection.producer.InterceptionModelInitializer.initEjbInterceptors(InterceptionModelInitializer.java:233)
        at org.jboss.weld.injection.producer.InterceptionModelInitializer.init(InterceptionModelInitializer.java:113)
        at org.jboss.weld.injection.producer.BeanInjectionTarget.initializeInterceptionModel(BeanInjectionTarget.java:91)
        at org.jboss.weld.injection.producer.ejb.SessionBeanInjectionTarget.initializeAfterBeanDiscovery(SessionBeanInjectionTarget.java:81)
        at org.jboss.weld.injection.producer.InjectionTargetInitializationContext.initialize(InjectionTargetInitializationContext.java:42)
        at org.jboss.weld.injection.producer.InjectionTargetService.initialize(InjectionTargetService.java:57)
        at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:529)
        at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:204)
        at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
        at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:537)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
        at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:164)
        at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:595)
        at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:482)
        at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:410)
        at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:401)
        at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:233)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)

        Show
        tlcksnyder added a comment - Still fails with Weld Beta7: Exception while loading the app : CDI deployment failure:Duplicate interceptor class definition when binding com.tests.interceptors.Interceptor1 on AROUND_INVOKE org.jboss.weld.interceptor.proxy.InterceptorException: Duplicate interceptor class definition when binding com.tests.interceptors.Interceptor1 on AROUND_INVOKE at org.jboss.weld.interceptor.builder.InterceptionModelImpl.validateDuplicateInterceptors(InterceptionModelImpl.java:136) at org.jboss.weld.interceptor.builder.InterceptionModelImpl.appendInterceptors(InterceptionModelImpl.java:120) at org.jboss.weld.interceptor.builder.InterceptionModelBuilder$MethodInterceptorDescriptor.with(InterceptionModelBuilder.java:114) at org.jboss.weld.injection.producer.InterceptionModelInitializer.initMethodDeclaredEjbInterceptors(InterceptionModelInitializer.java:285) at org.jboss.weld.injection.producer.InterceptionModelInitializer.initEjbInterceptors(InterceptionModelInitializer.java:233) at org.jboss.weld.injection.producer.InterceptionModelInitializer.init(InterceptionModelInitializer.java:113) at org.jboss.weld.injection.producer.BeanInjectionTarget.initializeInterceptionModel(BeanInjectionTarget.java:91) at org.jboss.weld.injection.producer.ejb.SessionBeanInjectionTarget.initializeAfterBeanDiscovery(SessionBeanInjectionTarget.java:81) at org.jboss.weld.injection.producer.InjectionTargetInitializationContext.initialize(InjectionTargetInitializationContext.java:42) at org.jboss.weld.injection.producer.InjectionTargetService.initialize(InjectionTargetService.java:57) at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:529) at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:204) at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131) at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:328) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:493) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219) at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:537) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423) at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762) at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:164) at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:595) at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:482) at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:410) at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:401) at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:233) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505)
        Show
        jjsnyder83 added a comment - https://issues.jboss.org/browse/WELD-1400
        Hide
        Jeremy_Lv added a comment - - edited

        I have looked into the code and found the current weld side code has don't allow define both of the @Interceptors(

        {Interceptor1.class}) define in class and the method contained in the class.
        MyStatelessSessionBean.java
        @Stateless
        @Interceptors({Interceptor1.class, Interceptor2.class})
        public class StatelessSessionBean {
        
          public void doSomething1() {
          }
          
          public void doSomething2() {
          }
          
          public void doSomething3() {
          }
          
          @ExcludeClassInterceptors
          @Interceptors(Interceptor1.class)
          public void doSomethingN() {
            
          }
        }
        
        Interceptor1.java
        public class Interceptor1 {
          @AroundInvoke
          public Object intercept(InvocationContext ctx) throws Exception {
            return ctx.proceed();
          }  
        }
        


        From the code in the glassfish weld side, If we have already define the MyStatelessSessionBean as @Interceptors({Interceptor1.class}

        ), the duplicate error exception will comes out if we define the @Interceptors(

        {Interceptor1.class}

        ) at the method contained in MyStatelessSessionBean.

        I'd like to continue to look into this issue if it is the right scenario that tweier has reported.

        BTW: the reason why the application can be deployed without a bean.xml because the application will not a weld application without a bean.xml and the weld side will not load the application to do some validation.

        Thanks

        Jeremy

        Show
        Jeremy_Lv added a comment - - edited I have looked into the code and found the current weld side code has don't allow define both of the @Interceptors( {Interceptor1.class}) define in class and the method contained in the class. MyStatelessSessionBean.java @Stateless @Interceptors({Interceptor1.class, Interceptor2.class}) public class StatelessSessionBean { public void doSomething1() { } public void doSomething2() { } public void doSomething3() { } @ExcludeClassInterceptors @Interceptors(Interceptor1.class) public void doSomethingN() { } } Interceptor1.java public class Interceptor1 {   @AroundInvoke   public Object intercept(InvocationContext ctx) throws Exception {     return ctx.proceed();   }   } From the code in the glassfish weld side, If we have already define the MyStatelessSessionBean as @Interceptors({Interceptor1.class} ), the duplicate error exception will comes out if we define the @Interceptors( {Interceptor1.class} ) at the method contained in MyStatelessSessionBean. I'd like to continue to look into this issue if it is the right scenario that tweier has reported. BTW: the reason why the application can be deployed without a bean.xml because the application will not a weld application without a bean.xml and the weld side will not load the application to do some validation. Thanks Jeremy
        Hide
        marina vatkina added a comment -

        Note @ExcludeClassInterceptors - it should remove the class-level binding

        Show
        marina vatkina added a comment - Note @ExcludeClassInterceptors - it should remove the class-level binding
        Hide
        Jeremy_Lv added a comment - - edited

        It seems the issue has been resovled in the version of 2.0.0.CR2.
        https://issues.jboss.org/browse/WELD-1400

        I think the issue will be resoved when the weld side in glassfish get upgrade to the <weld.version>2.0.0.CR2</weld.version>

        Show
        Jeremy_Lv added a comment - - edited It seems the issue has been resovled in the version of 2.0.0.CR2. https://issues.jboss.org/browse/WELD-1400 I think the issue will be resoved when the weld side in glassfish get upgrade to the <weld.version>2.0.0.CR2</weld.version>
        Hide
        arjavdesai added a comment -

        I just tried with latest GFS build with revisions upto 61409 which includes WELD CR2 and app is getting deployed fine as seen in server logs

        [2013-04-13T07:37:05.144-0400] [glassfish 4.0] [INFO] [] [org.jboss.weld.Version] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853025144] [levelValue: 800] [[
        WELD-000900 2.0.0 (CR2)]]

        [2013-04-13T07:37:06.412-0400] [glassfish 4.0] [WARNING] [] [org.jboss.weld.interceptor.util.InterceptionTypeRegistry] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853026412] [levelValue: 900] [[
        Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled]]

        [2013-04-13T07:37:06.413-0400] [glassfish 4.0] [WARNING] [] [org.jboss.weld.interceptor.util.InterceptionTypeRegistry] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853026413] [levelValue: 900] [[
        Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled]]

        [2013-04-13T07:37:07.070-0400] [glassfish 4.0] [WARNING] [] [org.jboss.weld.Bootstrap] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853027070] [levelValue: 900] [[
        WELD-001473 javax.enterprise.inject.spi.Bean implementation org.hibernate.validator.internal.cdi.ValidatorFactoryBean@6f4a53a4 declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. It won't be possible to inject this bean into a bean with passivating scope (@SessionScoped, @ConversationScoped). This can be fixed by assigning the Bean implementation a unique id by implementing the PassivationCapable interface.]]

        [2013-04-13T07:37:07.070-0400] [glassfish 4.0] [WARNING] [] [org.jboss.weld.Bootstrap] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853027070] [levelValue: 900] [[
        WELD-001473 javax.enterprise.inject.spi.Bean implementation org.hibernate.validator.internal.cdi.ValidatorBean@42a59140 declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. It won't be possible to inject this bean into a bean with passivating scope (@SessionScoped, @ConversationScoped). This can be fixed by assigning the Bean implementation a unique id by implementing the PassivationCapable interface.]]

        [2013-04-13T07:37:07.077-0400] [glassfish 4.0] [WARNING] [] [org.jboss.weld.Bootstrap] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853027077] [levelValue: 900] [[
        WELD-001473 javax.enterprise.inject.spi.Bean implementation org.glassfish.jms.injection.JMSCDIExtension$LocalBean@40e9618a declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. It won't be possible to inject this bean into a bean with passivating scope (@SessionScoped, @ConversationScoped). This can be fixed by assigning the Bean implementation a unique id by implementing the PassivationCapable interface.]]

        [2013-04-13T07:37:07.154-0400] [glassfish 4.0] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853027154] [levelValue: 800] [[
        cdi-interceptor-ejb-1.0-SNAPSHOT was successfully deployed in 2,543 milliseconds.]]

        Show
        arjavdesai added a comment - I just tried with latest GFS build with revisions upto 61409 which includes WELD CR2 and app is getting deployed fine as seen in server logs [2013-04-13T07:37:05.144-0400] [glassfish 4.0] [INFO] [] [org.jboss.weld.Version] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853025144] [levelValue: 800] [[ WELD-000900 2.0.0 (CR2)]] [2013-04-13T07:37:06.412-0400] [glassfish 4.0] [WARNING] [] [org.jboss.weld.interceptor.util.InterceptionTypeRegistry] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853026412] [levelValue: 900] [[ Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled]] [2013-04-13T07:37:06.413-0400] [glassfish 4.0] [WARNING] [] [org.jboss.weld.interceptor.util.InterceptionTypeRegistry] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853026413] [levelValue: 900] [[ Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled]] [2013-04-13T07:37:07.070-0400] [glassfish 4.0] [WARNING] [] [org.jboss.weld.Bootstrap] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853027070] [levelValue: 900] [[ WELD-001473 javax.enterprise.inject.spi.Bean implementation org.hibernate.validator.internal.cdi.ValidatorFactoryBean@6f4a53a4 declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. It won't be possible to inject this bean into a bean with passivating scope (@SessionScoped, @ConversationScoped). This can be fixed by assigning the Bean implementation a unique id by implementing the PassivationCapable interface.]] [2013-04-13T07:37:07.070-0400] [glassfish 4.0] [WARNING] [] [org.jboss.weld.Bootstrap] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853027070] [levelValue: 900] [[ WELD-001473 javax.enterprise.inject.spi.Bean implementation org.hibernate.validator.internal.cdi.ValidatorBean@42a59140 declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. It won't be possible to inject this bean into a bean with passivating scope (@SessionScoped, @ConversationScoped). This can be fixed by assigning the Bean implementation a unique id by implementing the PassivationCapable interface.]] [2013-04-13T07:37:07.077-0400] [glassfish 4.0] [WARNING] [] [org.jboss.weld.Bootstrap] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853027077] [levelValue: 900] [[ WELD-001473 javax.enterprise.inject.spi.Bean implementation org.glassfish.jms.injection.JMSCDIExtension$LocalBean@40e9618a declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. It won't be possible to inject this bean into a bean with passivating scope (@SessionScoped, @ConversationScoped). This can be fixed by assigning the Bean implementation a unique id by implementing the PassivationCapable interface.]] [2013-04-13T07:37:07.154-0400] [glassfish 4.0] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=33 _ThreadName=admin-listener(2)] [timeMillis: 1365853027154] [levelValue: 800] [[ cdi-interceptor-ejb-1.0-SNAPSHOT was successfully deployed in 2,543 milliseconds.]]

          People

          • Assignee:
            jjsnyder83
            Reporter:
            tweier
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: