Expand my Community achievements bar.

SOLVED

Not able to find my sling model

Avatar

Level 4

Hi Team,

I am facing one issue with my sling model. It mentioned in my core/pom.xml file as export package.

But its not there in "system/console/status-adapters" location.

I have followed the below articles too but didn't get the solution.

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/problem-sling-model-not-ge...

I have also tried to add package-info.java file in my model package location, but didn't worked out.

 

Now, i am clueless why its not working.

Note:-Its only working when removing "<packaging>bundle</packaging>"

Attaching the pom.xml file snapshot:-

 

 

 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.bookpedia</groupId>
        <artifactId>bookpedia-core</artifactId>
        <version>1.22.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>bookpedia-core.core</artifactId>
    <name>Bookpedia - Core</name>
    <description>Core bundle for Bookpedia</description>
    <packaging>bundle</packaging>
    <properties>
        <java.version>1.8</java.version>
        <sonar.language>java</sonar.language>
        <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
        <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
        <sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
        <sonar.jacoco.reportsPaths>target/jacoco.exec</sonar.jacoco.reportsPaths>
        <sonar.tests>src/test/java</sonar.tests>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.6</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <propertyName>argLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <!-- Coverage checking -->
                    <execution>
                        <id>jacoco-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>PACKAGE</element>
                                    <limits>
                                        <limit>
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.0</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.sonarsource.scanner.maven</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>3.7.0.1746</version>
            </plugin>
            <plugin>
                <groupId>org.apache.sling</groupId>
                <artifactId>sling-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bnd-process</id>
                        <goals>
                            <goal>bnd-process</goal>
                        </goals>
                        <configuration>
                            <bnd><![CDATA[
Import-Package: javax.annotation;version=0.0.0,*
                                ]]></bnd>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-baseline-maven-plugin</artifactId>
                <configuration>
                    <failOnMissing>false</failOnMissing>
                </configuration>
                <executions>
                    <execution>
                        <id>baseline</id>
                        <goals>
                            <goal>baseline</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>generate-scr-metadata</id>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <instructions>
                        <Import-Package>!net.sf.cglib.proxy, javax.inject;version=0.0.0,!org.dom4j.*, !org.xmlpull.v1,!sun.net.util,!antlr,!antlr.collections.impl,!org.apache.mina.*,*</Import-Package>
                        <Bundle-SymbolicName>bookpedia.core</Bundle-SymbolicName>
                        <Export-Package>
                            com.bookpedia.core.commons.*,
                            com.bookpedia.core.models.*
                        </Export-Package>
                        <Embed-Dependency>
                            api-all,commons-pool2,mina-core,org.apache.servicemix.bundles.antlr
                        </Embed-Dependency>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>

 

 

 

Anyone Please hep here.

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@skumari1 You've two bundle plugins in pom.xml: maven-bundle-plugin and bnd-maven-plugin, both essentially doing the same functionality and causing the problem. 

 

bnd-maven-plugin with maven-jar-plugin generates the OSGi bundle with metadata, which doesn't require <packaging>bundle</packaging>, whereas the maven-bundle-plugin requires the <packaging>

 

Either use the maven-bundle-plugin or bnd-maven-plugin, but not together in pom to resolve the issue. 

 

Note: bnd-maven-plugin is preferred over the other(maven-bundle-plugin) and is well maintained. You can refer to this to understand it better. 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

@skumari1 You've two bundle plugins in pom.xml: maven-bundle-plugin and bnd-maven-plugin, both essentially doing the same functionality and causing the problem. 

 

bnd-maven-plugin with maven-jar-plugin generates the OSGi bundle with metadata, which doesn't require <packaging>bundle</packaging>, whereas the maven-bundle-plugin requires the <packaging>

 

Either use the maven-bundle-plugin or bnd-maven-plugin, but not together in pom to resolve the issue. 

 

Note: bnd-maven-plugin is preferred over the other(maven-bundle-plugin) and is well maintained. You can refer to this to understand it better.