users@glassfish.java.net

_at_EJB in further classes

From: Pawel R. <odwrotnie_at_gmail.com>
Date: Fri, 21 Dec 2007 03:26:01 +0100

Hi,

I have a servlet:
...
        @EJB
        EJBServerCommunicatorLocalInterface server;
        
        protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
                Servant s = new Servant();
                // response.getWriter().write("<h1>" + s.test() + "</h1>");
//ERROR
                response.getWriter().write("<h1>" + server.test() +
"</h1>");
        }
...

Why does the commented line causes:
[#|2007-12-21T03:09:02.600+0100|SEVERE|sun-appserver9.1|javax.enterprise.sys
tem.container.web|_ThreadID=22;_ThreadName=httpSSLWorkerThread-8080-1;_Reque
stID=0d659ef1-1106-40e1-81a0-122c6371f3e4;|StandardWrapperValve[Test]:
PWC1406: Servlet.service() for servlet Test threw exception
java.lang.NullPointerException,

when the Servant class looks like:
...
        @EJB
        EJBServerCommunicatorLocalInterface server;
        
        public String test() {
                return server.test();
        }
...

Thanks in advance,
Paweł R.