cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript Debugger - Alfresco One on CentOS

beber7
Champ in-the-making
Champ in-the-making
Hi guys,

I'm pretty new in the Alfresco world.
I'm trying to do something simple and I keep hitting blockers. I wonder if I do something wrong or if something is broken. He is the problem description :

Background :
I want to create a Javascript script to perform actions on a document when document enter a certain folder.
I did create my rule for a the folder I wanted to interact with. I did put my JS file in Repository > Data Dictionary > Scripts
But my script doesn't work. No panic, I just need to debug it and here is the problem…

Goal :
Being able to debug this JS script.

What I've tried :
1) going on http://<ADDR>:<PORT>/alfresco/service/api/javascript/debugger and click activate. Then I got an not very helpfull error 500.

Here is the complete message :
<cite>An error has occured in the API: /alfresco/service/api/javascript/debugger.
It responded with a status of 500 - Internal Error.
Error Code Information: 500 - An error inside the HTTP server which prevented it from fulfilling the request.
Error Message: 05030001 Wrapped Exception (with status template): null
Server: Alfresco Enterprise v5.0.1 (.5 r108957-b87) schema 8,022
Time: Jun 3, 2016 8:02:34 AM
Click here to view full technical information on the error.
Exception: org.springframework.extensions.webscripts.WebScriptException - 05030001 Wrapped Exception (with status template): null
org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1126)
</cite>

2) I tried to locate the famous log4j.properties to activate the debug functionnality and have the script writting into my Chrome Console.
I went to  /opt/alfresco-5.0.1.5/tomcat/webapps/alfresco/WEB-INF/classes/log4j.properties
I tried to modify the following properties ( the rest of the file is default )
<cite>- log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug (previously warn)
- log4j.logger.org.alfresco.repo.web.scripts.AlfrescoRhinoScriptDebugger=debug (previously off)</cite>

I get an error 500 on the page, and can't even log in alfresco any more when this configuration apply.
I'm pretty sure I'm doing something wrong since I'm ensure of what I'm doing.

I'm running Alfresco on a CentOS v7.
Also, I'm a little confused with what I'm using… The install path says Alfresco, the URL says Share and on the website footer says ALfresco One.

I'm stuck on this, I read an interesting topic about the same 500 issue, but someone made a batch script for windows to solve it. I also read this debug option might not work on some unix for some version for unknown reasons yet.
If anyone have the solution or have the proper documentation to follow for my specific case, it will be helpful.

Goal summary :
- Have a print in the Browser console ( Or at least in a log file ) of a JS script called on a Rule, triggered when a document is pushed into a folder lacated in my repo.

My script file contain the following log lines :
<javascript>
logger.log("Test OK");
logger.warn("Test warn OK");
</javascript>

PS: I know the script is called, because I get an error when I upload a file if I pushed a broken JS file.

Thanks for reading
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

there are various potential reasons why this is not working. Please check the alfresco.log file for any further logging output that is not reported directly on the page. Server log output will never be written to the Chrome console, so you have to check that file (contents will be restricted/controlled by the log4j.properties).

Potential reasons:
- you run on a headless server - the debugger only supports running on a host which has a graphical interface associated with it
- you run the server on a different user account - the debugger will start its UI in the current process, which means for the user that is executing the Alfresco Tomcat instance / daemon. If that user account is different from yours, you will not set the UI popup. If that user account has no associated screen, than the attempt to open the UI may fail.
- your JDK / JRE somehow does not support the debugger UI - this I find rather improbable, since the UI technology being used is part of JVM core libraries

Regards
Axel

beber7
Champ in-the-making
Champ in-the-making
Hi AFaust,

Thank you so much !
Seems my problem is I'm on a headless server. I checked the alfresco.log file and can see my logs and breaking errors. The configuration of the Log4j did allow my trace in alfresco.log.
You made it so much more clear, thank you again.
I now can debug this script.

Thank you again,