ejb access
Hi,
I'm currently trying to get to know Java EE and thus playing around a little. But off course this means some trouble can happen along the road...
I created an EJB called TitleCheckerBean with a local interface TitleCheckerLocal which I can use without problems in a servlet like this:
publicclass PostMessageextends HttpServlet{
@EJB
private TitleCheckerLocal titleChecker;
...
if (!titleChecker.checkTitle(e)){
response.sendRedirect("invalidMessage.jsp");
}else{ ...
However, I tried doing the same using JSP and the following code but with a more negative result:
initCtx =new InitialContext();
TitleCheckerLocal titleChecker = (TitleCheckerLocal)initCtx.lookup("java:comp/env/ejb/TitleCheckerLocal");
ConnectionFactory connectionFactory = (ConnectionFactory)initCtx.lookup("jms/NewMessageFactory");
Queue queue = (Queue)initCtx.lookup("jms/NewMessage");
Using this code, I get:
javax.naming.NameNotFoundException: No object bound to name java:comp/env/ejb/TitleCheckerLocal
However, my ConnectionFactory and Queue pose no problems.
So the question is what am I forgetting to do, because I read in numerous threads that to access an EJB from a JSP this is the way to go, but obviously not in my case. I suppose the @EJB annotation used in the servlet is doing some 'under the hood magic' that is not happening in the JSP case, but which kind of magic?
Is there maybe some *.xml I also need to change?
Thanks!
Vaak

