Hi Everyone - I am using maven-bundle-plugin artifact in the core module. The issue I am facing is sling model not available, I found that Export Package header in the bundle MANIFEST.MF section is empty which causes the issues with the sling models.
I have also tried with "bnd-maven-plugin" artifactId and removed the VERSIONED filter from -exportcontents but it is still not generating. I have already tried with updating the Manifest.MF manually and it worked, so the issue is only related to Export Package header. Can someone suggest on this issue?
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>4.1.0</version>
<inherited>true</inherited>
<configuration>
<instructions>
<!--<Embed-Dependency>org.apache.servicemix.bundles.aws-java-sdk, netty-all</Embed-Dependency>
--><!-- Import any version of javax.inject, to allow running on multiple
versions of AEM -->
<Import-Package>javax.inject;version=0.0.0,*</Import-Package>
<Sling-Model-Packages>
com.test.aem.abc.core.xyz.impl.models
</Sling-Model-Packages>
</instructions>
</configuration>
</plugin>
Solved! Go to Solution.
Views
Replies
Total Likes
Check you package is under Private-Package, in bundle manifest. If so add package info(package-info.java) to your package and see.
Okie. Given that Sling model is not recognized per the error message, the way the package name/structure is defined inside core module for models family matters. Can you confirm the list of classes/models that resides under com.company.aem.xyz.core.models
Can you retain only the interfaces in com.company.aem.xyz.core.models and move the model implementation to something like com.company.aem.xyz.core.internal.model.impl and then,
1. Execute as is or
2. Remove <Sling-Model-Packages> and use Sling Models bnd plugin to scan the models. Details for the same as below
<_plugin>org.apache.sling.bnd.models.ModelsScannerPlugin</_plugin> within <instructions> tag and dependency information for this plugin within <dependencies> section of build definition.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<_plugin>org.apache.sling.bnd.models.ModelsScannerPlugin</_plugin>
</instructions>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.bnd.models</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
For Sling Model to be recognized, we use either <Sling-Model-Packages> or Sling Model bnd plugin that I shared in my previous comment
Along with this, package structure that holds the model matters.
If you have both satisfying correct, you should see your model in Sling Adapters console.
Outside this, Export-Package definition will skip the implementation classes. Example if you would have this package - com.company.aem.xyz.core.models in Export-Package entry in <instructions> and if files under this package are both interface and implementation, then this would not be part of Exported-Packages (as you view the bundle in Felix console)
Also, I couldn't get your point - "If I check the bundle Manifest Header, I could see all the packages listed in "Export-Package" section" in your latest comment.
Try the following :
In core/pom.xml file, let the <Sling-Model-Packages> be this - com.company.project.xyz.core.models or use Sling Model bnd plugin
You need not have explicit Export-Package entry in instructions.
Note : If any other classes are using your model, remove all trace of it. Example I see com.company.project.xyz.core.util is using your model.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies