0 Replies Latest reply on Jun 7, 2013 7:32 AM by Radim Hanus

    interceptor binding type @Target({TYPE, METHOD}), interceptor defines lifecycle callback methods and DefinitionException is thrown

    Radim Hanus Expert

      Hi,

       

      I've been playing around with cdi interceptors and found following problem:

       

      11:27:48,803 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-16) MSC000001: Failed to start service jboss.deployment.unit."test.ear".WeldStartService: org.jboss.msc.service.StartException in

      service jboss.deployment.unit."test.ear".WeldStartService: Failed to start service

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1930) [jboss-msc-1.1.2.Final.jar:1.1.2.Final]

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]

              at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]

      Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-000619 An interceptor for lifecycle callbacks Interceptor [class org.cditest.interceptor.LoggingInterceptor intercepts @Logging] declares

      and interceptor binding interface org.cditest.interceptor.Logging with METHOD as its @Target.

              at org.jboss.weld.bean.InterceptorImpl.checkInterceptorBindings(InterceptorImpl.java:132)

              at org.jboss.weld.bean.InterceptorImpl.initializeAfterBeanDiscovery(InterceptorImpl.java:121)

              at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$AfterBeanDiscoveryInitializerFactory.doWork(ConcurrentBeanDeployer.java:126)

              at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$AfterBeanDiscoveryInitializerFactory.doWork(ConcurrentBeanDeployer.java:117)

              at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)

              at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)

              at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.7.0_21]

              at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.7.0_21]

              ... 3 more

       

      @InterceptorBinding

      @Retention(RUNTIME)

      @Target({TYPE, METHOD})

      public @interface Logging {

      }


       

      @Interceptor

      @Logging

      public class LoggingInterceptor implements Serializable {

        @AroundInvoke

      public Object onAroundInvoke(InvocationContext ctx) throws Exception {

        ...

        }


        @PostConstruct

      void onPostConstruct(InvocationContext ctx) {

        ...

                }


        @PreDestroy

         void onPreDestroy(InvocationContext ctx) {

        ...

                }

      }


      @Singleton

      @Startup

      public class StartUpBean {

            @Logging

                @PostConstruct

                void init() {

                }



                @Logging

                public void hello() {

                }



                public void bye() {

                }

      }


       

      In spec Interceptors 1.2 I cannot find any reason for this rejection. Moreover in jboss-7.1 works fine.

      When I remove lifecycle cycle methods from interceptor class when exception disappears

      Thanks for clarification,

      Radim