Reputation: 3
I'm stuck since x time on how to inject a remote EJB in a managed bean of a JSF application. I've created a simpl java application and i've come to inject the remote EJB with the lookup... and it works. but when i come to the web application i really don't know what to do !!!
here is my EJB code:
@Stateless
public class Hello implements HelloRemote {
@Override
public String sayHello(String name) {
return "Hello, "+name;
}
}
the Remote interface is
@Remote
public interface HelloRemote {
public String sayHello(String name);
}
in my web application i vre created i managed bean :
@ManagedBean
public class MyBean {
@EJB
HelloRemote helloRemote;
}
BUT IT DOESN'T WORK :(
Upvotes: 0
Views: 1099
Reputation: 8151
If you want to expose EJB locally you have to use @Local
on Interface.
If you want to expose both locally and remotely you have to created 2 Interfaces, one with @Local
and one with @Remote
.
If your JSF ManagedBean(MyBean) is running locally ie.,Running on same App server as EJB you can directly inject it using @EJB
.
If your JSF ManagedBean is running on different server, you have to use the JNDI Registry to look up and access the EJB.
Upvotes: 1