Search code examples
javaaemsightly

AEM 6.1 Sightly very basic example from the docs not working


In the following adobe docs page there is a Sightly Java Use-API example:

http://docs.adobe.com/docs/en/aem/6-1/develop/sightly/use-api-in-java.html

Neither the first one (without Java) nor the second one (with Java) seems to work for me.

As you can see in the CRXDE, for the second example with Java, I have created the info component inside the component folder with its info.html and Info.java files inside, with exactly the same content that you can find in the link.

The JSON file is also in its place, inside content:

enter image description here

However, I get a 404 No resource found error.


Solution

  • You got it wrong. The URL http://localhost:4502/content/my-example.json in the docs meant JSON representation of the node /content/my-example and not the file /content/my-example.json.

    What you should actually be doing is

    1. Create a node with name my-example and type as nt:unstructured under /content.
    2. Add a property sling:resourceType whose value points to your component, i.e., my-example/component/info.
    3. Add properties title and description with some values so that you can read them in your component.

    Now, when you hit http://localhost:4502/content/my-example.json in your browser, you would be able to view the JSON representation of your node as shown in the docs.

    Accessing the same node with html extension (http://localhost:4502/content/my-example.html) would render the output based on the script written within info.html.

    I would suggest, going through the Basics and the Sling Request Processing Mechanism to better understand the above example.