Posts in Category "CQ"

CQ5.5: NullPointerException trying to reference an OSGi component/service using SCR annotations

Issue

If you are trying to reference an OSGi service or component using the SCR annotations, like the SlingRepository in the code below, then you may encounter a NullPointerException when you try to use these objects.

 /**
  * @scr.component immediate="true"
  * @scr.service interface="SampleService"
  */
 public class SampleServiceImpl implements SampleService {
     /**
      * @scr.reference
      */
     private SlingRepository repository;
...

Another symptom of this problem is that your SampleService component may not show up or register correctly in the CQ5 Web Console “components” tab (http://<server>:<port>/system/console/components).

Reason

The SCR annotations are deprecated in the latest builds of Apache Felix.

You should note that CRXDE and CRXDE Lite are both configured to automatically resolve these annotations and build the relevant XML files for you.  In other IDE environments you will have to include the maven-scr-plugin to resolve these annotations and build the XML files yourself.

Solution

To correctly reference these objects in the latest versions you should use the following syntax (note: you will have to explicitly import the Felix scr classes):

 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.felix.scr.annotations.Reference;

 @Component(immediate="true")
 @Service(interface="SampleService")

 public class SampleServiceImpl implements SampleService {

     @Reference
     private SlingRepository repository;
...
VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 5.0/10 (2 votes cast)

CQ5: preview mode in sidekick does not refresh automatically

Issue

If you are using the sidekick to switch between edit, design and preview modes, you may notice that the pages refreshes automatically when switching to edit and design mode, but not when switching to preview mode.

This can cause problems if you are using the WCMMode methods and properties in your application to display a different page view depending on the current mode (i.e. using conditional logic based on WCMMode.DESIGN, WCMMode.EDIT and WCMMode.PREVIEW).  If the page does not refresh when switching to preview mode, then it will display the same objects and state as it did in edit mode.

Solution

The solution is simply to force a page refresh automatically when switching to preview mode.

  1. Open /libs/wcm/core/components/init/init.jsp
  2. Add the previewReload property as follows and save the changes:
    CQ.WCM.launchSidekick("<%= currentPage.getPath() %>", {
        propsDialog: "<%= dlgPath == null ? "" : dlgPath %>",
        locked: <%= currentPage.isLocked() %>,
        previewReload: "true"
    });
  3. Now CQ is setup to refresh automatically when switching to preview mode.

reference: (32750)

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 8.7/10 (15 votes cast)

CQ: design and preview mode toolbar not visible

Issue

If you are using the sidekick on an author instance of CQ, you may notice that the toolbar at the bottom which includes the design and preview mode buttons, is not visible or available.

Reason

The functionality in the sidekick is determined by the ACLs (Access-Control-Lists) defined in the CQ server.  If you do not have the appropriate privileges then functionality may be hidden in your sidekick.  Sometimes the sidekick may become unstable if you add faulty components to the page, or after you have installed some packages that may have overwritten required objects in your application, breaking some dependencies.

Solution

You should first try to clear your browser cache, and then reload the page from WCM console to refresh the sidekick.

You should also ensure you have the correct privileges to access the appropriate design in /etc/designs.  This can be changed by an administrator on the Users tab in the siteadmin console.  If the privileges appear to be correct, then try to disable them, save, and then re-enable them and save.  The sidekick should now display the toolbar again as expected.

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 8.5/10 (4 votes cast)

CQ5.5: how to start the server in debug mode

Issue

In CQ5.4 you could start the server in debug mode using the [CQ_HOME]/crx-quickstart/server/server.bat file.  The server folder is no longer there in CQ5.5 on Windows.

Solution

To start the server in debug mode you can edit the [CQ_HOME]/crx-quickstart/bin/start.bat file and add the same debug parameters from a server.bat in an existing CQ5.4 installation, or you can use the command line below:

java -Xmx512m -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=30303,suspend=n -jar cq-author-4502.jar

Notes

You may notice that the “Attach Debugger” entry in the CRXDE menu is still disabled even after starting the server in debug mode.  You should analyse the console output on server startup to check for issues related to heap/memory problems which may result in a new process being forked.  The debug options used to start the parent JVM are not passed on to the forked process by default.

You can resolve this by adding more heap to the JVM, and/or by specifying the -nofork command line option to prevent forking.  You can also force the forked process to use the parent JVM parameters by specifying the -forkargs [<arg>…] command line option.

You can find more information on the options mentioned above, and other server startup options under the following link:

http://dev.day.com/docs/en/cq/current/deploying/installing_cq.html#Further%20options%20available%20from%20the%20Quickstart%20file

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 7.7/10 (7 votes cast)

CQ 5.4: how to export the user list as a CSV file

Problem

If you are using CQ 5.4 you will notice that the user report is displayed in the browser and you cannot save/export any of the information in this list.

You can view the user report from the “Tools” console in CQ5.  Select “Reports” in the left-hand pane, then double-click the user report in the right-hand pane to open it for viewing and/or configuration.

Solution

It is possible to export the user report as CSV content. You can do this in 3 steps.

  1. Overlay the /libs/cq/reporting/components/reportpage/ component to /apps/cq/reporting/components/reportpage/.
    For detailed instructions on how to overlay a component watch the following video:
    http://blogs.adobe.com/aaa/2011/11/walkthrough-of-overlaying-or-overriding-a-stock-cq-or-adep-wem-component.html
  2. In /apps/cq/reporting/components/reportpage/body.jsp replace the <body> section with the code in body_code.txt and save the changes.
  3. Navigate to the user report again and now you will see a link at the top to “Export” the content as CSV formatted text. This export function has different behaviour depending on the browser version.

Note: it is important to overlay the reportpage component in “apps”, rather than editing the file in “libs”, as libs is overwritten anytime you install a hotfix or a product update from Adobe, and therefore your changes are lost.  It is a best practice to overlay components to apps, and then you always have a backup of the original component in libs.

reference: (32200)

VN:F [1.9.22_1171]
Was this helpful? Please rate the content.
Rating: 10.0/10 (1 vote cast)