1 Reply Latest reply on Jan 22, 2010 2:25 PM by sathish avunoori

    Problem injecting stateless session bean into mail-receiving MDB

    aaa eee Newbie

      Hello all,


      I'm having some problems getting a stateless session bean injected into a mail-receiving MDB. Without any injection everything works and mails are being received. The mdb looks like this :




      @Name("mailUtilisationService")
      @MessageDriven(activationConfig =
        { @ActivationConfigProperty(propertyName = "mailServer", propertyValue = "localhost"),
         @ActivationConfigProperty(propertyName = "debug", propertyValue = "true"),
         @ActivationConfigProperty(propertyName = "mailFolder", propertyValue = "INBOX"),
         @ActivationConfigProperty(propertyName = "storeProtocol", propertyValue = "pop3"),
         @ActivationConfigProperty(propertyName = "flush", propertyValue = "false"),
         @ActivationConfigProperty(propertyName = "userName", propertyValue = "xxxxx"),
         @ActivationConfigProperty(propertyName = "password", propertyValue = "xxxxx") })
      @ResourceAdapter("mail-ra.rar")
      public class MailUtilisationService
                      implements MailListener
      {
      
        private static final Log log = Logging.getLog(MailUtilisationService.class);
      
        public void onMessage(final Message message)
        {
          try
          {
            final TestService testService = (TestService)Component.getInstance("testService");
            testService.helloWorld();
          }
          catch (final Exception e)
          {
            e.printStackTrace();
          }
        }
      }



      The bean:




      @Name("testService")
      @AutoCreate
      @Stateless
      public class TestServiceImpl
                      implements TestService
      {
        private static final Log log = Logging.getLog(TestServiceImpl.class);
      
        public void helloWorld()
        {
          log.info("Hello World!");
        }
      }
      



      It's interface:




      public interface TestService
      {
        public void helloWorld();
      }
      







      The exception that is logged:




      org.jboss.seam.InstantiationException: Could not instantiate Seam component: testService     
           at org.jboss.seam.Component.newInstance(Component.java:2144)
           at org.jboss.seam.Component.getInstance(Component.java:2021)
           at org.jboss.seam.Component.getInstance(Component.java:1983)
           at org.jboss.seam.Component.getInstance(Component.java:1977)
           at org.jboss.seam.Component.getInstance(Component.java:1972)
           at fr.groupamaES.gesflow.commun.utils.MailUtilisationService.onMessage(MailUtilisationService.java:34)
           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:597)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
           at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
           at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor$InvocationContext.proceed(InvocationContextInterceptor.java:138)
           at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
           at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:118)
           at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
           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:597)
           at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:83)
           at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:70)
           at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:59)
           at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
           at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
           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:597)
           at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
           at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_11983248.invoke(InvocationContextInterceptor_z_fillMethod_11983248.java)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
           at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_11983248.invoke(InvocationContextInterceptor_z_setup_11983248.java)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
           at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:194)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:80)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
           at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:262)
           at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:270)
           at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:140)
           at $Proxy279.onMessage(Unknown Source)
           at org.jboss.resource.adapter.mail.inflow.MailActivation.deliverMsg(MailActivation.java:149)
           at org.jboss.resource.adapter.mail.inflow.MailActivation.run(MailActivation.java:125)
           at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:213)
           at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:260)
           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
           at java.lang.Thread.run(Thread.java:619)
      Caused by: javax.naming.NamingException: Could not dereference object [Root exception is java.lang.RuntimeException: Can not find interface declared by Proxy in our CL + BaseClassLoader@f18dab{vfszip:/P:/opt/JBoss/jboss-as-5.0.1.GA-jdk6/server/default/deploy/mail-ra.rar/}]     
           at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1472)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:818)
           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:682)
           at javax.naming.InitialContext.lookup(InitialContext.java:392)
           at org.jboss.seam.Component.instantiateSessionBean(Component.java:1400)
           at org.jboss.seam.Component.instantiate(Component.java:1364)
           at org.jboss.seam.Component.newInstance(Component.java:2122)
           ... 74 more
      Caused by: java.lang.RuntimeException: Can not find interface declared by Proxy in our CL + BaseClassLoader@f18dab{vfszip:/P:/opt/JBoss/jboss-as-5.0.1.GA-jdk6/server/default/deploy/mail-ra.rar/}     
           at org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.redefineProxyInTcl(ProxyObjectFactory.java:341)
           at org.jboss.ejb3.proxy.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:134)
           at org.jboss.ejb3.proxy.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)
           at org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:156)
           at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
           at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1447)
           at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1464)
           ... 80 more
      Caused by: java.lang.ClassNotFoundException: fr.groupamaES.gesflow.operation.service.TestService from BaseClassLoader@f18dab{VFSClassLoaderPolicy@8bf0b4{name=vfszip:/P:/opt/JBoss/jboss-as-5.0.1.GA-jdk6/server/default/deploy/mail-ra.rar/ domain=ClassLoaderDomain@9fe84e{name=DefaultDomain parentPolicy=BEFORE parent=org.jboss.system.NoAnnotationURLClassLoader@1632c2d} roots=[MemoryContextHandler@23587306[path= context=vfsmemory://5c4o03d-z3ysz1-g42s9e0t-1-g42s9p2e-1t real=vfsmemory://5c4o03d-z3ysz1-g42s9e0t-1-g42s9p2e-1t], DelegatingHandler@19799306[path=mail-ra.rar context=file:/P:/opt/JBoss/jboss-as-5.0.1.GA-jdk6/server/default/deploy/ real=file:/P:/opt/JBoss/jboss-as-5.0.1.GA-jdk6/server/default/deploy/mail-ra.rar], DelegatingHandler@7641306[path=mail-ra.rar/mail-ra.jar context=file:/P:/opt/JBoss/jboss-as-5.0.1.GA-jdk6/server/default/deploy/ real=file:/P:/opt/JBoss/jboss-as-5.0.1.GA-jdk6/server/default/deploy/mail-ra.rar/mail-ra.jar]]  delegates=null exported=[org.jboss.resource.adapter.mail, org.jboss.resource.adapter.mail.inflow, META-INF] <IMPORT-ALL>NON_EMPTY}}     
           at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:422)
           at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
           at java.lang.Class.forName0(Native Method)
           at java.lang.Class.forName(Class.java:247)
           at org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.redefineProxyInTcl(ProxyObjectFactory.java:337)
           ... 86 more
      
      



      However, if I change the stateless session bean into a standard seam component by removing @Stateless, everything works fine.



      I'm using Jboss 5.0.1.GA and seam 2.1.1.GA.



      Any help or thoughts will be appreciated.