4 Replies Latest reply on Jun 13, 2013 8:47 AM by David Baddeley

    Quartz, Locale and Mail - FacesContext is null

    Frank Bitzer Newbie


      I'm trying to send e-mails from an Quartz scheduled process. The mails contain text from a resource bundle and must be sent in different languages. My classes are as follows:

      public class ScheduleController implements java.io.Serializable { 
              Processor processor;   
              public void scheduleTimer() {
                  //run task every minute
                  String intervalLogs = "0 0/1";
                  processor.createLogs(new Date(), intervalLogs);

      public class Processor { 
              @In(create = true)
              private Renderer renderer;
              LocaleSelector localeSelector;
              public QuartzTriggerHandle createLogs(@Expiration Date when, @IntervalCron String interval){
                //Code to get the Locale for this mail (country code is stored in a database
                //try to set locale and to send mail
                //this is required to confirm/save the selection and force the reload of message bundles!
                localeSelector.select();  //THIS IS THE LINE WHERE IT BREAKS DOWN

      It crashes in org.jboss.seam.international.LocaleSelector.select(LocaleSelector.java:65) with a NullPointerException. You can view the source of LocaleSelector here:Click

      Obviously, the javax.faces.context.FacesContext.getCurrentInstance() returns null.

      What can I to?