Configuring CQ 56 war on Tomcat and run it from Intellij IDEA

Goal


This post is for people who do not like opening too many windows while coding. To run AEM (CQ) instance the general approach followed by developers is, double click the CQ quickstart jar or open a command prompt window and run the jar using "java" command. In both cases a new window opens and you obviously will have your IDE ( Eclipse or Intellij ) open for coding. So,

1) A CQ run window
2) Eclipse or Intellij IDEA IDE application window
3) Browser to test your application

The intention of this post is to get rid of CQ window and run the application from your IDE; also explains the CQ configuration on Tomcat


Install and Configure


1) Download & Install IntelliJ IDEA 12; Download Tomcat 7 zip and expand it to a directory, say C:\dev\code\install\apache-tomcat-7.0.42

2) Open C:\dev\code\install\apache-tomcat-7.0.42\bin\catalina.bat and add enough memory

                       set JAVA_OPTS=-Xmx1792m -XX:MaxPermSize=512m

3) Open C:\dev\code\install\apache-tomcat-7.0.42\conf\server.xml and change the http connector port from 8080 to CQ author instance default port 4502

4) Delete ROOT war from C:\dev\code\install\apache-tomcat-7.0.42\webapps to deploy CQ war as the root application

5) Copy cq-quickstart-5.6.0-20130125.war to C:\dev\code\install\apache-tomcat-7.0.42\webapps

6) Rename cq-quickstart-5.6.0-20130125.war to ROOT.war

7) Create the CRX folder C:\dev\code\install\apache-tomcat-7.0.42\crx-quickstart. This is the location of your JCR repository created by CQ

8) Using WinZIP or WinRAR, extract the file web.xml in ROOT.war (ROOT.war\WEB-INF\web.xml) onto the filesystem.Open extracted web.xml in a text editor and change init-param sling.home from crx-quickstart to C:/dev/code/install/apache-tomcat-7.0.42/crx-quickstart

        <init-param>
        <param-name>sling.home</param-name>
        <param-value>C:/dev/code/install/apache-tomcat-7.0.42/crx-quickstart</param-value>
        </init-param>

9) Open cmd prompt at C:\dev\code\install\apache-tomcat-7.0.42\bin and start server using the command "catalina run". Just to make sure everything is alright, this is the first and last time we'll be doing it

10) Check the folder C:\dev\code\install\apache-tomcat-7.0.42\crx-quickstart and the following folders should have be created

             launchpad
             logs
             repository

11) It may take 3-4 minutes first time, for the server to start and get to a running state, wait and check the log C:\dev\code\install\apache-tomcat-7.0.42\crx-quickstart\logs\error.log to see if all services are starting up properly

12) Open a browser window and type http://localhost:4502 and it should redirect to http://localhost:8080/system/granite/license/index.html for license information. If you have license.properties get the customer name and license key from file, and enter in the form

13) Check http://localhost:4502/system/console/bundles and http://localhost:4502/crx/de to see if everything is ok ( user/pass : admin/admin )


Starting Tomcat from IntelliJ IDEA


1) Shutdown the tomcat started in section above

2) In your Intellij 12, open Run -> Edit Configurations

3) Click "+" and add Tomcat Server -> Local

4) Enter the following information in "Server" tab

                 Name: Tomcat 7
                 Application Server: Click configure and select the Tomcat Home (C:\dev\code\install\apache-tomcat-7.0.42)
                 Startup page: http://localhost:4502/
                 Http Port: 4502

5) Click on tab "Deployment", click "+" -> "External Source" and select the CQ ROOT.war. So, when tomcat is started the ROOT war (CQ) is deployed

6) Click on tab "Startup/Connection". Developers generally start the server in debug mode, so select "Debug" and add necessary settings or just select default settings and click ok.

7) Start the server from your IDE by clicking on Run -> Debug 'Tomcat 7' and you should see the ROOT war being deployed in server startup messages




12 comments:

  1. Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for me.I get a lot of great information from this blog. Thank you for your sharing this informative blog.Adobe CQ5 Training | Adobe CQ5 Online Training

    ReplyDelete
  2. Hi Sreekanth It was really nice article would you please provide us the steps on how to Configuring CQ 56 war on Tomcat and run it from eclipse IDE.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
  7. Thank you! very nice, clear and helpul post. keep posting more articles.TSM Training

    ReplyDelete
  8. Thank you,so thank of this tutorial! Hope you have more the lession like this!AWS Training
    Thank agains!

    ReplyDelete
  9. Your blog is so comprehensive...Almost everything at one place...You have that real PASSION...!
    Thanks a ton..!!! DevOps Training

    ReplyDelete
  10. One of the biggest challenges that organizations face today is having inaccurate data and being unresponsive to the needs of the Adobe CQ5 CMS Email List organization.

    ReplyDelete

  11. It fun to have a content like this really worth to read it
    Pega Online Training |
    Pega Training

    ReplyDelete