title: Using Jena Api in Java Web... Unknown Exception
body: <p>Did anyone encountered this exception while using Jena in Java Web Application... Please Kindly help me ..</p>
  
  <p>Here is my servlet code</p>
  
  <pre><code>package com.mycompany.servlet;
  
  import java.io.IOException;
  import java.util.Iterator;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletContext;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  
  
  import com.hp.hpl.jena.query.QueryExecution;
  import com.hp.hpl.jena.query.QueryExecutionFactory;
  import com.hp.hpl.jena.query.QueryFactory;
  import com.hp.hpl.jena.query.ResultSet;
  
  import com.hp.hpl.jena.rdf.model.ModelFactory;
  
  import com.hp.hpl.jena.ontology.*;
  
  
  /**
   * Servlet implementation class GreetingServlet
   */
  @WebServlet("/GreetingServlet")
  public class GreetingServlet extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      /**
       * @see HttpServlet#HttpServlet()
       */
      public GreetingServlet() {
          super();
          // TODO Auto-generated constructor stub
      }
  
      /**
       * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
       */
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
      }
  
      /**
       * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
       */
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
          String SOURCE ="file:E:\\healthcare.owl";
  
          OntModel base =  ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
          base.read( SOURCE );
  
  
          for (Iterator&lt;OntClass&gt; i = base.listClasses(); i.hasNext(); ) 
          {
  
          OntClass c = i.next();              
  
          //System.out.println( "Class" + c.getLocalName());
  
          }
      }
  
      }
  </code></pre>
  
  <p>Exception is
  HTTP Status 500 - </p>
  
  <hr>
  
  <p>type Exception report</p>
  
  <p>message </p>
  
  <pre><code>description The server encountered an internal error () that prevented it from fulfilling this request.
  </code></pre>
  
  <p>exception </p>
  
  <pre><code>javax.servlet.ServletException: Error instantiating servlet class com.mycompany.servlet.GreetingServlet
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
      java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>root cause </p>
  
  <pre><code>java.lang.NoClassDefFoundError: com/hp/hpl/jena/rdf/model/Model
      java.lang.Class.getDeclaredConstructors0(Native Method)
      java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
      java.lang.Class.getConstructor0(Unknown Source)
      java.lang.Class.newInstance0(Unknown Source)
      java.lang.Class.newInstance(Unknown Source)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
      java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>root cause </p>
  
  <pre><code>java.lang.ClassNotFoundException: com.hp.hpl.jena.rdf.model.Model
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
      java.lang.Class.getDeclaredConstructors0(Native Method)
      java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
      java.lang.Class.getConstructor0(Unknown Source)
      java.lang.Class.newInstance0(Unknown Source)
      java.lang.Class.newInstance(Unknown Source)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
      org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
      java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>note The full stack trace of the root cause is available in the Apache Tomcat/7.0.11 logs.</p>
  
  <hr>