Developing with CRXDE

You are reading the CRX 2.3 version of Developing with CRXDE.
This documentation is also available for the following versions: CRX 2.2  CRX 2.1  CRX 2.0 (for CQ 5.3) 

This section describes how to develop your JCR, Apache Sling or CQ5 application with CRXDE.

Please refer to the overview documentation for more information on the different development environments that are available.

CRXDE is a pre-packaged stand-alone Eclipse application. CRXDE is custom-built specifically for CQ and CRX and thus enables you to efficiently develop your project. CRXDE gives you a broad set of tools to easily create a project, create and manage files, folders, templates, components, dialogs, nodes, properties, scripts and bundles while logging, debugging and integrating with SVN. CRXDE is built on the Eclipse Rich Client Platform (RCP), leveraging the Eclipse File System (EFS) API.

CRXDE is recommended when you develop complex applications by creating new components and Java bundles.

Getting Started with CRXDE

To get started with CRXDE, do the following:

  1. Install CQ/AEM or CRX.

  2. Download CRXDE:

    Operating System

    Flavour

    Download Link

    Microsoft Windows

    32bit

    crxde-1.0.1.win32.win32.x86.zip

    Microsoft Windows

    64bit

    crxde-1.0.1.win32.win32.x86_64.zip

    Apple Mac OS X 10.4 - 10.5

    Carbon 32bit

    crxde-1.0.1.macosx.carbon.x86.zip

    Apple Mac OS X 10.5+

    Cocoa 32bit

    crxde-1.0.1.macosx.cocoa.x86.zip

    Apple Mac OS X 10.6+

    Cocoa 64bit

    crxde-1.0.1.macosx.cocoa.x86_64.zip

    Linux

    GTK+/Gnome 32bit

    crxde-1.0.1.linux.gtk.x86.zip

    Linux

    GTK+/Gnome 64bit

    crxde-1.0.1.linux.gtk.x86_64.zip

    Linux

    Motif

    crxde-1.0.1.linux.motif.x86.zip

  3. Extract the package.

  4. Double-click the executable.

  5. Enter the location of your CQ/AEM or CRX installation. By default it is:

    • http://localhost:4502/ for CQ/AEM Quickstart
    • http://localhost:7402/ for CRX Quickstart
  6. Enter your username and password. By default it is admin and admin.

  7. Click OK.

    Note

    If your installation uses non-standard contexts for CRX web applications, e.g., when you deployed CRX to an application server in such a way, you need to do the following:

    • In case CRX Launchpad web application is installed under another context (e.g., /launchpad instead of /), you need to login to this URL
      • http://<host>:<port>/launchpad
    • In case CRX web application is installed under another context (e.g., /daycrx instead of /crx), you need to configure the CRX server endpoint to use this context (/daycrx/server)

    You can now use CRXDE to develop your application.

    By default, CRXDE does not need to be configured. For advanced use cases, CRXDE offers advanced options to change the CRX server endpoint.

Supported Products

CRXDE supports the following Day products:

  • CRX repository
  • CQ5 suite of content management products; CQ5 is based on CRX repository
CRXDE release by default supports at least the latest version of CRX, and the CQ5 product which is based on that repository version. Please see CRXDE compatibility for information about compatibility of CRXDE with earlier product releases.

CRXDE Features

CRXDE seamlessly offers on-the-fly mapping of a JCR 2.0 repository made of nodes and properties to an Eclipse representation as files and folders, and "nodes" and their metadata. The underlying technology is based on FileVault, DavEx remoting and the Eclipse framework.

CRXDE provides the Integrated Development Environment functionalities and features offered by its underlying Eclipse platform. These include editing of source code, code completion and restructuring, searching and browsing, and many others.

Additionally, CRXDE provides extended support for CRX and CQ5 specific development tasks. This functionality is described in the following subsections.

Creating a Project

With CRXDE you can create a working project in three clicks. The project wizard creates a new project under /apps, some content under /content and a package wrapping all the project the content under /etc/packages. The project can be used right away to render a sample page displaying Hello World, based on a jsp script that renders a property from the repository and calls a Java class to render some text.

To create a project with CRXDE:

  1. In CRXDE, in the Navigator tab, right-click a folder, select Build, then Create Project ....
    Note: you can right-click any folder in the tree navigation, as the new project nodes are, by design, created below /apps, /content and /etc/packages.
  2. Define:
    • Project Name - the project name is used to create the new nodes and the bundle, e.g. myproject.
    • Java Package - the Java package name prefix, e.g. com.mycompany.
  3. Click OK.

To access the sample page displaying Hello World, point your browser to:

http://localhost:4502/content/<project-name>.html

The Hello World page is based on a content node, that calls a jsp script through the sling:resourceType property. The script reads the jcr:title property from the repository and gets the body content by calling a method of the SampleUtil class, that is available in the project bundle.

The following nodes are created:

  • /apps/<project-name>: the application container.
  • /apps/<project-name>/components: the components container, containing the sample html.jsp file, used to render a page.
  • /apps/<project-name>/src: the bundles container, containing a sample project bundle.
  • /apps/<project-name>/install: the compiled bundles container, containing the compiled sample project bundle.
  • /content/<project-name>: the content container.
  • /etc/packages/<java-suffix>/<project-name>.zip, a package wrapping all the project app and content. You can use it to rebuild the project for further deployment (e.g. to other environments) or for sharing through Package Share.

Creating a Folder

To create a folder with CRXDE:

  1. In CRXDE, in the Navigator tab, right-click the folder under which you want to create the new folder, select New, then Folder.
  2. Enter the Folder name and click Finish.

Creating a Template

To create a template with CRXDE:

  1. In CRXDE, in the Navigator tab, right-click the folder where you want to create the template, select New, then Template.
  2. Enter the Label, Title, Description, Resource Type and Ranking of the template. Click Finish.

It creates:

  • A node of type cq:Template with Template properties
  • A child node of type cq:PageContent with Page Content properties

You can drag and drop a thumbnail from your file system into the template folder.

You can add properties to your template: refer to the Creating a Property section.

Creating a Component

To create a component with CRXDE:

  1. In CRXDE, in the Navigator tab, right-click the folder where you want to create the component, select New, then Component.
  2. Enter the Label, Title, Description, Super Resource Type and Group of the component. Click Next.
  3. If needed, set values for the optional properties Allowed Parents, Allowed Children and check the box Is Container. Click Finish.

It creates:

  • A node of type cq:Component
  • Component Properties
  • A component .jsp script

Creating a Dialog

To create a dialog with CRXDE:

  1. In CRXDE, in the Navigator tab, right-click the component where you want to create the dialog, select New, then Dialog.
  2. Enter the Name and the Title. Click Finish.

It creates a dialog with the following structure:

dialog[cq:Dialog]/items[cq:TabPanel]/items[cq:WidgetCollection]/tab1[cq:Panel]

You can now adapt the dialog to your needs by modifying properties or creating new nodes.

Creating a Node

To create a node with CRXDE:

  1. In CRXDE, in the Navigator tab, right-click the node where you want to contain the new node, select New, then Node.
  2. Enter the Name and the Type. Click Finish.

You can now adapt the node to your needs by modifying properties or creating new nodes.

Creating a Property

To create a property with CRXDE:

  1. In CRXDE, in the Navigator tab, right-click the node where you want to add the new property, select New, then Property.
  2. Enter the Name, the Type and the Value. Click Finish.

You can also edit properties and add new ones in the Properties tab.

Creating a Script

To create a new script:

  1. In CRXDE, in the Navigator tab, right-click the component where you want to create the script, select New, then JSP.
  2. Enter the File name. Click Next.
  3. Select the JSP Template and click Finish.
    The new file opens in the main tab.

You can use the following key combinations for code completion:

  • Ctrl + Space on Windows
  • Cmd + Space on Mac

Importing Files and Folders into the Repository

To import a file or a folder from your file system into the repository with CRXDE:

  1. In your file explorer copy the file (or the folder).
  2. In CRXDE, navigate to the location that will contain the file (or the folder). Right-click and select Paste.

The files are mapped to nodes of type nt:file and the folders to nodes of type nt:folder.

You can also drag and drop the file (or the folder) directly into CRXDE.

Creating and Compiling Java Classes

With CRXDE, you can easily create and compile individual Java classes.

To create a Java class, select a folder where you want to place the new class. Usually, it is a part of an existing Java package (e.g., com/example/mypackage). Right-click the folder, select New, then Class. Fill out the Eclipse dialog providing information about your class, and click Finish. Your class is created, and its skeleton source file displayed in the editor.

Once you add source code to your class, you can easily compile it. Right-click the class source file in Navigator, select Build, then Compile. Your class will be compiled and automatically deployed into CRX OSGi container. In case of compilation problems, you will see the status in the Remote Build view.

Managing a Bundle

With CRXDE, it is straightforward to create an OSGI bundle, add Javaclasses to it, and build it. The bundle is then automatically installed and started in the OSGI container.

This section describes how to create a Test bundle with a HelloWorld Java class that displays Hello World! in your browser when the resource is requested.

Creating a Bundle

To create the Test Bundle with CRXDE:

  1. In CRXDE create myapp project with the project wizard. Among others the following nodes are created:
    • /apps/myapp/src
    • /apps/myapp/install
  2. Right-click the folder /apps/myapp/src that will contain the Test bundle, select Build, then Create Bundle ....
  3. Enter the following values for the bundle properties:
    • Symbolic Bundle Name: com.mycompany.test.TestBundle
    • Bundle Name: Test Bundle
    • Bundle Description: This is my Test Bundle
    • Package: com.mycompany.test
    Click Finish.

The wizard creates the following elements:

  • The node com.mycompany.test.TestBundle of type nt:folder. It is the bundle container node.
  • The file com.mycompany.test.TestBundle.bnd.  It acts as deployment descriptor for your bundle and consists of a set of headers.
  • The folder structures:
    • src/main/java/com/mycompany/test. It will contain the packages and the Java classes.
    • src/main/resources. It will contain the resources used within the bundle.
  • The Activator.java file. It is the optional listener class to be notified of bundle start and stop events.

The following table lists all the properties of the .bnd file, their values and descriptions:

Property Value Description
Export-Package: * The Export-Package header defines exported packages for the bundle (comma-separated list of packages)
Import-Package: * The Import-Package header defines imported packages for the bundle (comma-separated list of packages)
Private-Package: * The Private-Package header defines private packages for the bundle (comma-separated list of packages)
Bundle-Name: Test Bundle Defines a short, human-readable name for the bundle
Bundle-Description: This is my Test Bundle Defines a short, human-readable description for the bundle
Bundle-SymbolicName: com.mycompany.test.TestBundle Specifies a unique, non-localizable name for the bundle
Bundle-Version: 1.0.0-SNAPSHOT Specifies the version of the bundle
Bundle-Activator: com.mycompany.test.Activator Specifies the name of the optional listener class to be notified of bundle start and stop events

For more information on the bnd format, refer to the bnd utility used by CRXDE to create OSGI bundles.

Creating a Java Class

To create the HelloWorld Java class within the Test Bundle:

  1. In CRXDE, in the Navigator tab, navigate to /apps/myapp/src/com.mycompany.test.TestBundle/src/main/java. Right-click it, select New, then Class.
  2. Set HelloWorld as Name. Click Finish.
    The HelloWorld.java file is created beside Activator.java and displays following code in the main pane:
    package com.mycompany.test;

    public class HelloWorld {

    }
  3. Add the following lines into the body of the HelloWorld class:
        public String getString(){
        return "Hello World!";
        }
    Save the changes.

Building a Bundle

To build the Test Bundle:

  1. In CRXDE, in the Navigator tab, right-click the .bnd file and select Build Bundle.

The Build Bundle wizard:

  • Compiles the Java classes.
  • Creates the .jar file containing the compiled Java classes and the resources and places it into the myapp/install folder.
  • Installs and starts the bundle in the OSGI container.

To see the effect of the Test Bundle, create a component that uses the Java method HelloWorld.getString() and a resource that is rendered by this component:

  1. Create the component mycomp under myapp/components.
  2. Edit mycomp.jsp and replace the code with the following lines:
    <%@ page import="com.mycompany.test.HelloWorld"%><%
    %><%@ include file="/libs/foundation/global.jsp"%><%
    %><% HelloWorld hello = new HelloWorld();%><%
    %>
    <html>
    <body>
    <b><%= hello.getString() %></b><br>
    </body>
    </html>
  3. Save the changes.
  4. Create the resource test_node of type nt:unstructured under /content.
  5. For test_node, create the following property: Name = sling:resourceType, Type = String, Value = myapp/components/mycomp.
  6. In your browser, request test_node: http://<hostname>:<port>/content/test_node.html.
  7. A page is displayed with Hello World! in bold.

Logging

In CRXDE you can display the file error.log that is located on the file system at <crx-install-dir>/crx-quickstart/server/logs and filter it with the appropriate log level. Proceed as follows:

  1. In CRXDE, in the Console tab at the bottom of the window, click the arrow beside the Display Selected Console icon and select CQ.
  2. In the drop-down menu, set the log level. It can be one of the following values: trace, debug, info, warn or error.
    The error.log is filtered according to the log level and displayed in the tab.

Debugging

To debug with CRXDE:

  1. Stop the CRX server.
  2. Start the CRX server in debug mode: on the command line, change to the directory <crx-quickstart> and enter the following command:
    java -debug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=30303 -jar <quickstart-name>.jar
    Note: you can also enter the following command: server/start -d
  3. In CRXDE, in the top menu bar, select Debug, then Attach Debugger.
  4. As port number, enter 30303 (as defined as the address argument of the Xrunjdwp option). Click OK.
  5. The Debug Perspective is displayed. You can now set breakpoints in the .jsp and .java files.

To switch back to the standard perspective, use cmd + F8 or terminate the debug session by using the Disconnect button in the Debug view.

Note

When Quickstart forks a new process it does not start the JVM with the debug options. You can prevent forking by specifying the -nofork command line option.

Troubleshooting CRXDE

CRXDE stopped working

Remove the .crxde folder from your home folder.

Note: on Windows the .crxde folder is under c:\documents and settings\<YOUR_USER_NAME>.

Integrating with SVN

CRXDE and CRXDE Lite include integration with Apache Subversion (SVN), which allows developers to create a Subversion working copy inside their CRX repository without having to synchronize the file system as an intermediate step.

With SVN integration, you can do the following:

  • Check out of an existing CQ5 project from SVN into content subtree.
  • Modify a resource like a script and check it back into the SVN repository.

SVN integration has been designed with those use cases in mind where ease of use and simplicity is more important than complex development and processes. Any additional svn functionality is available via the CRX/CQ5 FileVault command-line tool vlt and stand-alone Subversion clients. (For example, use one of these tools to initially import the content into the SVN server.)

Note

SVN support is implemented on the server-side (crxde-support bundle) and is used by CRXDE and CRXDE Lite. The implementation is using SVNKit 1.3.0 which according to [1] should be compatible with SVN 1.6.

[1] http://svn.svnkit.com/repos/svnkit/branches/1.3.x-ca/changelog.txt

Intended Use Cases

With SVN integration, you can perform troubleshooting, performance tuning, quick fixes, and prototyping without external tools, and maintain the source code control at the same time.

In a single-developer project or small, agile teams, where a full project setup is not possible or too costly, but there is a requirement to keep code changes under version control, the CRXDE family of tools provides a simpler alternative to source code control using external tools and intermediate, manually managed working copy in the filesytem.

Typical, intended usage of SVN integration in the CRXDE family of development environments is as follows:

  1. A developer checks out an existing content application/project from SVN into content in his or her personal development repository; the command line vlt tool and svn client can be used for importing an unversioned content project into SVN. (Unversioned content can also be imported directly from a repository to SVN with the import operation.)
  2. The developer performs basic development tasks (changes source code in Java bundles or scripts, and so on) then tests the changes locally.
  3. The developer checks in the changed content back to the SVN repository.
  4. The developer checks the status of the content working copy and updates the local source code (content) with changes from other developers (changes from SVN), then repeats the cycle.

SVN Integration Features/Design Implications

The focus on simple usage resulted in a few design decisions, which are important to understand before using SVN integration:

Local, single user content repository instance

The integration has been designed to work with a local content repository (CRX or CQ5 instance), used by a single developer. Multiple users connecting to the same content repository instance (development instance) and using SVN integration on the same content is not supported.

Implicit SVN operations

Certain SVN operations are done implicitly, for example, nodes added to the content tree under source control are automatically added and committed to SVN when checking in (same for deletions).

SVN status on JCR nodes

The integration is based on many-to-one mapping between JCR nodes and FileVault representation thereof. This intermediate representation, based on files and folders, is then synchronized one-to-one with Subversion. SVN status is shown for individual repository nodes, and is mapped from "real" SVN status on FileVault files (for example, .content.xml representing potentially many nodes).

Conflict resolution

There is very limited support for SVN conflict resolution, so it is recommended to do frequent updates and short update-commit cycles.

Where more explicit control over SVN operations or full support for distributed development in larger teams is required, the integration based on stand-alone FileVault vlt client and Subversion client can be used (such as this project setup based on FileVault, Eclipse, Subversion, and Maven).

Using SVN Integration

With CRXDE you can perform the following operations through the tree context menu (Version Control):

  • Import into SVN (initial checkout)
  • Check out from SVN
  • Export from SVN
  • Update from SVN
  • Commit to SVN
  • View the SVN status

The following image illustrates the Version Control context menu:

file

Importing the CRX repository into SVN

Importing allows you to put a project under version control that was initially created with CRXDE (rather than in SVN). Use this command to initially check out content to SVN.

To import the CRX repository into SVN:

  1. In CRXDE, in the Navigator tab, right-click the folder that you want to import into SVN, select Version Control, and then Import.

    file
  2. Enter the URL, User Name, Password, Path, and optionally a Message. Click OK. The files are imported into SVN.

Checking out from the SVN server

To check out from SVN:

  1. In CRXDE, in the Navigator tab, right-click the folder that you want to contain the checkout in, and select Version Control, then Checkout.

    file
  2. Enter the URL, User Name, Password, and Path. Click OK. The files are checked out from SVN into the desired location.

Exporting from the SVN server

Exporting from the SVN is similar to checking out except that this action does not create a working copy.

  1. In CRXDE, in the Navigator tab, right-click the folder that you want to export, select Version Control and then Export.

    file
  2. Enter the URL, User Name, Password, and Path. Click OK. The files are exported from SVN into the desired location without version control.

Committing to SVN

When you create or modify a file or a folder that is under version control, it is automatically added to the version control.

To commit a change:

  1. In CRXDE, in the Navigator tab, right-click the folder that you want to commit, select Version Control, and then Commit.

    file
  2.  Enter a message and click OK. Your changes are committed.

Updating from SVN

To update a file or folder from SVN:

  1. In CRXDE, in the Navigator tab, right-click the file or the folder that you want to update, select Version Control and then Update.

  2. If not already logged in, you are prompted for a user name and password. Click OK. CRXDE updates the file or folder.

Viewing the SVN status

You can view the SVN status, either by looking at the icons on the nodes in the Navigator tab or by doing the following:

  1. In CRXDE, in the Navigator tab, right-click the file or the folder under version control, select Version Control and then Status.

  2. View the SVN status in the Console tab.

CRXDE Compatibility

CRXDE 1.0 supports the following product versions.

CRXDE supports this version out of the box.

CQ 5.3

CQ 5.3 is based on the CRX 2.0 release (only released as a part of CQ 5.3). To ensure compatibility of CRXDE 1.0 with CQ 5.3, the CRXDE Support module from CRX 2.1 release should be installed into CQ 5.3.

To use CRXDE with this release, you have two options outlined in the following subsections.

CQ 5.3 with CRXDE Support Package Upgraded to Version 2.1

To upgrade the CRXDE Support package in your CQ 5.3 instance to version 2.1 you have to obtain the upgrade package and install it into your CQ 5.3. There are two ways of obtaining the package.

Download from Package Share (recommended). The CRXDE Support package is available on Day Package Share, in the section Public » Day » CQ 5.3.0 » upgrade. The package is called cq53-update-crxdesupport. To install it:

  • Go to Packages in your CQ 5.3 instance
  • Select Package Share
  • Log in to Package Share using your day.com user account
  • Navigate to the Public » Day » CQ 5.3.0 » upgrade section
  • Click Download for cq53-update-crxdesupport-2.1.0.zip
  • After downloading, the button changes to Downloaded; click this and the CQ5 Package Manager will open
  • Install the package

Extract the updated components from CRX 2.1 quickstart jar file. If you don't have access to the Package Share from your instance, you can also get all the required components from a CRX 2.1 quickstart jar file. Please follow these steps:

  • Extract the CRX support package from the CRX 2.1 quickstart jar file:
    • unpack the CRX 2.1 quickstart file in an empty folder:
      java -jar crx-2.1.0.20100426-<edition>.jar -unpack
    • in the folder where you unpacked CRX 2.1, unzip the initial content file:
          crx-quickstart/repository/install/crx-initial-content-2.1.0.zip
    • using the CRX Package Manager upload and install the CRX 2.1 crxde-support package from the unpacked zip file:
          jcr_root/etc/packages/day/crx210/product/crxde-support.zip
  • Then install additional packages:
    • navigate to the extracted crx-initial-content-2.1.0
    • navigate to jcr_root/libs/sling/install
    • upload the following jars to /libs/sling/install (e.g. using WebDAV):
      • org.apache.sling.commons.auth-0.9.0-R925144.jar
      • crx-auth-token-2.1.0.jar

After upgrading the CRXDE Support package, restart the instance. Start CRXDE and connect to the instance to check, whether the tool works correctly. Pay special attention to checking, if you can execute server-side functionalities (like bundle compilation, product creation, CRXDE operations).

After you have successfully installed the upgrade and tested your instance, your CQ 5.3 is ready for developing with CRXDE.

CQ 5.3 with CRX Repository Upgraded to Version 2.1

Please see Upgrading CQ 5.3 to CRX 2.1 for upgrade instructions.The procedure includes the required update of the CRXDE support package to version 2.1.

After you have successfully upgraded and tested your instance, your CQ 5.3 is ready for developing with CRXDE.