weld JNDI space - fire Event from web to ejb
ret Feb 11, 2011 2:50 AMHi 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); } }
- @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;
- }
- }
stacktrace available here: http://pastebin.com/raw.php?i=mKcxcA2z