Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Error with Solr integration with AEM

Avatar

Level 3

Hi,

I am following the tutorial Solr integration with AEM (Java) to integrate SOLR with AEM. 

when I build the project, I get the error, but the bundle is active

krist_wang_0-1699326713472.png

 

 

[ERROR] The analyser found the following errors for author and publish : 
[ERROR] [api-regions-exportsimports] com.astellas:aem-astellas-project.core:0.0.1-SNAPSHOT: Bundle aem-astellas-project.core:0.0.1-SNAPSHOT is importing package(s) [org.apache.solr.common, org.apache.solr.client.solrj.impl, org.apache.solr.common.params, org.apache.solr.client.solrj.response, org.apache.solr.client.solrj] in start level 20 but no bundle is exporting these for that start level. (com.astellas:aem-astellas-project.all:0.0.1-SNAPSHOT)
public class SolrIndexServlet extends SlingAllMethodsServlet {
    
    protected void doGet(final SlingHttpServletRequest req,
                         final SlingHttpServletResponse resp) throws IOException {

        SolrClient solrClient = getSolrClient();

        try {
            // Get all documents from practice collection
            //SolrQuery solrQuery = new SolrQuery("*:*");

            // Get document having name as home
            SolrQuery solrQuery = new SolrQuery();
            solrQuery.set("q", "name:home");
            QueryResponse queryResponse = solrClient.query("practice", solrQuery);
            SolrDocumentList documents = queryResponse.getResults();
            for(SolrDocument document : documents) {
                document.getFirstValue("name");
            }
        } catch (SolrServerException e) {
            throw new RuntimeException(e);
        }

    }

    
    protected void doPost(final SlingHttpServletRequest req,
                          final SlingHttpServletResponse resp) throws IOException {

        // POST the data to solr having name and id as home.
        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("name", "home");

        /*
           Provide custom id as page path or some unique value.
           It will help us to update same record as part of
           next update, sync or POST data in
           place of creating new or duplicate document.
        */
        doc.addField("id", "home");

        SolrClient solrClient = getSolrClient();

        try {
            solrClient.add("practice", doc);
            solrClient.commit("practice");
        } catch (SolrServerException e) {
            throw new RuntimeException(e);
        }
    }

    
    protected void doDelete(final SlingHttpServletRequest req,
                            final SlingHttpServletResponse resp) throws IOException {

        SolrClient solrClient = getSolrClient();
        try {

            // Use below code to Delete all documents
            // solrClient.deleteByQuery("*");

            // Delete specific document having id == home and name == home
            solrClient.deleteByQuery("practice", "(id:home) AND (name:home)");

            solrClient.commit("practice");
        } catch (SolrServerException e) {
            throw new RuntimeException(e);
        }
    }

    private static Http2SolrClient getSolrClient() {
        return new Http2SolrClient.Builder("http://localhost:8983/solr")
                .connectionTimeout(50000)
                .build();
    }

 

Could you please advise how can I  solve it.

 

Best regards!

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

This error message indicates that the bundle `aem-astellas-project.core` is importing packages related to Apache Solr (e.g., `org.apache.solr.common`, `org.apache.solr.client.solrj.impl`), but there are no bundles exporting these packages at the specified start level (20).

Here are some steps to help you resolve this issue:

1. **Check Bundle Dependencies:**
- Ensure that all the required Apache Solr-related dependencies are correctly specified in the `Import-Package` section of your `aem-astellas-project.core` bundle's manifest file.

2. **Check OSGi Configuration:**
- Verify that the Apache Solr-related bundles are correctly installed and active in your AEM instance.
- Make sure the start level (in this case, 20) is appropriate for the bundles exporting the required packages.

3. **Resolve Versioning Conflicts:**
- Check for versioning conflicts between the versions specified in the `Import-Package` section and the actual versions available in the AEM instance. Ensure that the versions match or are compatible.

4. **Update Maven Dependencies:**
- If you are using Maven for your AEM project, make sure that the dependencies in your `pom.xml` file are correctly specified and are compatible with each other.

5. **Update Dependencies:**
- If you are using outdated versions of Apache Solr-related dependencies, consider updating them to the latest compatible versions.

 

Hope this can give you some clues.



Esteban Bustamante

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

This error message indicates that the bundle `aem-astellas-project.core` is importing packages related to Apache Solr (e.g., `org.apache.solr.common`, `org.apache.solr.client.solrj.impl`), but there are no bundles exporting these packages at the specified start level (20).

Here are some steps to help you resolve this issue:

1. **Check Bundle Dependencies:**
- Ensure that all the required Apache Solr-related dependencies are correctly specified in the `Import-Package` section of your `aem-astellas-project.core` bundle's manifest file.

2. **Check OSGi Configuration:**
- Verify that the Apache Solr-related bundles are correctly installed and active in your AEM instance.
- Make sure the start level (in this case, 20) is appropriate for the bundles exporting the required packages.

3. **Resolve Versioning Conflicts:**
- Check for versioning conflicts between the versions specified in the `Import-Package` section and the actual versions available in the AEM instance. Ensure that the versions match or are compatible.

4. **Update Maven Dependencies:**
- If you are using Maven for your AEM project, make sure that the dependencies in your `pom.xml` file are correctly specified and are compatible with each other.

5. **Update Dependencies:**
- If you are using outdated versions of Apache Solr-related dependencies, consider updating them to the latest compatible versions.

 

Hope this can give you some clues.



Esteban Bustamante