How to lookup EJB 3 session bean from servlet?

public class Test extends HttpServlet {

private static final long serialVersionUID = -1L;

@EJB

private T2Facade t2fl;

public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

T2 t2 = new T2("hello");

t2fl.save(t2);

LogUtil.log("t2.getId() = "+t2.getId(),Level.INFO,null);

LogUtil.log("t2.getX() = "+t2.getX(),Level.INFO,null);

}

@Entity

@SequenceGenerator(name="t2_sequence", sequenceName = "t2_seq")

public class T2 {

private static final long serialVersionUID = -2L;

private Long id;

private String x;

public T2(String x) {

this.x = x;

}

@Id

@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "t2_sequence")

public Long getId() {

return id;

}

public void setId(Long id) {

this.id = id;

}

[917 byte] By [maximuszena] at [2007-11-27 11:57:01]
# 1

I get a NullPointException on the save line in the servlet.

maximuszena at 2007-7-29 19:10:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...