[jboss-user] [Messaging, JMS & JBossMQ] - How call EJB 3.0 in scheduler ?
fxmichaud
do-not-reply at jboss.com
Tue Jan 16 03:40:07 EST 2007
Hi,
I'm developping web application and I would like run a scheduling service at JBoss startup.
I'm using JBoss 4.0.5 + Seam 1.1. My Eclipse project has been generated by using Seam-Gen tools.
[resources/META-INF/scheduler-service.xml] file :
| <?xml version="1.0" encoding="UTF-8"?>
| <server>
| <mbean code="org.jboss.varia.scheduler.Scheduler"
| name="task:service=Scheduler">
| <attribute name="StartAtStartup">true</attribute>
| <attribute name="SchedulableClass">com.application.intranet.tasks.Task</attribute>
| <attribute name="SchedulableArguments">aa,123456789</attribute>
| <attribute name="SchedulableArgumentTypes">java.lang.String,long</attribute>
|
| <attribute name="InitialStartDate">NOW</attribute>
| <attribute name="SchedulePeriod">6000</attribute>
| <attribute name="InitialRepetitions">-1</attribute>
| <depends>jboss.j2ee:module=fmichaud.jar,service=EJB3</depends>
| </mbean>
| </server>
|
[resources/META-INF/jboss-app.xml] file :
| <jboss-app>
| <loader-repository>
| seam.jboss.org:loader=fmichaud
| </loader-repository>
| <module>
| <service>META-INF/scheduler-service.xml</service>
| </module>
| </jboss-app>
|
My scheduled task class :
| public class Task implements Schedulable {
| private final zLogger log = zLogger.getLogger(getClass());
| private String name;
| private long value;
|
| /** Accounts business service EJB. */
| @EJB
| private AccountsServiceImpl accountsService;
|
| public Task(String name, long value)
| {
| this.name = name;
| this.value = value;
| log.logBusinessEvent(LogLevel.INFO, "ctor, name: " + name + ", value: " + value);
| }
|
| public void perform(Date now, long remainingRepetitions) {
| Collection<Account> accountsList = accountsService.getEntries();
| }
| }
|
I obtain next exception at JBoss startup :
| 09:35:53,066 ERROR [Scheduler$Listener] Handling a Scheduler call failed
| java.lang.NullPointerException
| at com.application.intranet.tasks.Task.perform(Task.java:72)
| at org.jboss.varia.scheduler.Scheduler$Listener.handleNotification(Scheduler.java:1251)
| at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.notification.NotificationListenerProxy.invoke(NotificationListenerProxy.java:153)
| at $Proxy46.handleNotification(Unknown Source)
| at javax.management.NotificationBroadcasterSupport.handleNotification(NotificationBroadcasterSupport.java:221)
| at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java:184)
| at javax.management.timer.Timer.sendNotification(Timer.java:1295)
| at javax.management.timer.Timer.notifyAlarmClock(Timer.java:1264)
| at javax.management.timer.TimerAlarmClock.run(Timer.java:1347)
| at java.util.TimerThread.mainLoop(Timer.java:512)
| at java.util.TimerThread.run(Timer.java:462)
|
In web application or with TestNG, EJB is running.
I tried to lookup jNDI EJB but nothing seems valid.
How to instantiate EJB 3.0 for calling from JBoss scheduler service ?
Thanks for any help.
Regards.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002157#4002157
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002157
More information about the jboss-user
mailing list