Sightly Cannot Find Bundled WCMUsePojo | Community
Skip to main content
Best answer by smacdonald2008

The component cannot find the Java. See this community artilce that will teach you how to setup everything so that Sightly finds the Java: Creating your first Adobe Experience Manager Sightly component.

6 replies

Jitendra_S_Toma
Level 10
December 29, 2015

Hi,

Just to confirm, Are you using Sling Model in developing Sightly component?. If yes, just make sure you have a correct maven project configuration for the Sling model.

For more details:

https://helpx.adobe.com/experience-manager/using/creating-sightly-component.html

Modify the Maven POM file 

Modify the POM files to successfully build the OSGi bundle. In the POM file located at C:\AdobeCQ\model\bundle, add the following dependencies.

  • org.apache.felix.scr
  • org.apache.felix.scr.annotations
  • org.apache.sling.models.api

In the following POM file, notice this plugin element.

https://helpx.adobe.com/experience-manager/using/sling_models.html

---Jitendra

Kunal_Gaba_
December 29, 2015

Have you also verified the OSGI manifest of the bundle that the package "com.t4g.aem.impl.usebeans" is declared to be exported in export-package header ? 

Feike_Visser1
Adobe Employee
Adobe Employee
December 29, 2015

This looks indeed like an issue that you are not "exporting" your package.

smacdonald2008
smacdonald2008Accepted solution
Level 10
January 4, 2016

The component cannot find the Java. See this community artilce that will teach you how to setup everything so that Sightly finds the Java: Creating your first Adobe Experience Manager Sightly component.

TaylorBastien
Level 2
January 14, 2016

Thanks for all your answers.

I'm afraid that tutorial above doesn't solve my issue. but indeed the missing link was that the Java class wasn't visible to OSGi because it wasn't in the bundle manifest.

To correct that, I had to add the details for all of the imported and exported packages to the org.apache.felix:maven-bundle-plugin entry in the bundle projects pom.xml

Here's what my pom entry looks like:

<plugin><groupId>org.apache.felix</groupId><artifactId>maven-bundle-plugin</artifactId><extensions>true</extensions><configuration><instructions><Bundle-SymbolicName>com.us.aem.sightly-stuff-bundle</Bundle-SymbolicName><Export-Package><!-- Let's export our primary package -->com.us.aem.impl.usebeans<!-- By default, don't export any other packages --></Export-Package><Import-Package><!-- JSR 250 && 330 -->javax.annotation;version=0.0.0.1_007_JavaSE,javax.inject,<!-- JEE Servlet -->javax.servlet,javax.servlet.http,<!-- Sling -->org.apache.sling.api,org.apache.sling.api.resource,org.apache.sling.auth.core,org.apache.sling.jcr.api,com.day.cq.commons,org.apache.sling.api.request,com.adobe.cq.sightly,com.day.cq.wcm.api,org.slf4j</Import-Package></instructions></configuration></plugin>

Typically, I use Felix SCR annotations on my classes (e.g. @Component, @Service, @SlingServlet) which allows the SCR Maven plugin to take care of adding my imports and classes to the manifest. In this case, because there are no such annotations on the use bean, so you must to do it by hand. It seems self-evident in retrospect, but it's a step that none of the tutorials out there (including the one linked to in the "solution" above) mention. My compiled class was in the bundle all along but wasn't exposed by the manifest.

Thanks,

 

Taylor

P.S. Before seeing these responses, I got the solution from an answer I kindly received from swathi07 in another thread. Thanks to all who responded.

joerghoh
Adobe Employee
Adobe Employee
January 14, 2016

Hi,

Just a remark: by default all java packages containing the string "impl" are not exported by the bundle plugin. It is best practice not to export the implementation classes but only the interfaces. In the case of Sightly it's different, but then I wouldn't put them into an "impl" package.

Jörg