users@glassfish.java.net

Re: _at_EJB in JSF-managed beans in GlassFish v2?

From: Danilo Levantesi <danilo.levantesi_at_gmail.com>
Date: Mon, 5 Jan 2009 14:16:33 +0100

Check your web.xml: it should use Servlet 2.5

> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net