aspose file tools*
The moose likes XML and Related Technologies and the fly likes ==> saxonb : but : RuntimeException: No query engine found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "==> saxonb : but : RuntimeException: No query engine found" Watch "==> saxonb : but : RuntimeException: No query engine found" New topic
Author

==> saxonb : but : RuntimeException: No query engine found

Aimee Best
Greenhorn

Joined: Feb 27, 2010
Posts: 4
Hello,

I am trying to use saxon to xquery an xml file with Java, below is the code just to give you an idea what I am trying to do (there is nothing wrong with it).

The thing is, if I try to run it, I get

Exception in thread "main" java.lang.RuntimeException: No query engine found
at org.apache.xmlbeans.impl.store.Query.getCompiledQuery(Query.java:160)
at org.apache.xmlbeans.impl.store.Query.getCompiledQuery(Query.java:85)
at org.apache.xmlbeans.impl.store.Query.cursorExecQuery(Query.java:80)
at org.apache.xmlbeans.impl.store.Cursor._execQuery(Cursor.java:1336)
at org.apache.xmlbeans.impl.store.Cursor._execQuery(Cursor.java:1331)
at org.apache.xmlbeans.impl.store.Cursor.execQuery(Cursor.java:3839)
at XMLBeansCursor.selectWithXQuery(TestXMLBeansCursor.java:40)
at TestXMLBeansCursor.main(TestXMLBeansCursor.java:106)


even though I have saxonb in the classpath

set cp=%classpath%;books.jar
set cp=%cp%;%saxon%\saxon9-dom4j.jar
set cp=%cp%;%saxon%\saxon9-jdom.jar
set cp=%cp%;%saxon%\saxon9-s9api.jar
set cp=%cp%;%saxon%\saxon9-sql.jar
set cp=%cp%;%saxon%\saxon9-xom.jar
set cp=%cp%;%saxon%\saxon9-xpath.jar
set cp=%cp%;%saxon%\saxon9-xqj.jar

java -cp %cp% TestXMLBeansCursor


The funny thing is, in eclipse this runs ok.

I can't see what's wrong, why does it work in eclipse but not on the command line?

Has anybody seen something like this before? Any ideas?

I am using java 6 update 18.

Thanks a lot in advance for any hints.


public void selectWithXQuery(File xmlFile) {
try {
InventoryDocument inventory =
InventoryDocument.Factory.parse(xmlFile);
XmlCursor cursor = inventory.newCursor();

String query =
"for $a in $this/inventory/book[1]"
+ "return $a/@author";

XmlCursor result = cursor.execQuery(query);
System.out.println(result.getObject().toString());

}
catch (IOException e){
e.printStackTrace();
}
catch (XmlException e){
e.printStackTrace();
}

} // end selectWithXQuery

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Perhaps, contrary to what you think, Saxon is not in your classpath. I would review what's actually in that %saxon% variable, and also the list of Saxon jars which you have in your Eclipse build path compared to that list.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ==> saxonb : but : RuntimeException: No query engine found