Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

AEM Error is importing package(s) [org.jsoup, org.jsoup.nodes, org.jsoup.select] in start level 20 but no bundle is exporting these for that start level

Avatar

Level 4

Hello, what happens is that I have a component and this has a sling model java, my idea is that I make a request with a url and I bring me the title of the page and save it in a getter, the code would be as follows:

 

public String getRecipeTitle() {
        String pageLink = "PAGE LINK";
        String titlePage = "";
        try {
            // Fetch the webpage content
            Document doc = Jsoup.connect(pageLink).get();

            // Extract the title
            Element titleElement = doc.select("title").first();
            if (titleElement != null) {
                titlePage = titleElement.text();
            } else {
                titlePage = "Title not found";
            }
        } catch (Exception e) {
            e.printStackTrace();
            titlePage = "Error fetching title";
        }

        return titlePage;
    }

And I use jsoup package to make this code, I install this package in the path: core/pom.xml adding this into the pom.xml file:

    <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.16.2</version>
    </dependency>
But when I build the project it throws me the error:
 
Bundle aem-develop-project.core:0.0.1-SNAPSHOT is importing package(s) [org.jsoup, org.jsoup.nodes, org.jsoup.select] in start level 20 but no
bundle is exporting these for that start level. (com.tfs:aem-develop-project.all:0.0.1-SNAPSHOT)
 
How can I fix this error? I only need to download the package of jsoup via Maven, I even try different solutions but it still not working
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi, 

The problem with your code is that the dependency should be wrapped with your bundle together so this is available at runtime. You can solve this by following this tutorial: https://www.linkedin.com/pulse/how-add-third-party-bundle-you-aem-package-veena-vikraman/. But beyond that, it seems a little bit odd what you are trying to do, if the page you are trying to get the title is an AEM one, it would be better to get it as a Page and use something like page.getTitle().

Hope this helps.



Esteban Bustamante

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi, 

The problem with your code is that the dependency should be wrapped with your bundle together so this is available at runtime. You can solve this by following this tutorial: https://www.linkedin.com/pulse/how-add-third-party-bundle-you-aem-package-veena-vikraman/. But beyond that, it seems a little bit odd what you are trying to do, if the page you are trying to get the title is an AEM one, it would be better to get it as a Page and use something like page.getTitle().

Hope this helps.



Esteban Bustamante