3 Replies Latest reply on May 23, 2006 11:54 AM by Bill Burke

    Problems with @Interceptors in JBoss 4.0.4 GA

    Hauke Stange Newbie

      Hi There!

      I just migrated my whole EJBs to JBoss 4.0.4 GA and now get those exceptions...

      16:26:24,602 WARN [ServiceController] Problem creating service jboss.j2ee:service=EJB3,module=plyd.jar
      java.lang.TypeNotPresentException: Type javax.ejb.Interceptors not present
       at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:98)
       at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:107)
       at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
       at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:351)
       at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:175)
       at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
       at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
       at java.lang.Class.initAnnotationsIfNecessary(Class.java:2998)
       at java.lang.Class.getAnnotation(Class.java:2958)
       at org.jboss.aop.annotation.AnnotationElement.getVisibleAnnotation(AnnotationElement.java:88)
       at org.jboss.aop.Advisor.resolveAnnotation(Advisor.java:327)
       at org.jboss.ejb3.ProxyDeployer.initializeRemoteBindingMetadata(ProxyDeployer.java:127)
       at org.jboss.ejb3.SessionContainer.instantiated(SessionContainer.java:70)
       at org.jboss.ejb3.Ejb3Deployment.deployElement(Ejb3Deployment.java:573)
       at org.jboss.ejb3.Ejb3Deployment.deployElement(Ejb3Deployment.java:555)
       at org.jboss.ejb3.Ejb3Deployment.deployUrl(Ejb3Deployment.java:536)
       at org.jboss.ejb3.Ejb3Deployment.deploy(Ejb3Deployment.java:508)
       at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:463)
       at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:125)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:243)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
       at $Proxy0.create(Unknown Source)
       at org.jboss.system.ServiceController.create(ServiceController.java:330)
       at org.jboss.system.ServiceController.create(ServiceController.java:273)
       at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy34.create(Unknown Source)
       at org.jboss.ejb3.EJB3Deployer.create(EJB3Deployer.java:429)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
       at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
       at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
       at org.jboss.ws.server.WebServiceDeployer.create(WebServiceDeployer.java:99)
       at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.create(SubDeployerInterceptorSupport.java:180)
       at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:91)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy35.create(Unknown Source)
       at org.jboss.deployment.MainDeployer.create(MainDeployer.java:953)
       at org.jboss.deployment.MainDeployer.create(MainDeployer.java:943)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:807)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
       at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy6.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
      Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: javax.ejb.Interceptors
       at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:306)
       at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:511)
       at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:405)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Class.java:242)
       at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:95)
       ... 85 more
      


      For installing JBoss I used the jboss-4.0.4.GA-Patch1-installer.jar and selected the EJB3 configuration.

      I figured out, that by commenting out the @Interceptors annotation the deployment functions properly. I want to know, if something with the Interceptors has changed regarding to the new JBoss / EJB stuff.

      Here are the "interceptor class" and my session bean. Maybe you've some hints for me. I couldn't find anythings about that in the specs.

      CustomerAccountHomeBean

      import static javax.ejb.TransactionAttributeType.REQUIRED;
      
      import javax.annotation.EJB;
      import javax.annotation.Resource;
      import javax.ejb.Interceptors;
      import javax.ejb.Stateless;
      
      import javay.ejb.config.Config;
      import javay.ejb.config.ConfigListener;
      import javay.ejb.config.ConfigResource;
      import javay.ejb.config.PropertiesConfigurator;
      
      @Stateless
      @Interceptors(ConfigListener.class)
      @ConfigResource(type = PropertiesConfigurator.class, resource = "/config.properties")
      public class CustomerAccountHomeBean implements CustomerAccountHomeLocal,
       CustomerAccountHomeRemote
      {
       protected @Resource(mappedName="java:/Mail")
       Session mailSession;
      
       public @Config
       String transportProtocol = "smtp";
      
       protected @EJB
       Velocity velocity;
      
       // ...some Methods...
      
      }
      


      ConfigListener

      public class ConfigListener
      {
       @PostConstruct
       public void init(InvocationContext invocationContext)
       {
       Class< ? > clazz;
       ConfigResource configResource;
       Configurator configurator;
       String resource;
       InputStream inputStream;
       Object object;
      
       object = invocationContext.getBean();
      
       try
       {
       clazz = object.getClass();
       if (clazz.isAnnotationPresent(ConfigResource.class))
       {
       configResource = clazz.getAnnotation(ConfigResource.class);
       configurator = configResource.type().newInstance();
       resource = configResource.resource();
       assert resource != null;
       inputStream = clazz.getResourceAsStream(resource);
       assert inputStream != null;
       configurator.load(inputStream);
       walk(configurator, clazz, object);
       for (Class< ? > cl : clazz.getClasses())
       {
       walk(configurator, cl, object);
       }
       }
       }
       catch (InstantiationException e)
       {
       // TODO Logging
       e.printStackTrace();
       }
       catch (IllegalAccessException e)
       {
       // TODO Logging
       e.printStackTrace();
       }
       catch (IOException e)
       {
       // TODO Logging
       e.printStackTrace();
       }
       }
      
       private void walk(Configurator configurator, Class< ? > clazz, Object object)
       throws IllegalArgumentException, IllegalAccessException
       {
       for (Field field : clazz.getDeclaredFields())
       {
       if (field.isAnnotationPresent(Config.class))
       {
       configurator.config(field, object, field
       .getAnnotation(Config.class));
       }
       }
       }
      }
      



      Regards,
      Hauke