0

I'm trying to use the Jena libraries from inside an eclipse plugin.

If I use it normally, I can write code like this:

public static void main(String[] args) {
    Query query = QueryFactory.create("SELECT * {} LIMIT 10");
    // provider.disconnect(file);
    QueryExecution qexec = QueryExecutionFactory.sparqlService(
            "http://dbpedia.org/sparql", query);
    switch (query.getQueryType()) {
    case (Query.QueryTypeSelect): {
        ResultSet results = qexec.execSelect();
        ResultSetFormatter.out(System.out, results);
        break;
    }
    default:
        return;
    }
}

But when I use the same code to execute a sparql query from an Eclipse plugin project (I run the plugin in the another eclipse runtime) it doesn't work. There isn't even an exception. The debugger just does weird stuff. Here is the code where it doesn't work (Its a method inside of a ILaunchShortcut implementation):

public void launch(IFile file) {
    MessageConsoleStream out = findConsole(CONSOLE_NAME).newMessageStream();
    try {
        provider.connect(file);
        IDocument document = provider.getDocument(file);
        String queryString = document.get();
        provider.disconnect(file);
        out.println(queryString);
        Query query = QueryFactory.create(queryString);
        // provider.disconnect(file);
        QueryExecution qexec = QueryExecutionFactory.sparqlService(
                "http://dbpedia.org/sparql", query);
        switch (query.getQueryType()) {
        case (Query.QueryTypeSelect): {
            ResultSet results = qexec.execSelect();
            ResultSetFormatter.out(out, results);
            break;
        }
        default:
            return;
        }
    } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

On the statement Query query = QueryFactory.create(queryString); the debugger goes into the class "EventTable.class" and does weird stuff. And then ends up in a loop of "org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine". I don't know why and what is happening.

I just found out that there is some kind of error handling going on. The error says:"parsers.FactoryConfigurationError: Provider for class javax.xml.parsers.DocumentBuilderFactory cannot be created"

pNRuag
  • 63
  • 5

1 Answers1

0

After some research on the web I found out, that i had to add the javax.xml bundle to the dependencies of my Jena Wrapper plugin projec. It now works fine.

pNRuag
  • 63
  • 5