2

This might be a very basic and silly question for experienced people. But please help. I am trying to use Crawler4j with in my Grails app by following this tutorial. I know its Java code but I am using it in a controller class called CrawlerController.groovy.

I added the jar files but when I write CrawlConfig crawlConfig = new CrawlConfig() it throws me a compiler error saying "Groovy unable to resolve class" . I refreshed dependencies and tried everything. May be I am missing something since I am a beginner. This is what I have written so far and all the import statements and CrawlConfig statement throws errors:

import edu.uci.ics.crawler4j.crawler.Page;
import edu.uci.ics.crawler4j.crawler.WebCrawler;
import edu.uci.ics.crawler4j.parser.HtmlParseData;
import edu.uci.ics.crawler4j.url.WebURL;
class CrawlerController extends WebCrawler {
    public static void main(String[] args) {
    CrawlConfig crawlConfig = new CrawlConfig()

    }
}

` Please help. Thanks.

clever_bassi
  • 2,392
  • 2
  • 24
  • 43
  • 1
    What class does it say? How did you add the jars? You could just add `compile 'edu.uci.ics:crawler4j:3.5'` to your BuildConfig dependencies... did you do i that way, or did you download loads of stuff and put it somewhere? – tim_yates Jun 25 '14 at 14:19
  • 1
    I updated question. Tried adding that line in buildconfig, doesnt work. I downloaded the jar files from the crawler4j website, then in my grails IDE, i added external jars. Thats all. Error says: Groovy: Unable to resolve class edu.uci.ics.crawler4j.crawler.Page and similarly for all other imports. – clever_bassi Jun 25 '14 at 14:23
  • 1
    _"CrawlConfig statement throws errors"_ <-- Pasting the errors you get into the question is invariably useful – tim_yates Jun 25 '14 at 14:23
  • 1
    editing buildconfig, and running grails compile should be enough...do you see it fetching he jars? Obviously if he jars are elsewhere in the classpath, his may break it in other ways – tim_yates Jun 25 '14 at 14:24
  • Ya I apologize. Updated the comment. – clever_bassi Jun 25 '14 at 14:24
  • They are in my Project/lib folder. I edited build config, but when I write this code it shows me compilations errors. – clever_bassi Jun 25 '14 at 14:29

1 Answers1

0

Just refresh your dependencies.

sean3838
  • 65
  • 8