4 Replies Latest reply on May 8, 2007 3:45 AM by Stateless Bean

    problem with messages in scheduler.

    Stateless Bean Novice

      hi,
      I got in messages properties some text like:

      myText = xxx yyy zzz
      


      and my messages
      @In
      protected Map<String, String> messages;
      


      in normal case it works when i do somethink like:
      String someString = messages.ge("myText");

      someString get "xxx yyy zzz",
      but i got method scheduled each minute and when i use messages in method i still get not "xxx yyy zzz", but "myText", why?
      If I run my medthod like <s:link action="sfsb.method", messages work!!!!

      here is my controler:
      @Name("engineControler")
      public class EngineControler extends GameSystem {
       public EngineControler() {}
      
       @In(create=true)
       EngineProcessor processor;
      
       public String calcUserPoints() {
       try {
       long interval = 1 * 500;
       @SuppressWarnings("unused")
       Timer timer = processor.scheduleUserPoints(new Date(), interval, null);
      
       }
       catch (RuntimeException e) {
       log.error("Scheduler ->engineControler - calcUserPoints(): " + e.getMessage());
       }
       return "success";
       }
      


      and processor
      @Name("processor")
      public class EngineProcessor extends GameSystem {
       public EngineProcessor() {}
      
       @SuppressWarnings("unchecked")
       @Asynchronous
       @Transactional
       public Timer scheduleUserPoints(@Expiration Date when,
       @IntervalDuration long interval,
       Person p) {
       try {
       long a = System.currentTimeMillis();
       //=================================================
      String someString = messages.ge("myText");
       //=================================================
       long b = System.currentTimeMillis();
       System.out.println("TIME: " + (b - a) + " ms.");
       }
       catch (RuntimeException e) {
       log.error("processor -> scheduleUserPoints(): " +
       e.getMessage());
       }
       return null;
       }
      


      can anyone explain why my messages instance can't work in scheduler?

        • 1. Re: problem with messages in scheduler.
          Stateless Bean Novice

          there shoudl be:
          messages.ge("myText");

          get(..), i made mistake in post, but problem still exist in cource code i have get()

          • 2. Re: problem with messages in scheduler.
            Pete Muir Master

            where is the messages.properties being packaged to in your ear?

            • 3. Re: problem with messages in scheduler.
              Stateless Bean Novice

               

              "petemuir" wrote:
              where is the messages.properties being packaged to in your ear?


              myProject - project name

              myProject.ear/myProject.jar/messages_en.properties
              


              • 4. Re: problem with messages in scheduler.
                Stateless Bean Novice

                Hi Pete!
                Until my problem still exist, i made some check;

                1. Downloaded newer seam version 1.2.1GA
                2. Create in eclipse new project "seampay" like in examples.
                3. Copied from your examples/seampay/src classes and modified:
                Processor and conroler like here:

                Controler

                 @In
                 protected Map<String, String> messages; //MY MESSAGES Instance
                
                 public String saveAndSchedule()
                 {
                 String locale = messages.get("login.password");
                 System.out.println("CONTROLER: " + locale); //here shoudl be "blabla,bleble, bububububu" and stil is login.password"
                 String result = persist();
                
                 Payment payment = getInstance();
                 log.info("scheduling instance #0", payment);
                
                 Timer timer = processor.schedulePayment(payment.getPaymentDate(),
                 payment.getPaymentFrequency().getInterval(),
                 payment);
                
                 payment.setTimerHandle( timer.getHandle() );
                
                 return result;
                 }
                


                Processor
                 @In
                 protected Map<String, String> messages;
                
                 @Asynchronous
                 @Transactional
                 public Timer schedulePayment(@Expiration Date when,
                 @IntervalDuration long interval,
                 Payment payment)
                 {
                 payment = entityManager.merge(payment);
                 String locale = messages.get("login.password");
                 System.out.println("LOCALE: " + locale); //and here again
                 log.info("[#0] Processing payment #1", System.currentTimeMillis(), payment.getId());
                 log.info("Timer handle is #0", payment.getTimerHandle());
                
                 if (payment.getActive()) {
                 BigDecimal balance = payment.getAccount().adjustBalance(payment.getAmount().negate());
                 log.info(":: balance is now #0", balance);
                 payment.setLastPaid(new Date());
                
                 if (payment.getPaymentFrequency().equals(Payment.Frequency.ONCE)) {
                 payment.setActive(false);
                 }
                 }
                
                 return null;
                 }
                


                and modified faces-config.xml by adding

                 <application>
                 <message-bundle>messages</message-bundle>
                 <locale-config>
                 <default-locale>en</default-locale>
                 <supported-locale>en</supported-locale>
                 </locale-config>
                 </application>
                


                and also copied my messages file to
                jboss-seam-pay.jar/messages-en.properties
                


                login.password = blabla,bleble, bububububu
                


                all copied back into ear file and started on jboss 4.0.5 AS,

                Problem is same as like in my app, i get "login.password" not "blabla...etc"
                why?
                Can anyone check this and tell me what i'm going wrong?
                Maybe this is bug?