glassfish
  1. glassfish
  2. GLASSFISH-11825

CDI Interceptors Doest Work with Glassfish

    Details

    • Issuezilla Id:
      11,825

      Description

      I try to create some interceptors but :

      INFO: Created HTTP listener http-listener-1 on port 8080
      INFO: Created HTTP listener http-listener-2 on port 8181
      INFO: Created HTTP listener admin-listener on port 4848
      INFO: Created virtual server server
      INFO: Created virtual server __asadmin
      INFO: Virtual server server loaded system default web module
      INFO: Portable JNDI names for EJB NewSessionBean :
      [java:global/QuemSabeUmLogTeste/QuemSabeUmLogTeste-ejb/NewSessionBean,
      java:global/QuemSabeUmLogTeste/QuemSabeUmLogTeste-ejb/NewSessionBean!teste.NewSessionBean]
      INFO: WELD-000900 1.0.1 (SP1)
      INFO: Instantiated an instance of
      org.hibernate.validator.engine.resolver.JPATraversableResolver.
      INFO: Inicializando Mojarra 2.0.2 (FCS b10) para o contexto
      '/QuemSabeUmLogTeste-war'
      INFO: Loading application QuemSabeUmLogTeste#QuemSabeUmLogTeste-war.war at
      QuemSabeUmLogTeste-war
      SEVERE: Exception while loading the app
      org.glassfish.deployment.common.DeploymentException: WELD-001417 Enabled
      interceptor class class teste.BasicInterceptor is neither annotated @Interceptor
      nor registered through a portable extension
      at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:181)
      at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:125)
      at
      org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:239)
      at
      com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
      at
      com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:183)
      at
      org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:272)
      at
      com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:305)
      at
      com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
      at
      com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
      at
      com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(CommandRunnerImpl.java:83)
      at
      com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
      at
      com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1224)
      at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:365)
      at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:204)
      at
      com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
      at
      com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
      at
      com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:245)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
      at
      com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
      at
      com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
      at
      com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
      at
      com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
      at
      com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
      at
      com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
      at
      com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
      at
      com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001417 Enabled
      interceptor class class teste.BasicInterceptor is neither annotated @Interceptor
      nor registered through a portable extension
      at
      org.jboss.weld.bootstrap.Validator.validateEnabledInterceptorClasses(Validator.java:449)
      at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:319)
      at
      org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:399)
      at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:178)
      ... 30 more

      The beans.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <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>teste.BasicInterceptor</class>
      </interceptors>
      </beans>

      The BasicInterceptor.java

      @Interceptor @Basic
      public class BasicInterceptor {

      private final static ThreadLocal<InvocationContext> context = new
      ThreadLocal<InvocationContext>();

      @AroundInvoke
      public Object classInterceptor(InvocationContext newContext) throws Exception {}

      }

      The Basic.java

      @InterceptorBinding
      @Target(

      {ElementType.METHOD, ElementType.TYPE}

      )
      @Retention(RetentionPolicy.RUNTIME)
      public @interface Basic {

      }

      GlassFish V3 3.0.1 b14 and Weld 1.0.1

      The IDE is NetBeans 6.8 and 6.9 Beta

      1. QuemSabeUmLogTest-changes.diff
        1 kB
        Sivakumar Thyagarajan
      2. QuemSabeUmLogTeste.rar
        67 kB
        dyegocarmo

        Activity

        Hide
        dyegocarmo added a comment -

        Created an attachment (id=4313)
        Test Project with NetBeans 6.9 Beta

        Show
        dyegocarmo added a comment - Created an attachment (id=4313) Test Project with NetBeans 6.9 Beta
        Hide
        dyegocarmo added a comment -

        The error is in beans.xml

        The interceptors are declared in beans.xml on WAR MODULE... but the classes are
        located in EJB MODULE...

        But the interceptors doest work if the Managed Bean is on WAR MODULE , are this
        correct ?

        Show
        dyegocarmo added a comment - The error is in beans.xml The interceptors are declared in beans.xml on WAR MODULE... but the classes are located in EJB MODULE... But the interceptors doest work if the Managed Bean is on WAR MODULE , are this correct ?
        Hide
        dyegocarmo added a comment -

        The project proves:

        If you use @Vai (the @Vai use a @Interceptorbinding) on WAR MODULE... Doest
        work... because interceptors are codded on EJB module...

        This is a bug... because according to spec this should work.

        if you hard code a @Interceptors({}) on WAR module , the interceptors work...

        Show
        dyegocarmo added a comment - The project proves: If you use @Vai (the @Vai use a @Interceptorbinding) on WAR MODULE... Doest work... because interceptors are codded on EJB module... This is a bug... because according to spec this should work. if you hard code a @Interceptors({}) on WAR module , the interceptors work...
        Hide
        rogerk added a comment -

        Must this be a rar file? Can you attach an ear file for the app?

        Show
        rogerk added a comment - Must this be a rar file? Can you attach an ear file for the app?
        Hide
        rogerk added a comment -

        P2

        Show
        rogerk added a comment - P2
        Hide
        rogerk added a comment -

        assign to Siva

        Show
        rogerk added a comment - assign to Siva
        Hide
        Sivakumar Thyagarajan added a comment -

        Targetting MS7. The interceptor definition in the beans.xml in the WAR is not
        considered valid as there are no Interceptor defined in the WAR. The interceptors
        are defined in the EJB-JAR. Need to understand whether module visibility rules
        allow interceptors to be defined in a CDI-enabled module and the interceptors
        enabled in another CDI-enabled module.

        Show
        Sivakumar Thyagarajan added a comment - Targetting MS7. The interceptor definition in the beans.xml in the WAR is not considered valid as there are no Interceptor defined in the WAR. The interceptors are defined in the EJB-JAR. Need to understand whether module visibility rules allow interceptors to be defined in a CDI-enabled module and the interceptors enabled in another CDI-enabled module.
        Hide
        Sivakumar Thyagarajan added a comment -

        Diffs that I had to make to the project to run.

        Description of diffs follows in the next comment.

        Show
        Sivakumar Thyagarajan added a comment - Diffs that I had to make to the project to run. Description of diffs follows in the next comment.
        Hide
        Sivakumar Thyagarajan added a comment -

        I had to make the following changes to get the attached application running. Description of changes:
        1. QuemSabeUmLogTeste-ejb/src/conf/beans.xml: ejb-jar beans.xml has to have the interceptors enabled as the EJB uses the interceptor
        2. QuemSabeUmLogTeste-ejb/src/java/teste/BasicInterceptor.java: Interceptor must implement Serializable as it is assigned to a Bean (MyManagedBean) that is passivation scoped. The Interceptor, since it is part of the accessible closure of MyManagedBean, must implement Serializable so that MyManagedBean is passivation capable.
        3. QuemSabeUmLogTeste-ejb/src/java/teste/Vai.java: InterceptorBindingTypes must be either Target(METHOD,TYPE) or Target(TYPE) as per section 9.1 of the CDI 1.0 spec.

        After these changes, the application works and I am able to access the application through http://localhost:8080/QuemSabeUmLogTeste-war/
        The following application output is seen in server.log
        [#|2010-12-03T15:52:24.092+0530|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=15;_ThreadName=Thread-1;|Basic Interceptor Added|#]

        [#|2010-12-03T15:52:24.092+0530|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=15;_ThreadName=Thread-1;|Logger Interceptor Added|#]

        [#|2010-12-03T15:52:24.093+0530|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=15;_ThreadName=Thread-1;|Basic Interceptor Added|#]

        [#|2010-12-03T15:52:24.094+0530|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=15;_ThreadName=Thread-1;|Logger Interceptor Added|#]

        [#|2010-12-03T15:52:24.095+0530|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=15;_ThreadName=Thread-1;|See Passou pelo Manged Bean AGORA ! teste.NewSessionBean@1e5941c|#]

        [#|2010-12-03T15:52:24.095+0530|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=15;_ThreadName=Thread-1;|See Aqui passou pelo session bean !!!!|#]

        I am closing this issue as the original issue discussed in the bug report is resolved.

        Show
        Sivakumar Thyagarajan added a comment - I had to make the following changes to get the attached application running. Description of changes: 1. QuemSabeUmLogTeste-ejb/src/conf/beans.xml: ejb-jar beans.xml has to have the interceptors enabled as the EJB uses the interceptor 2. QuemSabeUmLogTeste-ejb/src/java/teste/BasicInterceptor.java: Interceptor must implement Serializable as it is assigned to a Bean (MyManagedBean) that is passivation scoped. The Interceptor, since it is part of the accessible closure of MyManagedBean, must implement Serializable so that MyManagedBean is passivation capable. 3. QuemSabeUmLogTeste-ejb/src/java/teste/Vai.java: InterceptorBindingTypes must be either Target(METHOD,TYPE) or Target(TYPE) as per section 9.1 of the CDI 1.0 spec. After these changes, the application works and I am able to access the application through http://localhost:8080/QuemSabeUmLogTeste-war/ The following application output is seen in server.log [#|2010-12-03T15:52:24.092+0530|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=15;_ThreadName=Thread-1;|Basic Interceptor Added|#] [#|2010-12-03T15:52:24.092+0530|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=15;_ThreadName=Thread-1;|Logger Interceptor Added|#] [#|2010-12-03T15:52:24.093+0530|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=15;_ThreadName=Thread-1;|Basic Interceptor Added|#] [#|2010-12-03T15:52:24.094+0530|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=15;_ThreadName=Thread-1;|Logger Interceptor Added|#] [#|2010-12-03T15:52:24.095+0530|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=15;_ThreadName=Thread-1;|See Passou pelo Manged Bean AGORA ! teste.NewSessionBean@1e5941c|#] [#|2010-12-03T15:52:24.095+0530|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=15;_ThreadName=Thread-1;|See Aqui passou pelo session bean !!!!|#] I am closing this issue as the original issue discussed in the bug report is resolved.

          People

          • Assignee:
            Sivakumar Thyagarajan
            Reporter:
            dyegocarmo
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: