Leiste mit Community-Erfolgen erweitern.

Get ready! An upgraded Experience League Community experience is coming in January.

Mark Solution

Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.

GELÖST

sling context aware configuration context-aware-configuration-bnd-plugin not working as expected

Avatar

Level 3

Hi Everyone,

 

I am trying to use sling context aware configurations inside AEM 6.5 project to store some configurations.

As described here https://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configurati...

 

I have tried adding bnd statement with below plugin

org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin

 But still my bundle is not able to identify configuration files (annotated with @Configuration) after deploying it into OSGI.

And If i manually add like below then only it started identifying 

Sling-ContextAware-Configuration-Classes:com.abc.caconfigs.MySampleConfig

 Could you guys please let me know how can we do it without adding each class names and should make it work with only plugin? .

1 Akzeptierte Lösung

Avatar

Korrekte Antwort von
Employee Advisor

I have a working example at https://github.com/joerghoh/cqdump/tree/master/ca-config-example which also includes the mentioned plugin.

The maven-bundle-plugin is configured here: https://github.com/joerghoh/cqdump/blob/master/ca-config-example/core/pom.xml

 

Jörg

 

// Update: I do use the maven-bundle-plugin and not the bnd-maven-plugin.

Lösung in ursprünglichem Beitrag anzeigen

8 Antworten

Avatar

Korrekte Antwort von
Employee Advisor

I have a working example at https://github.com/joerghoh/cqdump/tree/master/ca-config-example which also includes the mentioned plugin.

The maven-bundle-plugin is configured here: https://github.com/joerghoh/cqdump/blob/master/ca-config-example/core/pom.xml

 

Jörg

 

// Update: I do use the maven-bundle-plugin and not the bnd-maven-plugin.

Avatar

Level 3
Hi, I have seen you added Maven-bnd-plugin. Instead why Can't I achieve this with bnd-maven-plugin as described here https://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configurati...

Avatar

Employee Advisor
As far as I can see both my pom.xml and the referenced documentation use the maven-bundle-plugin.

Avatar

Community Advisor

Did you tried below ?

<plugin>
				<groupId>biz.aQute.bnd</groupId>
				<artifactId>bnd-maven-plugin</artifactId>
<configuration>
					<bnd><![CDATA[
						-plugin org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin
                                ]]></bnd>
				</configuration>
				<executions>
					<execution>
						<id>bnd-process</id>
						<goals>
							<goal>bnd-process</goal>
						</goals>
						<configuration>
							<bnd><![CDATA[
						Bundle-Category: MyApp
						Sling-Model-Packages: com.aem.core.models
						-snapshot: ${tstamp;yyyyMMddHHmmssSSS}
						Bundle-DocURL:
                                ]]></bnd>
						</configuration>
					</execution>
				</executions>
			</plugin>

 

Arun Patidar

AEM LinksLinkedIn

Avatar

Level 1

The below works for me.

 

            <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	
						Sling-Model-Packages: com.aem.core.models
						-snapshot: ${tstamp;yyyyMMddHHmmssSSS}
						Bundle-DocURL:
-plugin org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin
                                ]]></bnd>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

 

Avatar

Community Advisor

Hi @Shakir 

Just make sure you are including ModelScanner as well for Sling Model

 

e.g. https://github.com/arunpatidar02/aemaacs-aemlab/blob/f96ce5316dfa4798c72d2e87d3a0b41fc49791a4/pom.xm...

 

Arun Patidar

AEM LinksLinkedIn

Avatar

Employee

Its not working even though instructions in sling doc are followed, but i figured it out that you need to manually append this line to the bnd-process before the actual ConfigurationClassScannerPlugin in plugin bnd-maven-plugin

 

Sling-ContextAware-Configuration-Classes: 

ca-config-pom.png

Then you generated required headers in the MENIFEST file. At this moment i cannot tell you why, but it works for me.

Avatar

Employee Advisor

I hope, that the order does not matter. But if the documentation is not accurate anymore and the plugin does not work correctly, I would recommend to discuss this at the Sling lists.