AW: Problem to retrieve a document within a java class
"Pasche" <[email protected]>
| Newsgroups | gmane.text.xml.xindice.user |
|---|---|
| Message-ID | <[email protected]> |
I´m glad that you are right. It simply was an error with my classpath. I checked it different times but now it works fine. Thx, Christoph _____ Von: CORMIER Mario [mailto:[email protected]] Gesendet: Donnerstag, 21. Juli 2005 23:38 An: [email protected] Betreff: RE: Problem to retrieve a document within a java class The code looks good to me. It definitely looks like its a simple matter of a missing jar in your classpath. Make sure you have the Xindice jar(s) in your classpath, and verify that they contain the driver class. Mario -----Original Message----- From: Pasche [mailto:[email protected]] Sent: Thursday, July 21, 2005 4:46 PM To: [email protected] Subject: Problem to retrieve a document within a java class I´m running Xindice 1.1b4 on Tomcat 4.1.24. If I try to retrieve a document via console, I have no problems. Now I tried to search for a document within a java class: import org.xmldb.api.base.*; import org.xmldb.api.modules.*; import org.xmldb.api.*; public class Read { public static void main(String[] args) throws Exception { Collection col = null; try { String driver = "org.apache.xindice.client.xmldb.DatabaseImpl"; Class c = Class.forName(driver); Database database = (Database) c.newInstance(); DatabaseManager.registerDatabase(database); col = DatabaseManager.getCollection("xmldb:xindice://localhost:8080/db/test"); String xpath = "/output/ART/A0/SSTW"; XPathQueryService service = (XPathQueryService) col.getService("XPathQueryService", "1.0"); ResourceSet resultSet = service.query(xpath); ResourceIterator results = resultSet.getIterator(); while (results.hasMoreResources()) { Resource res = results.nextResource(); System.out.println((String) res.getContent()); } } catch (XMLDBException e) { System.err.println("XML:DB Exception occurred " + e.errorCode); } finally { if (col != null) { col.close(); } } } } If I try to run this program, I get the following errors and have no idea where it comes from. java.lang.ClassNotFoundException: org.apache.xindice.client.xmldb.DatabaseImpl at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at main.Read.main(Read.java:24) Exception in thread "main"