You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Thusitha Thilina Dayaratne <th...@gmail.com> on 2015/06/11 19:59:08 UTC
cdi alternative NPE issue
I'm having following CDI-Alternative implementation in a simple app.
@WebServlet(name = "HelloServlet", urlPatterns = "/")
public class HelloServlet extends javax.servlet.http.HttpServlet {
@Inject
private Greeter greeter;
@EJB
private Greeter namedGreeter;
protected void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws
javax.servlet.ServletException, IOException {
PrintWriter writer = response.getWriter();
writer.println(greeter.greet());
writer.println(namedGreeter.greet()); // this throws NPE since EJB
is null
writer.close();
}
}
When I'm running this on my TomEE integrated tomcat server, im getting an
NPE. But when I run the same app in TomEE plus it doesn't throw the NPE. I
debug the app code inside the tomEE. It is null there too. but NPE is not
get thrown.
what is the reason here?
Thanks
/Thusitha
--