this was my servlet program
package servlet;
import bean.statefullLocal;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
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;
@WebServlet(name="servletbean", urlPatterns={"/servletbean"})
public class servletbean extends HttpServlet {
statefullLocal statefull = lookupstatefullLocal();
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet servletbean</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet servletbean at " + request.getContextPath () + "</h1>");
int zahl = statefull.getIntMemory();
statefull.setIntMemory(zahl + 10);
out.println(statefull.getIntMemory());
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
private statefullLocal lookupstatefullLocal() {
try {
Context c = new InitialContext();
// return (statefullLocal) c.lookup("java:global/statelessbean-war/statelessbean-ejb/statefull!bean.statefullLocal");
return (statefullLocal) c.lookup("java:global/statelessbean-ejb/statefullLocal");
} catch (NamingException ne) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
throw new RuntimeException(ne);
}
}
}
[b]my ejb file is [/b]
package bean;
import javax.ejb.Stateful;
@Stateful
public class statefull implements statefullLocal {
Integer intMemory=0;
public Integer getIntMemory() {
return intMemory;
}
public void setIntMemory(int intMemory) {
this.intMemory = intMemory;
}
// Add business logic below. (Right-click in editor and choose
// "Insert Code > Add Business Method")
}
and I got the error as
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: PWC1392: Error instantiating servlet class servlet.servletbean
root cause
com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class servlet.servletbean
root cause
java.lang.RuntimeException: javax.naming.NamingException: Lookup failed for 'java:global/statelessbean-ejb/statefullLocal' in SerialContext [Root exception is javax.naming.NameNotFoundException: statelessbean-ejb]
root cause
javax.naming.NamingException: Lookup failed for 'java:global/statelessbean-ejb/statefullLocal' in SerialContext [Root exception is javax.naming.NameNotFoundException: statelessbean-ejb]
root cause
javax.naming.NameNotFoundException: statelessbean-ejb
note The full stack traces of the exception and its root causes are available in the GlassFish v3 lo
i tried with all the possibilities of lookup but its not working please help in getting output