users@glassfish.java.net

_at_EJB in JSF-managed beans in GlassFish v2?

From: <glassfish_at_javadesktop.org>
Date: Sun, 04 Jan 2009 05:58:30 PST

My local interface:

@javax.ejb.Local
public interface Calculator {
Integer add(Integer x, Integer y);
}

My EJB stateless session bean:

@javax.ejb.Stateless
public class CalculatorImpl implements Calculator {
public Integer add(Integer x, Integer y) {
return (x == null || y == null) ? null : x+ y;
}
}

My JSF-managed bean:

public class Index {
@EJB
private Calculator calculator;

private Integer x;
private Integer y;
private Integer result;

public void action() {
if (calculator == null) {
final String error = "You don't know how to use @EJB :)";
FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_FATAL, error, error);
FacesContext.getCurrentInstance().addMessage("form:result", fm);
result = null;
}
else {
result = calculator.add(x, y);
}
}
....

My web.xml has nothing related to ejb.

When I run the application, the calculator is null. Could anybody tell me what my problem is and how to fix it?

Thank you very much.
[Message sent by forum member 'dxxvi' (dxxvi)]

http://forums.java.net/jive/thread.jspa?messageID=323976