title: org.apache.jasper.JasperException: Unable to compile class for JSP pls helpz
body: <p>I'm making a web application project using Maven. I've jsp file as <code>index.jsp</code>.</p>
  
  <p>Here is <code>index.jsp</code>:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"%&gt; 
  &lt;%@ page import="rajendra.arora.bitcoin.CoinbaseExample" %&gt;  
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;My name is fooo.&lt;/p&gt;
  &lt;%
      CoinbaseExample ce=new CoinbaseExample();
      out.println(ce.getHttp("https://api.coinbase.com/v1/account/balance", null));
  %&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Now, I've <code>CoinbaseExample.java</code> file which looks something like:</p>
  
  <pre><code>package rajendra.arora.bitcoin;
  import java.io.IOException;
  import java.security.InvalidKeyException;
  import java.security.NoSuchAlgorithmException;
  
  import javax.crypto.Mac;
  import javax.crypto.spec.SecretKeySpec;
  
  import org.apache.commons.codec.binary.Hex;
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.ClientProtocolException;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.client.methods.HttpRequestBase;
  import org.apache.http.entity.StringEntity;
  import org.apache.http.impl.client.HttpClientBuilder;
  import org.apache.http.util.EntityUtils;
  
  import com.coinbase.api.Coinbase;
  import com.coinbase.api.CoinbaseBuilder;
  
  public class CoinbaseExample {
  
      static String API_KEY = "API_KEY";
  
      static String API_SECRET = "API_SECRET";
  
      public static String getHttp(String url, String body)
              throws InvalidKeyException, NoSuchAlgorithmException,
              ClientProtocolException, IOException {
  
          String nonce = String.valueOf(System.currentTimeMillis());
          String message = nonce + url + (body != null ? body : "");
  
          Mac mac = Mac.getInstance("HmacSHA256");
          mac.init(new SecretKeySpec(API_SECRET.getBytes(), "HmacSHA256"));
          String signature = new String(Hex.encodeHex(mac.doFinal(message.getBytes())));
  
          HttpRequestBase request;
          if (body == null || body.length() == 0)
              request = new HttpGet(url);
          else {
              HttpPost post = new HttpPost(url);
              post.setEntity(new StringEntity(body));
              request = post;
          }
          request.setHeader("ACCESS_KEY", API_KEY);
          request.setHeader("ACCESS_SIGNATURE", signature);
          request.setHeader("ACCESS_NONCE", nonce);
  
          Coinbase cb = new CoinbaseBuilder()
          .withApiKey(System.getenv(API_KEY), System.getenv(API_SECRET))
          .build();
  
          HttpClient httpClient = HttpClientBuilder.create().build();
          HttpResponse response = httpClient.execute(request);
  
          HttpEntity entity = response.getEntity();
          if (entity != null)
              return EntityUtils.toString(entity);
          return null;
      }
  
  }
  </code></pre>
  
  <p>I've also inserted <code>dependency</code> into <code>pom.xml</code> like:</p>
  
  <pre><code>        &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
              &lt;version&gt;2.0&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>After running my program it says:</p>
  
  <pre><code>Dec 02, 2014 2:56:45 AM org.apache.catalina.core.AprLifecycleListener init
  INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre8\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre8/bin/client;C:/Program Files/Java/jre8/bin;C:/Program Files/Java/jre8/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;D:\eclipse;;.
  Dec 02, 2014 2:56:45 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
  WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:coinbase-java' did not find a matching property.
  Dec 02, 2014 2:56:46 AM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["http-nio-8080"]
  Dec 02, 2014 2:56:46 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
  INFO: Using a shared selector for servlet write/read
  Dec 02, 2014 2:56:46 AM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
  Dec 02, 2014 2:56:46 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
  INFO: Using a shared selector for servlet write/read
  Dec 02, 2014 2:56:47 AM org.apache.catalina.startup.Catalina load
  INFO: Initialization processed in 2440 ms
  Dec 02, 2014 2:56:47 AM org.apache.catalina.core.StandardService startInternal
  INFO: Starting service Catalina
  Dec 02, 2014 2:56:47 AM org.apache.catalina.core.StandardEngine startInternal
  INFO: Starting Servlet Engine: Apache Tomcat/8.0.0-RC5
  Dec 02, 2014 2:56:48 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
  INFO: validateJarFile(C:\Users\raj\Documents\jsp projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\coinbase-java\WEB-INF\lib\servlet-api-2.4.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
  Dec 02, 2014 2:56:51 AM org.apache.jasper.servlet.TldScanner scanJars
  INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
  Dec 02, 2014 2:56:51 AM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-nio-8080"]
  Dec 02, 2014 2:56:51 AM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["ajp-nio-8009"]
  Dec 02, 2014 2:56:51 AM org.apache.catalina.startup.Catalina start
  INFO: Server startup in 4557 ms
  Dec 02, 2014 2:56:54 AM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [jsp] in context with path [/coinbase-java] threw exception [Unable to compile class for JSP: 
  
  An error occurred at line: [32] in the generated java file: [C:\Users\raj\Documents\jsp projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\coinbase-java\org\apache\jsp\index_jsp.java]
  The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
  
  Stacktrace:] with root cause
  org.apache.jasper.JasperException: Unable to compile class for JSP: 
  
  An error occurred at line: [32] in the generated java file: [C:\Users\raj\Documents\jsp projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\coinbase-java\org\apache\jsp\index_jsp.java]
  The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
  
  Stacktrace:
      at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
      at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199)
      at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:467)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:606)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:221)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:107)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:76)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:934)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:90)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:515)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1012)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:642)
      at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1555)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>And my <code>index.jsp</code> says:</p>
  
  <pre><code>HTTP Status 500 - Unable to compile class for JSP.
  </code></pre>
  
  <p><strong><em>Please, help me :(</em></strong></p>
  
  <p><strong><em>Surely, your help would be appreciated!!</em></strong></p>