1 Reply Latest reply on Jul 23, 2009 2:31 PM by Sanne Grinovero

    CNFE on business interface when injecting MBean in a MDB

    Sanne Grinovero Master

      Hello,

      env: JBoss 5.1.0.GA on Sun JDK 6, Fedora

      want to do:
      I'm defining a service using annotations and including the classes in a JAR package in EAR; in the same JAR, again using annotations, I define a quartz-activated MDB which is injecting the service.

      problem:
      Injection appears to work, I get a reference to a proxy, but when using the reference I get ClassNotFoundException about the business interface.

      MDB code:

      import java.io.Serializable;
      
      import javax.ejb.ActivationConfigProperty;
      import javax.ejb.EJB;
      import javax.ejb.MessageDriven;
      
      import org.jboss.ejb3.annotation.ResourceAdapter;
      import org.quartz.JobExecutionContext;
      import org.quartz.JobExecutionException;
      import org.quartz.StatefulJob;
      import org.slf4j.Logger;
      
      import com.revdriver.logging.LoggerFactory;
      import com.revdriver.parking.optimization.databasetruncate.OldDataTruncatorManagement;
      import com.revdriver.parking.optimization.sessionfactories.SessionFactoryIn;
      
      @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "cronTrigger", propertyValue = "*/15 * * * * ?") })
      @ResourceAdapter("quartz-ra.rar")
      public class ScheduledOptimization implements StatefulJob, Serializable {
      
       private static final Logger log = LoggerFactory.make();
      
       @EJB( name="MySessionFactory", beanInterface=SessionFactoryIn.class )
       public SessionFactoryIn sf;
      
       @Override
       public void execute(JobExecutionContext arg0) throws JobExecutionException {
       log.info( "Schedule triggered, sf is null: " + ( sf == null ) );
       {
       log.info( "using sf class: " + sf.getClass().getCanonicalName() );
       log.info( sf.sayHello() ); // **** CNFE EXCEPTION HERE
       }


      This deploys fine, and the management bean is usable from jmx-console, but when the timer triggers it prints:
      Schedule triggered, sf is null: false
      using sf class: $Proxy378

      and then throws exception:
      [org.jboss.aspects.tx.TxPolicy] javax.ejb.EJBTransactionRolledbackException: Specified calling class, com.revdriver.parking.optimization.sessionfactories.SessionFactoryIn could not be found for BaseClassLoader@70dc5c99{vfszip:/home/sanne/jboss-5.1.0.GA/server/default/deploy/quartz-ra.rar/}
      [org.quartz.core.JobRunShell] Job default.job.0.1248357986793 threw an unhandled Exception:
      javax.ejb.EJBTransactionRolledbackException: Specified calling class, com.revdriver.parking.optimization.sessionfactories.SessionFactoryIn could not be found for BaseClassLoader@70dc5c99{vfszip:/home/sanne/jboss-5.1.0.GA/server/default/deploy/quartz-ra.rar/}
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:115)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
       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:282)
       at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:270)
       at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:140)
       at $Proxy359.execute(Unknown Source)
       at org.jboss.resource.adapter.quartz.inflow.QuartzJob.execute(QuartzJob.java:57)
       at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
       at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
      Caused by: java.lang.RuntimeException: Specified calling class, com.revdriver.parking.optimization.sessionfactories.SessionFactoryIn could not be found for BaseClassLoader@70dc5c99{vfszip:/home/sanne/jboss-5.1.0.GA/server/default/deploy/quartz-ra.rar/}
       at org.jboss.ejb3.common.lang.SerializableMethod.getClassFromName(SerializableMethod.java:311)
       at org.jboss.ejb3.common.lang.SerializableMethod.getClassType(SerializableMethod.java:282)
       at org.jboss.ejb3.common.lang.SerializableMethod.toMethod(SerializableMethod.java:233)
       at org.jboss.ejb3.common.lang.SerializableMethod.toMethod(SerializableMethod.java:220)
       at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:182)
       at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
       at $Proxy348.sayHello(Unknown Source)
       at com.revdriver.parking.optimization.beans.ScheduledOptimization.execute(ScheduledOptimization.java:42)
       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.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_564410294.invoke(InvocationContextInterceptor_z_fillMethod_564410294.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_564410294.invoke(InvocationContextInterceptor_z_setup_564410294.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)
       ... 17 more
      Caused by: java.lang.ClassNotFoundException: com.revdriver.parking.optimization.sessionfactories.SessionFactoryIn from BaseClassLoader@70dc5c99{VFSClassLoaderPolicy@13437ab2{name=vfszip:/home/sanne/jboss-5.1.0.GA/server/default/deploy/quartz-ra.rar/ domain=ClassLoaderDomain@4f444356{name=DefaultDomain parentPolicy=BEFORE parent=org.jboss.bootstrap.NoAnnotationURLClassLoader@20968fda} roots=[MemoryContextHandler@858539519[path= context=vfsmemory://3j001-fcqqp4-fxhk2gl1-1-fxhk2um0-22 real=vfsmemory://3j001-fcqqp4-fxhk2gl1-1-fxhk2um0-22], DelegatingHandler@531071640[path=quartz-ra.rar context=file:/home/sanne/jboss-5.1.0.GA/server/default/deploy/ real=file:/home/sanne/jboss-5.1.0.GA/server/default/deploy/quartz-ra.rar], DelegatingHandler@779016548[path=quartz-ra.rar/quartz-ra.jar context=file:/home/sanne/jboss-5.1.0.GA/server/default/deploy/ real=file:/home/sanne/jboss-5.1.0.GA/server/default/deploy/quartz-ra.rar/quartz-ra.jar]] delegates=null exported=[org.jboss.resource.adapter.quartz.inflow, META-INF] <IMPORT-ALL>NON_EMPTY}}
       at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:448)
       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.common.classloader.PrimitiveAwareClassLoader.findClass(PrimitiveAwareClassLoader.java:105)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
       at org.jboss.ejb3.common.lang.SerializableMethod.getClassFromName(SerializableMethod.java:307)
       ... 56 more


      involved Local (management) interface:
      import javax.ejb.Local;
      
      @Local
      public interface SessionFactoryIn {
       public String sayHello();
      }


      MBean implementation:
      import org.jboss.ejb3.annotation.Depends;
      import org.jboss.ejb3.annotation.Management;
      import org.jboss.ejb3.annotation.Service;
      
      @Service( objectName = "optimizationJMX:service=sessionFactories", name = "MySessionFactory" )
      @Management(SessionFactoryIn.class)
      @Depends(value = { "jboss.jca:service=DataSourceBinding,name=parkingLogDS", "jboss.jca:service=DataSourceBinding,name=parkingContentDS" })
      public class SessionFactoryBean implements SessionFactoryIn {
       @Override
       public String sayHello() {
       return "Hi Sanne";
       }
      }


      As Jaikiran suggested on IRC I'm goin to open a JIRA; any suggestion is welcome as I was trying to load Hibernate SessionFactory this way to hunt down another bug in JBoss... it looks like it's hiding himself nesting deeper :-)