11/16/15

Enable Javascript debugging in Alfresco Community


Hi Readers,

If you work on developing alfresco community then this tutorial may come very useful for you.

By enabling javascript debugging in alfresco community you can debug your custom written javascript and web scripts right inside the browser.

If you have installed alfresco the you will see option to enable javascript debugging on page

http://localhost:8080/alfresco/service/index

But clicking on enable button page will show you the following error

500 - Internal Error

In the relevant log, you’ll also see a message along these lines:

Caused by java.awt.HeadlessException at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159) ...


Here are the steps you need to follow to enable javascript debugging in alfresco community

Step 1 :- make changes to setenv.sh file

Go to alfresco -> tomcat -> bin and open setenv.sh file.
delete only headless=true

Step 2:- restart alfresco

from terminal follow
> sh alfresco.sh stop
> sh alfresco.sh start

Step 3:- goto this url

open url in your browser.

http://localhost:8080/alfresco/s/api/javascript/debugger
http://localhost:8080/share/page/api/javascript/debugger

It will ask you to login as admin. And in next screen click on Enable button.

Step 4:-

A java based application will start running. This will look as per given screen



Step 5:- open js file for debugging

Goto File -> Open and choose file inside alfresco that you want to debug. And apply break point as per your choice. You can apply/remove break point by clicking.

Step 6:- Call that logic that uses that js file.

This may be your web script. So call it.
You will see script will run and stop at your break point.

This is how you can use javascript debugging inside alfresco community.
Please are this and also put your words in comments.