Sling Models are not working if Model classes are inside subfolders.
See original GitHub issueWith Archtype 20, Maven classes are not getting resolved as type inside model’s subfolders if Sling-Model-Packages: com.myapp.core.models is defined in bnd-maven-plugin e.g. com.myapp.core.models.sub
<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[
Bundle-Category: MyApp
-exportcontents: ${packages;VERSIONED}
Sling-Model-Packages: com.myapp.core.models
-snapshot: ${tstamp;yyyyMMddHHmmssSSS}
Bundle-DocURL:
]]></bnd>
</configuration>
</execution>
</executions>
</plugin>
We get following error, if we use create model inside subfolder: com.myapp.core.models.sub.HelloWorldModel cannot be resolved to a type
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
If your Sling Models are not working.....
You need to have: org.apache.sling.models.api.1-1.0.jar installed in the OSGI console, system/console/bundles.
Read more >Sling Models - Apache Sling
Many Sling projects want to be able to create model objects - POJOs which are automatically mapped from Sling objects, typically resources, ...
Read more >The Distributed Hydrology Soil Vegetation Model (DHSVM)
The model requires spatially distributed input in the form of surface ... file to the directory where you are storing materials for the...
Read more >Files & Folders - Help Website - Web Community Manager
Refreshing a subfolder displays a current view of the Files & Folders window. This can be useful if multiple editors are working in...
Read more >PMP Evaluation Tool Description and Usage
Similar to a shapefile but specific to the ArcGIS environment. Feature classes must be stored within a Geodatabase or Feature. Dataset. 7. Feature...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I dig more into the issue and found that the packages/sub packages apart from default packages are not getting added in Export-Package header in MANIFEST.MF file. All the new packages are getting added in Private-Package header, because of missing package-info.java file in sub/new packages.
To resolve above issue either you can create package-info.java with with version annotation or update core pom to remove VERSIONED filter from -exportcontents.
I’ve added the package-info in my sub folder and it got resolved.