From: Christiaan F. <chr...@ad...> - 2007-01-29 12:01:16
|
shafqat zaman wrote: > I trying to work out with example web crawler but it seems to not > working ever after spending couple of hours. > > public static void main(String[] args) { > // create a new ExampleWebCrawler instance > ExampleWebCrawler crawler = new ExampleWebCrawler(); > // parse the command line options > parseArgs(args, crawler); > // start crawling and exit afterwards > crawler.crawl(); > } > > for some reaons crawl() method is producing NullPointerException. i > would be grateful, if some one can solve this problem. I'm sorry to hear that you are having these problems. I was not able to reproduce the problem, although I did encounter another one (see below). Could you provide us with the command line arguments that you used and the resulting stacktrace? That might give us a clue what to look for. Regarding the problem that I did find: it turns out that the export of the created RDF graph to a file does not work. After crawling, the file to which the Model is exported contains a TriX document with zero statements. After inserting some debug code I noticed that the following call prints out the same empty TriX document: model.writeTo(System.out, Syntax.Trix); This gives the following output: <?xml version='1.0' encoding='UTF-8'?> <TriX xmlns='http://www.w3.org/2004/03/trix/trix-1/'> </TriX> When I invoke the following code, I do get to see a reasonable TriX document: Connection connection = ((ModelImplSesame) model).getSesameConnection(); connection.export(new TriXWriter(System.out)); I have not traced down the cause but my gut feeling is that it probably has something to do with the use of context in the Model class: besides wrapping the Repository in a Model per URL to crawl, it is also wrapped in a shared Model. That Model is used to serialize the RDF. Perhaps it tries to export statements in the artificial and empty null context? Antoni: you adapted this code to RDF2Go, can you have a look at it? Chris -- |