[jboss-user] [JBoss Tools (users)] - How to lookup EJB 3 session bean from servlet?
maximuszen
do-not-reply at jboss.com
Fri Jul 27 10:09:59 EDT 2007
I get a NullPointException at the save line.
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);
}
@Stateless
public class T2Facade implements T2FacadeLocal {
@PersistenceContext
private EntityManager em;
public void save(T2 t2) {
// em.persist(t2);
}
@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;
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068216#4068216
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068216
More information about the jboss-user
mailing list