0

I build dynamic web project in eclipse JAVA EE , I make a servlet and write in this code :

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{
    try {
        String comment = request.getParameter("comment") ;
        ANTLRInputStream input = new ANTLRInputStream(request.getParameter("comment"));
    } catch(Exception exception) {
        exception.printStackTrace();    
    }
}

when I run the project on server "apache-tomac-7" it take the input from text area then throw exciption :

**java.lang.NoClassDefFoundError: org/antlr/v4/runtime/ANTLRInputStream
    MyServlet.doPost(MyServlet.java:41)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)**

so How I can solve this problem ?

zajonc
  • 1,935
  • 5
  • 20
  • 25
code
  • 177
  • 1
  • 15

2 Answers2

0

Usually NoClassDefFoundErrors happen because you compiled your project with certain libraries, that are not found during runtime (or because a different version of your library is used by tomcat). You may want to check your classpath and make sure antlr is listed in your runtime libraries or copied within your tomcat libraries.

There are similar questions on this website, you may want to check it out: How to solve java.lang.NoClassDefFoundError?

Community
  • 1
  • 1
Jako
  • 944
  • 14
  • 33
0

ok , My Problem solve by add to my WEB-INF the (antlr-x.jar) and (annotation-api.jar) Thanks for all

code
  • 177
  • 1
  • 15