• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jboss scheduler and spring framework

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

i have a task that needs to be executed at frequent intervals of time(every 5 min.) so i have been using scheduler-service.xml of jboss to do that. declaration of this class in scheduler-service is as follows.





now, my scheduled implementation(PollingThread) needs to access spring related beans. i have declared a private variable of spring bean inside PollingThread and it is not instatiating that and is giving null pointer exception while accessing spring related bean. so this should be passed as paramter in one of application context.



how can I inject spring bean inside polling thread. should i delcare polling thread as one bean in spring application context and pass spring bean to it.
If I declare it in spring application context, am i not technically declaring them in two places and it is getting created twice?
Please suggest .



Thanks
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The PollingThread will be instantiated by the JBoss MBean scheduler and will have no access to Spring or any of your other application components. It's upto you to set/get them appropriately from within the Schedulable. So instead of maintaining that as a field in the PollingThread, you can instead get hold of the UploadVideoService Spring bean instance from within the perform method by somehow getting access to the Spring's application context. I don't however have experience in Spring, so I don't know how you can do that.
 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic