/* AsyncEjbServlet + Async Ejb - demonstrates how to use async. execution in java EE6 */ package dk.thoerup.asyncsamples; import java.io.IOException; import javax.ejb.EJB; import javax.ejb.embeddable.EJBContainer; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; //@EJB(beanInterface=AsyncEjb.class,name="ejb/SimpleBeanJNDI") @WebServlet(name = "AsyncEjbServlet", urlPatterns = { "/AsyncEjbServlet" }) public class AsyncEjbServlet extends HttpServlet { private static final long serialVersionUID = 1L; private EJBContainer container; private Context namingContext; private AsyncEjb asyncBean; public AsyncEjbServlet() { } @Override public void init() throws ServletException { super.init(); try { InitialContext ctx = new InitialContext(); asyncBean = (AsyncEjb) ctx.lookup("ejb/SimpleBeanJNDI"); //asyncBean = (AsyncEjb) namingContext.lookup("java:global/Test3/AsyncBean"); } catch (NamingException ne) { throw new ServletException(ne); } } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.getWriter().print("Started"); } }