[JBoss/Spring Integration] - Spring module and war deployed separatly
by djeanprost
Hello,
My question may be considered as off-topic, but let me expose my problem. I would like folks here to share their point of view on my issue.
I have a spring module which holds my business implementation. This business implementation is shared between 2 webapps. So what I want to do is to deploy my spring module using spring deployer (what a great feature by the way), and use these beans in my webapps. Both of them are deployed in the deploy dir of jboss.
As I also need the beans classes in my webapp, I also need them in the WEB-INF/lib. The classloading problem is approaching, isn't it ?
ApplicationContext appContext = WebApplicationContextUtils
| .getWebApplicationContext(servletContext);
| Object o = appContext.getBean("service.global.idFonctionnel");
| ServiceIdFonctionnel serviceIdFonctionnel = (ServiceIdFonctionnel)o;
This code leads me to a ClassCastException. I precise that the bean do implements the ServiceIdFonctionnel interface.
My questions :
Is spring deployer aimed at this kind of deployment scenario ?
If so, how should I do to avoid this ClassCastException ? Do I have to play with classloading options of my jboss-web.xml ?
If not, this means to me that I can't share spring modules between 2 webapp ?
Thank you for your testimonials and answers.
Best regards,
Dom
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002161#4002161
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002161
19 years, 3 months
[Messaging, JMS & JBossMQ] - How call EJB 3.0 in scheduler ?
by fxmichaud
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
19 years, 3 months