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 | Community
Skip to main content
Level 4
April 10, 2024
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

  • April 10, 2024
  • 1 reply
  • 1281 views

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
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by EstebanBustamante

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.

1 reply

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
April 10, 2024

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