1 Reply Latest reply on Jun 21, 2012 10:22 AM by Tommy T

    Extending CachePutInterceptor -- is neither annotated @Interceptor nor registered through a portable extension

    Tommy T Newbie

      Hi,

       

       

      I am trying to write a simple Interceptor that extends Infinispan CachePutInterceptor (and all JSR107 annotations support interceptors).

       

      I extend the interceptor like this:

       

       

      {code}

      @Interceptor

      public class MyPutInterceptor extends CachePutInterceptor {

       

       

          /**

           * @param cacheResolver

           * @param contextFactory

           */

          public MyPutInterceptor(final CacheResolver cacheResolver, final CacheKeyInvocationContextFactory contextFactory) {

              super(cacheResolver, contextFactory);

              System.out.println("/n/nn/n/n/IN cacheput interceplto/n/n/n/nn/");

              // TODO Auto-generated constructor stub

          }

       

       

          private static final long serialVersionUID = 1L;

       

       

      }

       

      {code}

       


      I register it in extension like so

       

       

      {code} 

      class CacheConfigurationExtension implements Extension {

      ...

       

      /**

           * Support for JSR107 Annotations

           */

          void registerInterceptorBindings(@Observes final BeforeBeanDiscovery event) {

              //log.version(Version.getVersion());

       

       

              event.addInterceptorBinding(CacheResult.class);

              event.addInterceptorBinding(CachePut.class);

              event.addInterceptorBinding(CacheRemoveEntry.class);

              event.addInterceptorBinding(CacheRemoveAll.class);

          }

       

      void registerCachePutInterceptor(@Observes final ProcessAnnotatedType<MyPutInterceptor> event) {

              event.setAnnotatedType(new AnnotatedTypeBuilder<MyPutInterceptor>().readFromType(event.getAnnotatedType()).addToClass(MyCachePutLiteral.INSTANCE).create());

          }

       

      {code}

       

       

      I then add to beans.xml and run a simple Arquillian test. That does teh following :

       

       

      {code}

          @CachePut(cacheName = SIMPLE_CACHE)

          private int setUpCacheTest(final String domainId, @CacheKeyParam final String mykey, @CacheValue final int value) {

       

       

              System.out.println("in @cacheput method");

              final int returnvalue = value + 10;

              return returnvalue;

          }

       

       

          @CachePut

          private int setUpCacheTest1(final String domainId, @CacheKeyParam final String mykey, @CacheValue final int value) {

       

       

              System.out.println("in @cacheput method");

              final int returnvalue = value + 10;

              return returnvalue;

          }

       

       

          @Test

          @InSequence(7)

          public void test_cache_put_annotation() {

              System.out.println("calling @cacheput");

              int returnvalue = setUpCacheTest("mydomain", "myKey", 25);

              returnvalue = setUpCacheTest("mydomain", "myKey2", 25);

              int returnvalue1 = setUpCacheTest1("mydomain", "myKey2", 25);

              returnvalue1 = setUpCacheTest1("mydomain", "myKey2", 25);

              System.out.println("back from @cacheput method");

              Assert.assertEquals(35, returnvalue);

              final String returnedvalueis = cache.get("myKey");

              final String returnedvalue1is = cache.get("myKey2");

       

       

              System.out.println("ret: " + returnedvalueis);

              System.out.println("ret1: " + returnedvalue1is);

       

       

          }

      {code}

       

       

       

       

      But I keep getting the following error.....

      neither annotated @Interceptor nor registered through a portable extension

                at org.jboss.as.weld.services.WeldService.start(WeldService.java:83)

       

       

       

      {code}

      22:44:25,168 INFO  [com.mycompany.oss.itpf.datalayer.cache.core.extension.CacheExtension] (MSC service thread 1-4) CacheExtension is prearing for shutting down ...

      22:44:25,173 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."InfinispanCacheAnnotationWARTest.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."InfinispanCacheAnnotationWARTest.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001417 Enabled interceptor class <class>com.mycompany.oss.itpf.sdk.cache.infinispan.cdi.interceptor.MyPutInterceptor</class> in vfs:/C:/mycompany/eclipse/workspace/ServiceFramework/testsuite/integration/jee/content/InfinispanCacheAnnotationWARTest.war/WEB-INF/beans.xml@5 is neither annotated @Interceptor nor registered through a portable extension

                at org.jboss.as.weld.services.WeldService.start(WeldService.java:83)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_04]

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

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

      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001417 Enabled interceptor class <class>com.mycompany.oss.itpf.sdk.cache.infinispan.cdi.interceptor.MyPutInterceptor</class> in vfs:/C:/mycompany/eclipse/workspace/ServiceFramework/testsuite/integration/jee/content/InfinispanCacheAnnotationWARTest.war/WEB-INF/beans.xml@5 is neither annotated @Interceptor nor registered through a portable extension

                at org.jboss.weld.bootstrap.Validator.validateEnabledInterceptorClasses(Validator.java:455)

                at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:333)

                at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:366)

                at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:83)

                at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)

                ... 5 more

       

       

      22:44:25,389 INFO  [org.jboss.as.server] (management-handler-thread - 2) JBAS015870: Deploy of deployment "InfinispanCacheAnnotationWARTest.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"InfinispanCacheAnnotationWARTest.war\".WeldService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"InfinispanCacheAnnotationWARTest.war\".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001417 Enabled interceptor class <class>com.mycompany.oss.itpf.sdk.cache.infinispan.cdi.interceptor.MyPutInterceptor</class> in vfs:/C:/mycompany/eclipse/workspace/ServiceFramework/testsuite/integration/jee/content/InfinispanCacheAnnotationWARTest.war/WEB-INF/beans.xml@5 is neither annotated @Interceptor nor registered through a portable extension"}}

      22:44:25,641 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment InfinispanCacheAnnotationWARTest.war in 251ms

      22:44:25,644 INFO  [org.jboss.as.controller] (management-handler-thread - 2) JBAS014774: Service status report

      JBAS014777:   Services which failed to start:      service jboss.deployment.unit."InfinispanCacheAnnotationWARTest.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."InfinispanCacheAnnotationWARTest.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001417 Enabled interceptor class <class>com.mycompany.oss.itpf.sdk.cache.infinispan.cdi.interceptor.MyPutInterceptor</class> in vfs:/C:/mycompany/eclipse/workspace/ServiceFramework/testsuite/integration/jee/content/InfinispanCacheAnnotationWARTest.war/WEB-INF/beans.xml@5 is neither annotated @Interceptor nor registered through a portable extension

       

      {code}

       

       

      setup:

       

      {code}

      EBUG | logging                             | Logging Provider: org.jboss.logging.Log4jLoggerProvider

      Jun 17, 2012 10:44:01 PM org.jboss.as.arquillian.container.managed.ManagedDeployableContainer startInternal

      INFO: Starting container with: [C:\Java\jdk1.7.0_04\\bin\java, -Djboss.socket.binding.port-offset=201, -Xmx1024m, -XX:MaxPermSize=256m, -Djboss.node.name=jboss_eclipse, -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n, -Dtom=tom, -ea, -Djboss.home.dir=C:/tools/jboss7.1.1.Final-New/jboss-as-7.1.1.Final, -Dorg.jboss.boot.log.file=C:/tools/jboss7.1.1.Final-New/jboss-as-7.1.1.Final/standalone/log/boot.log, -Dlogging.configuration=file:C:/tools/jboss7.1.1.Final-New/jboss-as-7.1.1.Final/standalone/configuration/logging.properties, -Djboss.modules.dir=C:\tools\jboss7.1.1.Final-New\jboss-as-7.1.1.Final\modules, -Djboss.bundles.dir=C:\tools\jboss7.1.1.Final-New\jboss-as-7.1.1.Final\bundles, -jar, C:\tools\jboss7.1.1.Final-New\jboss-as-7.1.1.Final\jboss-modules.jar, -mp, C:/tools/jboss7.1.1.Final-New/jboss-as-7.1.1.Final\modules, -jaxpmodule, javax.xml.jaxp-provider, org.jboss.as.standalone, -server-config, standalone-full.xml]

      INFO  | xnio                                | XNIO Version 3.0.0.GA

      INFO  | nio                                 | XNIO NIO Implementation Version 3.0.0.GA

      INFO  | remoting                            | JBoss Remoting version 3.2.3.GA

      Listening for transport dt_socket at address: 8787

      DEBUG | nio                                 | Started channel thread 'Remoting "management-client" read-1', selector sun.nio.ch.WindowsSelectorImpl@1fd3a3b

      DEBUG | nio                                 | Started channel thread 'Remoting "management-client" write-1', selector sun.nio.ch.WindowsSelectorImpl@697123

      22:44:01,944 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA

       

      Infinispan CDI extension version: 5.1.5.FINAL{code}

       

       

      Any help appreciated.

       

       

      Best regards,

      T