EJB3 Timer and Dependency Injection
ruhiakh Dec 18, 2009 11:27 PMI am working with Jboss 5.1. and I have simple SLB with ejbTimer in it. This beans references the another SLSB thru dependency injection. But deploying this bean causes issues which I can't figure out. It seems that timer runs in different class loader than my code and hence can't find the dependency injection bean: I spend too much of time on it and I don't know what is going on. Any help on this is much Appreciated. Here is code and exception
@Stateless
@Local
({ReferenceDataObserverLocalInterface.class})
@Remote
({ReferenceDataObserverRemoteInterface.class})
//@Pool (value=PoolDefaults.POOL_IMPLEMENTATION_STRICTMAX, maxSize=1, timeout=10000)
public
implements ReferenceDataObserverRemoteInterface,ReferenceDataObserverLocalInterface {
private static final Logger LOG = Logger.getLogger(ReferenceDataObserverBean.class);
private @Resource SessionContext ctx;
@EJB ReferenceDataServiceLocal refdata;
public void addChangeListener(String account, Object o) { SerializedServiceMessage info =
new SerializedServiceMessage(account, omsBlock);
ctx.getTimerService().createTimer(30000,60000, info); }
@Timeout
public void timeoutHandler(Timer timer) { SerializedServiceMessage message = (SerializedServiceMessage)timer.getInfo();
LOG.info("Timer notification received for " + timer.getInfo());
if ( timer != null ) { timer.cancel();
LOG.info("Timer created for " + ntapAccts.toString() + " for Object " + message.source.toString()); } }
else {
LOG.info("Time out called but the map is null"); } }
static class SerializedServiceMessage implements Serializable {
private static final long serialVersionUID = 1L; String
account; Object
source; SerializedServiceMessage(String account, Object source) {
this.account = account;
this.source = source; } } } ------------------------------------------------------ exception: 2009-12-18 12:35:07,918 ERROR [EJB-Timer-1261157694169[target=jboss.j2ee:ear=Mob.ear,jar=mob-business.jar,name=ReferenceDataObserverBean,service=EJB3]] [org.jboss.ejb.txtimer.TimerImpl] Error invoking ejbTimeout Caused by: java.lang.RuntimeException: Can not find interface declared by Proxy in our CL + BaseClassLoader@710713de{vfsfile:/opt/equity/mob/applications/application_server/jboss-5.1.0.GA/server/mob/deploy/ejb2-timer-service.xml}
javax.ejb.EJBException: java.lang.RuntimeException: Unable to inject jndi dependency: env/com.lotus.mob.services.booking.ReferenceDataObserverBean/mobAllocationBeanInterface into property com.lotus.mob.services.booking.ReferenceDataObserverBean.mobAllocationBeanInterface: com.lotus.mob.database.service.beans.interfaces.ReferenceDataServiceLocal from BaseClassLoader@710713de{VFSClassLoaderPolicy@7a98dcb{name=vfsfile:/opt/equity/mob/applications/application_server/jboss-5.1.0.GA/server/mob/deploy/ejb2-timer-service.xml domain=ClassLoaderDomain@3219ee8a{name=DefaultDomain parentPolicy=BEFORE parent=org.jboss.bootstrap.NoAnnotationURLClassLoader@74341960} roots=[MemoryContextHandler@211553883[path= context=vfsmemory://432d4h2j-bmdr5q-g3d8pnt8-1-g3d8q0d9-w real=vfsmemory://432d4h2j-bmdr5q-g3d8pnt8-1-g3d8q0d9-w]] delegates=null exported=[] <IMPORT-ALL>NON_EMPTY}}
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
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.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
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.stateless.StatelessContainer.callTimeout(StatelessContainer.java:266)
at org.jboss.as.ejb3.timerservice.TimedObjectInvokerBridge.callTimeout(TimedObjectInvokerBridge.java:44)
at org.jboss.ejb.txtimer.TimerImpl$TimerTaskImpl.run(TimerImpl.java:561)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: java.lang.RuntimeException: Unable to inject jndi dependency: env/com.lotus.mob.services.booking.ReferenceDataObserverBean/refData into property com.lotus.mob.services.booking.ReferenceDataObserverBean.ReferenceDataService: com.lotus.mob.database.service.beans.interfaces.ReferenceDataServiceLocal from BaseClassLoader@710713de{VFSClassLoaderPolicy@7a98dcb{name=vfsfile:/opt/equity/mob/applications/application_server/jboss-5.1.0.GA/server/mob/deploy/ejb2-timer-service.xml domain=ClassLoaderDomain@3219ee8a{name=DefaultDomain parentPolicy=BEFORE parent=org.jboss.bootstrap.NoAnnotationURLClassLoader@74341960} roots=[MemoryContextHandler@211553883[path= context=vfsmemory://432d4h2j-bmdr5q-g3d8pnt8-1-g3d8q0d9-w real=vfsmemory://432d4h2j-bmdr5q-g3d8pnt8-1-g3d8q0d9-w]] delegates=null exported=[] <IMPORT-ALL>NON_EMPTY}}
at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:99)
at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:89)
at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:61)
at org.jboss.ejb3.injection.InjectionInvocation.invokeTarget(InjectionInvocation.java:89)
at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:83)
at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:74)
at org.jboss.ejb3.EJBContainer.injectBeanContext(EJBContainer.java:1138)
at org.jboss.ejb3.pool.AbstractPool.create(AbstractPool.java:83)
at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:56)
at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:51)
at org.jboss.ejb3.pool.ThreadlocalPool.create(ThreadlocalPool.java:52)
at org.jboss.ejb3.pool.ThreadlocalPool.get(ThreadlocalPool.java:92)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:58)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
... 19 more
Caused by: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NamingException: Could not dereference object [Root exception is java.lang.RuntimeException: Can not find interface declared by Proxy in our CL + BaseClassLoader@710713de{vfsfile:/opt/equity/mob/applications/application_server/jboss-5.1.0.GA/server/mob/deploy/ejb2-timer-service.xml}]]
at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1352)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:817)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at org.jboss.ejb3.JndiUtil.lookup(JndiUtil.java:44)
at org.jboss.injection.JndiPropertyInjector.lookup(JndiPropertyInjector.java:75)
... 35 more
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@710713de{vfsfile:/opt/equity/mob/applications/application_server/jboss-5.1.0.GA/server/mob/deploy/ejb2-timer-service.xml}]
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1504)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:822)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1346)
... 39 more
Caused by: java.lang.RuntimeException: Can not find interface declared by Proxy in our CL + BaseClassLoader@710713de{vfsfile:/opt/equity/mob/applications/application_server/jboss-5.1.0.GA/server/mob/deploy/ejb2-timer-service.xml}
at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.redefineProxyInTcl(ProxyObjectFactory.java:410)
at org.jboss.ejb3.proxy.impl.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:134)
at org.jboss.ejb3.proxy.impl.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)
at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:161)
at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.redefineProxyInTcl(ProxyObjectFactory.java:410)
at org.jboss.ejb3.proxy.impl.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:134)
at org.jboss.ejb3.proxy.impl.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)
at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:161)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1479)
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1496)
... 43 more
Caused by: java.lang.ClassNotFoundException: com.lotus.mob.database.service.beans.interfaces.ReferenceDataServiceLocal from BaseClassLoader@710713de{VFSClassLoaderPolicy@7a98dcb{name=vfsfile:/opt/equity/mob/applications/application_server/jboss-5.1.0.GA/server/mob/deploy/ejb2-timer-service.xml domain=ClassLoaderDomain@3219ee8a{name=DefaultDomain parentPolicy=BEFORE parent=org.jboss.bootstrap.NoAnnotationURLClassLoader@74341960} roots=[MemoryContextHandler@211553883[path= context=vfsmemory://432d4h2j-bmdr5q-g3d8pnt8-1-g3d8q0d9-w real=vfsmemory://432d4h2j-bmdr5q-g3d8pnt8-1-g3d8q0d9-w]] delegates=null exported=[] <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.proxy.impl.objectfactory.ProxyObjectFactory.redefineProxyInTcl(ProxyObjectFactory.java:406)
... 49 more