0 Replies Latest reply on Feb 11, 2011 2:50 AM by ret

    weld JNDI space - fire Event from web to ejb

    ret

      Hi there!

       

      I created a little test-app and deployed it in an exploded ear to my JB6 final.

      My web-tier fires an @Inject Event<Entity> and on the other side in ejb i have an observer which should react to this.

      Weld first said it want to notify this observer, but then prints an errormessage that the EJB could not be found in JNDI.

       

      Seems like web-tier and ejb-tier have seperate JNDIs, but why?

       

      This is a bug or i have to work around this? and how? write a "repeater" in ejb-tier that fires the same Event again?

       

      this problem does not occur if i move the observer to web-tier too - then it works fine.

       

      Chris

       

      Samplecode for the Bean in the war:

       

      @Named
      @Stateless
      public class PersonRequestModel {
       
              @EJB
              PersonServiceImpl ps;
             
              @Inject
              Event<Person> event;
             
              private Person person = new Person();
       
              public void setPerson(Person person) {this.person = person;}
              public Person getPerson() {return person;}
             
              public Person search() {
                     Person p = ps.searchByName(person.getName()); // call to EJB
                      System.out.println(p); // prints the person found
                      event.fire(p); // err
                      return p;
              }
      }
      

       

      Samplecode ejb

       

      @Stateless
      public class PersonObserver {
       
          public PersonObserver() {}
         
          public void onAction(@Observes Person person) {
              System.out.println("sth happened with person " + person);
          }
      }
      
      1. @Named
      2. @Stateless
      3. public class PersonRequestModel {
      4.         @EJB
      5.         PersonServiceImpl ps;
      6.        
      7.         @Inject
      8.         Event<Person> event;
      9.        
      10.         private Person person = new Person();
      11.         public void setPerson(Person person) {this.person = person;}
      12.         public Person getPerson() {return person;}
      13.        
      14.         public Person search() {
      15.                 Person p = ps.searchByName(person.getName()); // call to EJB
      16.                 System.out.println(p); // prints the person found
      17.                 event.fire(p); // err
      18.                 return p;
      19.         }
      20. }

       

      stacktrace available here: http://pastebin.com/raw.php?i=mKcxcA2z