Pages

Wednesday, December 5, 2012

Running and debugging CQ5 using CRXDE

The Problem

You want to debug your code on a CQ5 server using Breakpoints in CRXDE, but the Debug option is greyed out.

The Solution

Chances are, you are not running CQ5 in debug mode. Here is a simple way to start your CQ5 instance in debug mode, and how to attach CRXDE to it.

Assuming a windows machine and a local copy of CQ5 for the purposes of this tutorial, located at c:\cq5\author running on the default port 4502.

1. Ensure that all local instances of CQ5 are shut down.

2. Under windows. open up command from the start menu, navigate to the c:\cq5\author directory

3. copy and paste the following command:

java -debug -XX:MaxPermSize=256M -Xnoagent -Xmx1024M -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=30303 -jar cq5-author-4502.jar -nofork

4. IMPORTANT: It can take quite a while for the server to start in debug mode. Wait until your browser window opens up at the author login screen before continuing.

5. Open up CRXDE. Search for it in your supplied CQ5 materials.

6. Enter http://localhost:4502 in the URL field, and admin/admin for the username and password.

7. Click on OK, and wait for CRXDE to load.

8. To test, we can navigate to a piece of code that you can break into.

A good place to test is to put a breakpoint on line 31 in /apps/geometrix/components/title/title.jsp

When you have put the breakpoint in, navigate to:
http://localhost:4502/cf#/content/geometrixx/en/products.html

You will now be able to step through your code.

Gotchyas


7 comments:

  1. this was a very helpful tip was having a hard time starting DEBUG.

    ReplyDelete
  2. Glad to hear it helped you guys out.

    ReplyDelete
  3. You can use a similar process to put a breakpoint into a jsp file, however, you will need to keep in mind that you won't get the ide to display the break. You will need to use the inspector to keep an eye on variables, and go by line number. (Which possibly won't make much sense).

    A trick to use, is to sprinkle some variable definitions into the code, such as int stage1=1, int stage2=2 etc, so that you can get used to debugging with half of the tools. Just remember to take these out afterwards, and not check them into your repository.

    ReplyDelete
  4. Can you please explain a bit about the forking process when CQ is started in debug mode?

    ReplyDelete
  5. How to put breakpoint in title.jsp

    ReplyDelete