java.lang.NoClassDefFoundError:kotisoft / entrybean

时间:2014-04-14 20:36:23

标签: java servlets glassfish ejb

我正在制作一个项目,其中我使用servlet并通过它调用EJB。

  • 包名称为kotisoft
  • bean名称是entrybean
  • 接口名称entrybeanLocal

我的servlet代码是:

public class reportthis extends HttpServlet {

  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
    // Context jndiContext = new javax.naming.InitialContext();
    // InitialContext ic=new InitialContext();
    // entrybean = (entrybean)ic.lookup("java:global/KotiSoft-ejb/entrybean");

    /* TODO output your page here. You may use following sample code. */

    String jindiName = entrybean.class.getName();
    InitialContext ctx = new InitialContext();
    entrybean entrybean;
    entrybean = (entrybean) ctx.lookup(jindiName);

    String name,emailid,model,problem;
    name=request.getParameter("Name");
    emailid=request.getParameter("Emailid");
    model=request.getParameter("Model");
    problem=request.getParameter("Problem");
    Ticket ticket=new Ticket(); 
    ticket.setEmailid(emailid);
    ticket.setModel(model);
    ticket.setName(name);
    ticket.setProblem(problem);
    ***entrybean.addTicket(ticket);***...

加星标的代码是抛出异常的地方。

Glassfish服务器日志是:

INFO: WEB0671: Loading application [KotiSoft-war] at [/KotiSoft-war]
INFO: KotiSoft-war was successfully deployed in 198 milliseconds.
WARNING: StandardWrapperValve[reportthis]: PWC1406: Servlet.service() for servlet reportthis threw exception:
java.lang.NoClassDefFoundError: kotisoft/entrybean
    at com.kotisoft.reportthis.processRequest(reportthis.java:47)
    at com.kotisoft.reportthis.doPost(reportthis.java:103)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: kotisoft.entrybean
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
    ... 28 more

我已完成所有导入,我的EJB工作正常,服务器运行良好。我还将类文件夹添加到我的WAR中但没有用。

1 个答案:

答案 0 :(得分:0)

我明白了!

我添加了玻璃鱼部署描述符

并且我添加了ejb n给它一个jndi名称

我的servlet shud中的入口bean声明也是entrybeanLocal,而不仅仅是入口bean