Hi,

I have a large project that uses Jena extensively, and which was developed under the very early Jena code base. I'm trying to move to the latest Jena code 2.11.2. Creating a default Model and creating a query execution now fail. I've written and attached a small test case to help solve my problem, but I'm still stuck. In addition to the test program I've all attached a small rdf xml and ttl data files and a sparql query. There is also a the stack trace from one of the failures. I'm running this code in NetBeans varying all the commented out inputs for testing. They all show the same phenomena.

The stack trace, attached, seems to indicate a bad character so the test program, with the handleCharacters function, also checks that the characters are valid. When I move down to Jena 10.0, the create default Model and Model read work ok, but the SPARQL create query execution still faisl. I've also run my rdf files and SPARQL queries through the respective validators.

The product is large - having 10s of thousands of rdf files each of the order of 1MB. There many built SPARQL queries and the ability for the customer/user to write their own SPARQL query.

The system runs on Microsoft Windows 7 and on Microsoft Windows Server.

Any help or suggestions would be greatly appreciated. If more or different data or clarification is needed, I will happily supply it.

Don


--
e-mail: [email protected]
phone cell: 781-856-7230

TEST CODE

package javafintest;

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.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.apache.jena.riot.RDFDataMgr;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;


/**
 *
 * @author don
 */


public class JavaFinTest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        DoCk ck = new DoCk();
        ck.CkIllegal();
    }  
}
class  DoCk{
        public void CkIllegal(){
            //Input rdf
            String rdfname = "BadUTF";
            //String fullPath = 
"c:\\tmp\\Files\\transformed\\2013\\QTR1\\1800_2013-02-15.rdf";
            String fullPath = 
"/tmp/Files/transformed/2013/QTR1/1800_2013-02-15.rdf";
            //String fullPath = "/tmp/Files/transformed/2014/QTR4/test.rdf";
            //File file = new 
File("c:\\tmp\\Files\\transformed\\2013\\QTR1\\1800_2013-02-15.rdf");
            File file = new 
File("c:\\tmp\\Files\\transformed\\2013\\QTR2\\2488_2013-05-06.rdf");
            //String xmlFilePath = 
"c:\\tmp\\Files\\transformed\\2013\\QTR"+qtr+"\\"+rdfname+".rdf";
           //File file = new File(xmlFilePath);
            try {
                InputStream in = new FileInputStream(file);
                File qfile = new File("/tmp/Files/instances/queries/CoCik.rq"); 
               FileReader reader = new FileReader(qfile);
               char[] chars = new char[(int) qfile.length()];
               reader.read(chars);
               String content = new String(chars);
               reader.close();
               // Check for illegal characters
               FileReader reader2 = new FileReader(fullPath);
               Reader buffer = new BufferedReader(reader2);
                handleCharacters(buffer);
                //Test for Jena Model
                Model model = RDFDataMgr.loadModel(fullPath) ;
                
                Model financialModel = ModelFactory.createDefaultModel();
                financialModel.read(fullPath);
                // Test Query Factory
               //Query query = 
QueryFactory.read("file:/tmp/Files/instances/queries/CoCik.rq");
               //Query query2 = QueryFactory.create(content);
               
                String queryString = "PREFIX m_terms: 
<http://www.mansurus.com/terms/> \" "
                        + "PREFIX us-gaap: <http://xbrl.us/us-gaap/2008-03-31/> 
\" "
                + "PREFIX xbrldi: <http://xbrl.org/2006/xbrldi/> \" "
                + "SELECT ?periodEndDate    \" "
                + "Where {        $y  m_terms:DocumentPeriodEndDate 
?periodEndDate .      }";
            
                reader2 = new FileReader(fullPath);
                buffer = new BufferedReader(reader2);
                handleCharacters(buffer);
            QueryExecution qe = QueryExecutionFactory.create(queryString, 
financialModel);

        } catch (Exception e) {
            e.printStackTrace();
        } 
    } 
    
    
    public void handleCharacters(Reader reader) throws IOException {
        int r;
        int line= 0;
        while ((r = reader.read()) != -1) {
            char current = (char) r;
            if(current == 0xA)
                line++;
            if ((current <= 0x1F || current >= 0x7F) && (current != 0xD) && 
current != 0xA  && current != 0x9 ){
                System.out.println("possible illegal character: " + 
Integer.toHexString(current)+" at line number: "+line); 
            }
        }
    }
    }
        
        
Simple RDF XML Example

<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:contact="http://www.w3.org/2000/10/swap/pim/contact#"; 
xmlns:eric="http://www.w3.org/People/EM/contact#"; 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
  <rdf:Description rdf:about="http://www.w3.org/People/EM/contact#me";>
    <contact:fullName>Eric Miller</contact:fullName>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.w3.org/People/EM/contact#me";>
    <contact:mailbox rdf:resource="mailto:e.miller123(at)example"/>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.w3.org/People/EM/contact#me";>
    <contact:personalTitle>Dr.</contact:personalTitle>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.w3.org/People/EM/contact#me";>
    <rdf:type rdf:resource="http://www.w3.org/2000/10/swap/pim/contact#Person"/>
  </rdf:Description>
</rdf:RDF>      

SIMPLE TURTLE EXAMPLE

@PREFIX eric:    <http://www.w3.org/People/EM/contact#> .
@PREFIX contact: <http://www.w3.org/2000/10/swap/pim/contact#> .
@PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
 
eric:me contact:fullName "Eric Miller" .
eric:me contact:mailbox <mailto:e.miller123(at)example> .
eric:me contact:personalTitle "Dr." .
eric:me rdf:type contact:Person .


Exception in thread "main" java.lang.NoSuchFieldError: actualValueType
        at 
com.hp.hpl.jena.datatypes.xsd.XSDDatatype.convertValidatedDataValue(XSDDatatype.java:396)
        at com.hp.hpl.jena.datatypes.xsd.XSDDatatype.parse(XSDDatatype.java:270)
        at 
com.hp.hpl.jena.graph.impl.LiteralLabelImpl.setValue(LiteralLabelImpl.java:213)
        at 
com.hp.hpl.jena.graph.impl.LiteralLabelImpl.setLiteralLabel_1(LiteralLabelImpl.java:107)
        at 
com.hp.hpl.jena.graph.impl.LiteralLabelImpl.<init>(LiteralLabelImpl.java:96)
        at 
com.hp.hpl.jena.graph.impl.LiteralLabelFactory.createLiteralLabel(LiteralLabelFactory.java:28)
        at com.hp.hpl.jena.graph.NodeFactory.createLiteral(NodeFactory.java:81)
        at com.hp.hpl.jena.sparql.graph.NodeConst.<clinit>(NodeConst.java:29)
        at com.hp.hpl.jena.sparql.lang.ParserBase.<init>(ParserBase.java:56)
        at 
com.hp.hpl.jena.sparql.lang.SPARQLParserBase.<init>(SPARQLParserBase.java:48)
        at 
com.hp.hpl.jena.sparql.lang.sparql_11.SPARQLParser11Base.<init>(SPARQLParser11Base.java:22)
        at 
com.hp.hpl.jena.sparql.lang.sparql_11.SPARQLParser11.<init>(SPARQLParser11.java:5006)
        at 
com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:93)
        at 
com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
        at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:37)
        at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:156)
        at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:79)
        at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:52)
        at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:40)
        at 
com.hp.hpl.jena.query.QueryExecutionFactory.makeQuery(QueryExecutionFactory.java:480)
        at 
com.hp.hpl.jena.query.QueryExecutionFactory.create(QueryExecutionFactory.java:191)
        at javafintest.DoCk.CkIllegal(JavaFinTest.java:104)
        at javafintest.JavaFinTest.main(JavaFinTest.java:59)
Java Result: 1

Reply via email to