JcrProperty Always NULL - AEM 6.1/Slice 4.2

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

JcrProperty Always NULL - AEM 6.1/Slice 4.2

phil@siteworx.com
We are using AEM 6.1 and Slice 4.2. We have all dependencies added to the pom including the AEM add-on, Activator created, and registered, and everything builds successfully. No errors in logs or Felix console.

We have a TestModel class set up with the SliceResource and JcrProperty annotations for a simple text field and a Sightly component to output it to the page.

When we load the page in the browser the annotated property always returns NULL even though we have verified it exists and is not empty in the CRX. Below are the values in our Activator:

INJECTOR_NAME = "testapp";
In the CRX our app is here "/apps/testapp".

BUNDLE_NAME_FILTER = "testapp-aem-bundle.*";
In the bundle pom.xml we have a Bundle-SymbolicName set as "testapp-aem-bundle". Is this correct or does the name need to come from the content package name (testapp-aem-content-1.0.0-SNAPSHOT.zip)?

BASE_PACKAGE = "com.testapp.aem"
This (java) package contains our Activator and TestModel classes.

What else can we try to troubleshoot the issue?
Reply | Threaded
Open this post in threaded view
|

Re: JcrProperty Always NULL - AEM 6.1/Slice 4.2

maciej.majchrzak
Administrator
The first thing which paid my attention is the BUNDLE_NAME_FILTER. Can you try with "testapp-aem-bundle" instead of "testapp-aem-bundle.*"?
Reply | Threaded
Open this post in threaded view
|

Re: JcrProperty Always NULL - AEM 6.1/Slice 4.2

phil@siteworx.com
I'm still getting the same NULL result using "testapp-aem-bundle".

Below is part of our pom where we have specified a bundle name and Activator:

...
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Export-Package>com.testapp.aem.*</Export-Package>
                        <Bundle-Activator>com.testapp.aem.core.Activator</Bundle-Activator>
                        <Bundle-SymbolicName>testapp-aem-bundle</Bundle-SymbolicName>
                    </instructions>
                </configuration>
            </plugin>
...
Reply | Threaded
Open this post in threaded view
|

Re: JcrProperty Always NULL - AEM 6.1/Slice 4.2

phil@siteworx.com
How do I know if the bundle name filter found anything? Is there somewhere I can check in the crx, logs, etc.?
Reply | Threaded
Open this post in threaded view
|

Re: JcrProperty Always NULL - AEM 6.1/Slice 4.2

maciej.majchrzak
Administrator
First, please verify that all the bundles are active. Then you can verify if the models were correctly "registered" by taking a look at the list of Sling adapters (http://localhost:4502/system/console/adapters). For each class annotated with SliceResource, there should be an adapter registered. In your case you should look for TestModel and check if there is an adapter adapting to org.apache.sling.api.resource.Resource.

Please also take a look at our draft version of Slice demo project (https://github.com/Cognifide/Slice-demo/pull/1) - it may be helpful to spot configuration issues.
Reply | Threaded
Open this post in threaded view
|

Re: JcrProperty Always NULL - AEM 6.1/Slice 4.2

phil@siteworx.com
All bundles are active but I do not see my TestModel class listed in the adapters.

I will go through the draft demo project again to see if I missed anything.
Reply | Threaded
Open this post in threaded view
|

Re: JcrProperty Always NULL - AEM 6.1/Slice 4.2

phil@siteworx.com
I don't see any config issues comparing with the demo. I did try to run the demo myself, had to add some dependencies, guice, asm, peaberry, inject, and aopalliance.

Now I have your demo building successfully with all bundles active but still no models showing in the adapters. There are errors on the test homepage (http://localhost:4502/content/slicedemo/en.html). A snippet shown below.

-Phil

------------------------

Error during include of component '/apps/slicedemo/components/content/helloworld'

Error Message:
org.apache.sling.scripting.sightly.SightlyException: Identifier com.cognifide.demo.slice.demo.core.models.HelloWorldModel cannot be correctly instantiated by the Use API

Processing Info:
Page = /content/slicedemo/en
Resource Path = /content/slicedemo/en/jcr:content/par/servicecomponent
Cell = helloworld
Cell Search Path = page/par|parsys/helloworld
Component Path = /apps/slicedemo/components/content/helloworld

Full Exception:
org.apache.sling.scripting.sightly.SightlyException: Identifier com.cognifide.demo.slice.demo.core.models.HelloWorldModel cannot be correctly instantiated by the Use API
        at org.apache.sling.scripting.sightly.impl.engine.extension.use.UseRuntimeExtension.call(UseRuntimeExtension.java:91)
        at org.apache.sling.scripting.sightly.impl.engine.runtime.RenderContextImpl.call(RenderContextImpl.java:89)
        at apps.slicedemo.components.content.helloworld.SightlyJava_helloworld.render(SightlyJava_helloworld.java:38)
        at org.apache.sling.scripting.sightly.impl.engine.runtime.RenderUnit.render(RenderUnit.java:52)
...
Caused by: org.apache.sling.scripting.jsp.jasper.JasperException: /apps/slicedemo/components/content/helloworldJsp/helloworldJsp.jsp(2,2) The absolute uri: http://cognifide.com/jsp/slice cannot be resolved in either web.xml or the jar files deployed with this application
        at org.apache.sling.scripting.jsp.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)


Reply | Threaded
Open this post in threaded view
|

Re: JcrProperty Always NULL - AEM 6.1/Slice 4.2

phil@siteworx.com
Should be seeing Slice bundle here? http://localhost:4502/system/console/bundles

I do not see any, just my app bundle which has all the Slice stuff as embedded dependencies.
Reply | Threaded
Open this post in threaded view
|

Re: JcrProperty Always NULL - AEM 6.1/Slice 4.2

maciej.majchrzak
Administrator
This is it - Slice embedded in you bundle simply won't work. Instead, you need to install Slice on your instance as a separate package - you can find appropriate versions at https://cognifide.atlassian.net/wiki/display/SLICE/Downloads. Please let me know if this helps.

Cheers
Maciej
Reply | Threaded
Open this post in threaded view
|

Re: JcrProperty Always NULL - AEM 6.1/Slice 4.2

phil@siteworx.com
Yes that was it. I have Slice working now in my setup. Thank you for the help.