title: Sparql Lexical Error Encountered: " " (32), after : "not"
body: <p>I am getting lexical error when creating sparql query using Jena.
     Below is my source code. The error says
     com.hp.hpl.jena.query.QueryParseException: Lexical error at line 5, column 92.Encountered: " " (32), after : "not".</p>
  
  <pre><code>    package mas;
      import agent.core.onto.Ontology;
      import com.hp.hpl.jena.ontology.OntDocumentManager;
      import com.hp.hpl.jena.ontology.OntModel;
      import com.hp.hpl.jena.ontology.OntModelSpec;
      import com.hp.hpl.jena.query.Query;
      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.QuerySolution;
      import com.hp.hpl.jena.query.ResultSet;
      import com.hp.hpl.jena.rdf.model.Model;
      import com.hp.hpl.jena.rdf.model.ModelFactory;
      import com.hp.hpl.jena.rdf.model.ModelMaker;
      import java.io.FileInputStream;
  
      /**
      *
      * @author Naveed Khan
      */
      public class NewClass {
  
        public static void main(String arg[])
         {
          NewClass obj=new NewClass(); 
          String PREFIX="PREFIX seo:            &lt;http://www.seontology.org/test/specificOnto.owl#&gt; 
         PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
         PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt; "
          Model m = obj.getModel();
          String querystr=PREFIX + 
                  " \n SELECT  ?individualaff ?uc "
                          + "WHERE { "
                          + "?individualaff  seo:Requirements_Content ?c. "
                          + "filter not exists {?individualaff seo:hasUsecase ?uc } "
                          + "}";
          try 
          {
              Query query = QueryFactory.create(querystr) ;
              QueryExecution qexec = QueryExecutionFactory.create(query, m) ;
              ResultSet results = qexec.execSelect() ;
              QuerySolution soln = results.nextSolution() ;
          }catch(Exception ex) { 
           ex.printStackTrace(); }
  
  
  
  }
  private OntModel getModel()
  {
      OntModel model = null;
      if (model == null) {
  
      model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
      try {
  
          model.read(new FileInputStream(agent.core.onto.Config.SOURCE_FILE), Ontology.BASE);
  
      } catch (Exception e) {
          System.out.println("Loading Model failed:"+ e);
      }
    } 
          if (model != null)
            return model;
          else
            return null;
          }
          }
  
  The error says
  com.hp.hpl.jena.query.QueryParseException: Lexical error at line 5, column 92.     Encountered: " " (32), after : "not".
  </code></pre>