0

I have a java maven project and I use jax-rs for http GET,POST requests. Inside that rest controller class I'm calling getHTML content (using jsoup) in another class. Then this NoClassDefFroundErrorr comes. I have already added the maven dependency and added the jar as well. Any reasons for this error?

This is my jsoup code:

public static ArrayList<StringBuilder> getHTMLContent(ArrayList newsUrl) throws IOException, InterruptedException {

    ArrayList<StringBuilder> descriptionList = new ArrayList();
    Document document;
    for (int i = 0; i < 15; i++) {
        System.out.println(newsUrl.get(i));
        try {
            Connection.Response response = Jsoup.connect((String) newsUrl.get(i))
                    .ignoreContentType(true)
                    .userAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0")
                    .referrer("http://www.google.com")
                    .timeout(12000)
                    .followRedirects(true)
                    .execute();


            document = response.parse();
            Elements paragraphs = document.body().select("p");
            StringBuilder content = new StringBuilder();
            for (Element element : paragraphs) {
                //removing advertisement tag
                if (!element.text().equals("Advertisement") &&
                        !element.text().contains("|") &&
                        !element.text().contains(":") &&
                        !(element.text().trim().split(" ").length == 1) &&
                        !(element.text().trim().contains("Home Page"))) {
                    content.append(element.text());
                    content.append("\n");
                }
            }
            descriptionList.add(content);
        }catch (Exception e){

        }
    }

    return descriptionList;

}

I call the method like this inside the rest controller

ArrayList<StringBuilder> descriptions = api_client.getHTMLContent(urls);

0 Answers0