title: Unable to Compile class for JSP. Tomcat 7.0.82
body: <p>I have created a <code>war</code> file from a Java web project within Eclipse. It very rightly created a <code>classes</code> and <code>lib</code> folders in <code>WEB-INF</code> directory containing compiled sources and referenced libraries. When I deployed this project on Apache Tomcat 7.0.82, it runs fine for most of the pages except <code>Main2.jsp</code> where I get the following exception</p>
  
  <blockquote>
    <p>type Exception report</p>
    
    <p>message Unable to compile class for JSP</p>
    
    <p>description The server encountered an internal error that prevented it
    from fulfilling this request.</p>
    
    <p>exception</p>
    
    <p>org.apache.jasper.JasperException: Unable to compile class for JSP
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:675)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)</p>
  </blockquote>
  
  <p>The code of <code>Main.jsp</code> is below</p>
  
  <pre><code>&lt;%@page import="assemble_xml.*"%&gt;
  &lt;%@page import="java.io.*"%&gt;
  &lt;%@page import="java.util.*"%&gt; 
  &lt;%@page import="org.json.JSONObject"%&gt;
  &lt;%@page import="org.json.*;"%&gt;
  &lt;%
  System.out.println("\n*** Inside Main2.jsp");
  String data1 = request.getParameter("data");
  String sourceApiId = request.getParameter("sourceApiId");
  String bpFile = request.getParameter("bpFile");
  String context = getServletContext().getRealPath("/");
  //data1 = "{000:{name:mkyong.com,messages:[msg 1,msg 2,msg 3],age:100},001:{name:mkyong.com,messages:[msg 1,msg 2,msg 3],age:100}}";
  JSONObject jsonObject = new JSONObject(data1);
  
  System.out.println("\n*** Inside Main2.jsp: jsonObject"  + data1);
  
  Operation op1 = new Operation ("");
  
  HashMap&lt;String, Operation&gt; hm_xml_att  = op1.readOpAttribFromXML2(context+bpFile, jsonObject);
  op1.writeXML(hm_xml_att,context + "auth_refine_output" + File.separatorChar + sourceApiId);
  
  //BP bp = new BP(context,context + "\\auth_refine_output\\Mappings.txt",context + "\\auth_refine_output\\" + sourceApiId,context + "\\auth_refine_output\\OFBiz_Process.xml");
  
  //response.setContentType("text/html"); 
  //response.getWriter().write("Dataflow file (" +context + "\\auth_refine_output\\OFBiz_Process.xml) generated successfully");  
  //System.out.println("\n*** Inside Main2.jsp: Dataflow file (" +context + "\\auth_refine_output\\OFBiz_Process.xml" + ") generated successfully");
  %&gt; 
  </code></pre>
  
  <p>I am pretty sure that the problem is due to the following two imports</p>
  
  <pre><code>&lt;%@page import="org.json.JSONObject"%&gt;
  &lt;%@page import="org.json.*;"%&gt;
  </code></pre>
  
  <p>because, when I remove them, the error remains the same but now it's due to not resolving <code>JsonObject</code> to a type. Ironically, I have more than three files in <code>WEB-INF\lib</code> folder that seem like containing <code>JsonOject</code>. Those files are <code>json-20090211.jar</code>, <code>json-20160810.jar</code> and <code>json-lib-2.4-jdk15.jar</code>.</p>
  
  <p>All three files are also present in eclipse project but it runs flawlessly in eclipse. I am not the author of this project and not a Java pro anyway. So, I wonder why do we have three files included as dep just for JSON? and why it works fine in eclipse but not from Apache Tomcat 7? </p>