[jboss-user] [Beginner's Corner] - Timers on stateful sessions. JBoss 6 M4
Estanislao Musulin
do-not-reply at jboss.com
Mon Aug 30 15:56:47 EDT 2010
Estanislao Musulin [http://community.jboss.org/people/elsote] created the discussion
"Timers on stateful sessions. JBoss 6 M4"
To view the discussion, visit: http://community.jboss.org/message/559624#559624
--------------------------------------------------------------
Hi!
I'm building a simple session to test timers on JBoss 6 M4,
//-----------------------------------------------
package org.jboss.ejb3.timerservice.example;
import java.util.Date;
import javax.annotation.Resource;
import javax.ejb.Stateful;
//import javax.ejb.Stateless;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerService;
import com.soteica.ots.scheduler.SchedulerRemote;
@Stateful(name = "Scheduler")
public class Scheduler implements SchedulerRemote
{
@Resource
private TimerService timerService;
@Override
public void scheduleTask()
{
Date now = new Date();
Timer timer = this.timerService.createTimer(now, 5000, "5SecondTimer");
}
@Timeout
private void onTimeout(Timer timer)
{
System.out.println("Timeout method invoked at " + new Date() + " for bean " + this.getClass().getSimpleName());
}
}
//-----------------------------------------------
It works properlly is defined as Stateles, but if defined as stateful the following errors appear:
16:30:53,546 ERROR [STDERR] java.lang.RuntimeException: Unable to inject jndi dependency: TimerService into property org.jboss.ejb3.timerservice.example.Scheduler.timerService: stateful bean doesn't s
upport TimerService (EJB3 18.2#2)
16:30:53,546 ERROR [STDERR] at org.jboss.injection.JndiPropertyInjector.lookup(JndiPropertyInjector.java:82)
16:30:53,546 ERROR [STDERR] at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:99)
16:30:53,546 ERROR [STDERR] at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:89)
16:30:53,546 ERROR [STDERR] at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:61)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.injection.InjectionHelper.inject(InjectionHelper.java:51)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.injection.InjectionHelper.inject(InjectionHelper.java:43)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.session.SessionInjectionInvocation.proceed(SessionInjectionInvocation.java:45)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.injection.InjectionInvocation.invokeTarget(InjectionInvocation.java:97)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:91)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:82)
16:30:53,546 ERROR [STDERR] at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:82)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.EJBContainer.injectBeanContext(EJBContainer.java:1220)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.create(StatefulContainer.java:148)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:402)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.createSession(StatefulContainer.java:408)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.session.SessionContainer.createSession(SessionContainer.java:692)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionProxyFactoryBase.getNewSessionId(StatefulSessionProxyFactoryBase.java:280)
16:30:53,546 ERROR [STDERR] at org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionProxyFactoryBase.createProxyBusiness(StatefulSessionProxyFactoryBase.java:143)
16:30:53,546 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:30:53,546 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
16:30:53,546 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
16:30:53,546 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
16:30:53,562 ERROR [STDERR] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:121)
16:30:53,562 ERROR [STDERR] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
16:30:53,562 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:898)
16:30:53,562 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:791)
16:30:53,562 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:744)
16:30:53,562 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:548)
16:30:53,562 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:234)
16:30:53,562 ERROR [STDERR] Caused by: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NamingException: Could not dereference object [Root exception is java.
lang.UnsupportedOperationException: stateful bean doesn't support TimerService (EJB3 18.2#2)]]
16:30:53,562 ERROR [STDERR] at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1356)
16:30:53,562 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:819)
16:30:53,562 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)
16:30:53,562 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:30:53,562 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
16:30:53,562 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
16:30:53,562 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
16:30:53,562 ERROR [STDERR] at org.jboss.ejb3.EJBContainer$1.invoke(EJBContainer.java:853)
16:30:53,562 ERROR [STDERR] at $Proxy145.lookup(Unknown Source)
16:30:53,562 ERROR [STDERR] at org.jboss.ejb3.JndiUtil.lookup(JndiUtil.java:44)
16:30:53,562 ERROR [STDERR] at org.jboss.injection.JndiPropertyInjector.lookup(JndiPropertyInjector.java:75)
16:30:53,562 ERROR [STDERR] ... 30 more
16:30:53,562 ERROR [STDERR] Caused by: javax.naming.NamingException: Could not dereference object [Root exception is java.lang.UnsupportedOperationException: stateful bean doesn't support TimerService
(EJB3 18.2#2)]
16:30:53,562 ERROR [STDERR] at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1508)
16:30:53,562 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:824)
16:30:53,562 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)
16:30:53,562 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:392)
16:30:53,562 ERROR [STDERR] at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1350)
16:30:53,562 ERROR [STDERR] ... 40 more
16:30:53,562 ERROR [STDERR] Caused by: java.lang.UnsupportedOperationException: stateful bean doesn't support TimerService (EJB3 18.2#2)
16:30:53,562 ERROR [STDERR] at org.jboss.ejb3.TimerServiceContainer.getTimerService(TimerServiceContainer.java:178)
16:30:53,562 ERROR [STDERR] at org.jboss.ejb3.timerservice.naming.TimerServiceObjectFactory.getObjectInstance(TimerServiceObjectFactory.java:65)
16:30:53,562 ERROR [STDERR] at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
16:30:53,562 ERROR [STDERR] at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1483)
16:30:53,562 ERROR [STDERR] at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1500)
16:30:53,562 ERROR [STDERR] ... 44 more
16:30:53,562 ERROR [org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionProxyFactoryBase] Could not obtain new Session ID from SFSB Container: javax.ejb.EJBException: java.lang.RuntimeEx
ception: Unable to inject jndi dependency: TimerService into property org.jboss.ejb3.timerservice.example.Scheduler.timerService: stateful bean doesn't support TimerService (EJB3 18.2#2)
at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:423) [:1.5.0-alpha-4]
at org.jboss.ejb3.stateful.StatefulContainer.createSession(StatefulContainer.java:408) [:1.5.0-alpha-4]
at org.jboss.ejb3.session.SessionContainer.createSession(SessionContainer.java:692) [:1.5.0-alpha-4]
at org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionProxyFactoryBase.getNewSessionId(StatefulSessionProxyFactoryBase.java:280) [:1.0.10]
at org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionProxyFactoryBase.createProxyBusiness(StatefulSessionProxyFactoryBase.java:143) [:1.0.10]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_18]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_18]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_18]
at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_18]
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:121) [jboss-aop.jar:2.2.1.Alpha3]
at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) [:1.0.1.GA]
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:898) [:6.0.0.20100721-M4]
at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:791) [:6.0.0.20100721-M4]
at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:744) [:6.0.0.20100721-M4]
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:548) [:6.0.0.20100721-M4]
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:234) [:6.0.0.20100721-M4]
Caused by: java.lang.RuntimeException: Unable to inject jndi dependency: TimerService into property org.jboss.ejb3.timerservice.example.Scheduler.timerService: stateful bean doesn't support TimerServi
ce (EJB3 18.2#2)
at org.jboss.injection.JndiPropertyInjector.lookup(JndiPropertyInjector.java:82) [:1.5.0-alpha-4]
at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:99) [:1.5.0-alpha-4]
at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:89) [:1.5.0-alpha-4]
at org.jboss.injection.JndiPropertyInjector.inject(JndiPropertyInjector.java:61) [:1.5.0-alpha-4]
at org.jboss.ejb3.injection.InjectionHelper.inject(InjectionHelper.java:51) [:1.5.0-alpha-4]
at org.jboss.ejb3.injection.InjectionHelper.inject(InjectionHelper.java:43) [:1.5.0-alpha-4]
at org.jboss.ejb3.session.SessionInjectionInvocation.proceed(SessionInjectionInvocation.java:45) [:1.5.0-alpha-4]
at org.jboss.ejb3.injection.InjectionInvocation.invokeTarget(InjectionInvocation.java:97) [:1.5.0-alpha-4]
at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:91) [:1.5.0-alpha-4]
at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47) [:1.5.0-alpha-4]
at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:82) [:1.5.0-alpha-4]
at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67) [:1.0.1]
at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:82) [:1.5.0-alpha-4]
at org.jboss.ejb3.EJBContainer.injectBeanContext(EJBContainer.java:1220) [:1.5.0-alpha-4]
at org.jboss.ejb3.stateful.StatefulContainer.create(StatefulContainer.java:148) [:1.5.0-alpha-4]
at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:402) [:1.5.0-alpha-4]
... 15 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.UnsupportedOperationExc
eption: stateful bean doesn't support TimerService (EJB3 18.2#2)]]
at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1356) [:5.0.5.Final]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:819) [:5.0.5.Final]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688) [:5.0.5.Final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_18]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_18]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_18]
at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_18]
at org.jboss.ejb3.EJBContainer$1.invoke(EJBContainer.java:853) [:1.5.0-alpha-4]
at $Proxy145.lookup(Unknown Source) at org.jboss.ejb3.JndiUtil.lookup(JndiUtil.java:44) [:1.5.0-alpha-4]
at org.jboss.injection.JndiPropertyInjector.lookup(JndiPropertyInjector.java:75) [:1.5.0-alpha-4]
... 30 more
Caused by: javax.naming.NamingException: Could not dereference object [Root exception is java.lang.UnsupportedOperationException: stateful bean doesn't support TimerService (EJB3 18.2#2)]
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1508) [:5.0.5.Final]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:824) [:5.0.5.Final]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688) [:5.0.5.Final]
at javax.naming.InitialContext.lookup(InitialContext.java:392) [:1.6.0_18]
at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1350) [:5.0.5.Final]
... 40 more
Caused by: java.lang.UnsupportedOperationException: stateful bean doesn't support TimerService (EJB3 18.2#2)
at org.jboss.ejb3.TimerServiceContainer.getTimerService(TimerServiceContainer.java:178) [:1.5.0-alpha-4]
at org.jboss.ejb3.timerservice.naming.TimerServiceObjectFactory.getObjectInstance(TimerServiceObjectFactory.java:65) [:6.0.0.20100721-M4]
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) [:1.6.0_18]
at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1483) [:5.0.5.Final]
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1500) [:5.0.5.Final]
... 44 more
Any help will be appreciated, Thanks!
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/559624#559624]
Start a new discussion in Beginner's Corner at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100830/a8277ef8/attachment-0001.html
More information about the jboss-user
mailing list