cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript debugger when running as a Windows Service

ghernando
Champ in-the-making
Champ in-the-making
I'm using Community 3.4 release and I'm not sure how to bring up the debugger for server side investigation.
I've used it before, but with version 3.4, Alfresco is installed as a Windows Service rather than an app that I can start from the command line.
I'm not sure that's the problem, but that is different from what I've done in the past.

I set the flags in the log4j.properties file:

log4j.logger.org.springframework.extensions.webscripts.ScriptDebugger
and
log4j.logger.org.alfresco.repo.web.scripts.AlfrescoRhinoScriptDebugger

But on restart there is no debugger window.
When I go to http://localhost:8080/share/page/api/javascript/debugger, it says that the debugger is enabled.  I toggle it there off and then on again, but there is no window to debug with.
How can I get the debugger?
5 REPLIES 5

cmcmillen1
Champ in-the-making
Champ in-the-making
I was having the same issue and ended up getting the debugger to work by stopping the service and running it from the command line.

Specifically,
1. Log into machine from which alfresco is running (debugger does not work remotely)
2. Stop alfresco service
3. Run [ALFRESCO_HOME]\tomcat\bin\startup.bat
4. Go to http://[ALFRESCO_DOMAIN]/alfresco/service/ using browser on same machine that alfresco is running on
5. Click Refresh Web Scripts
6. Click List Web Scripts
7. Click Alfresco Javascript Debugger
8. Click Enable
9. You should see a standalone java app pop up entitled "Alfresco web-tier JavaScript Debugger"
10. Now just run a webscript and you should see the javascript controller in the debugger window

Also, the first time I tried to run startup.bat from the command line I got a permgen exception. Adding
set "JAVA_OPTS=-Xms256m -Xmx256m -XX:PermSize=256m -XX:MaxPermSize=256m"
to startup.bat just above the line with
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
solved it.

Lastly, for me, the debugger only works for one webscript execution. I have to disable then enable the debugger between consecutive executions.

michalwrobel
Champ on-the-rise
Champ on-the-rise
What version of windows do you have? I'm not successful with running javascript debugger.. I have windows 7 64 bit. Enabling the debugger results in:

at java.lang.Thread.run(Thread.java:619)
aused by: java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHGadlGss(GraphicsEnvironment.java:1
at java.awt.Window.<init>(Window.java:432)
at java.awt.Frame.<init>(Frame.java:403)
at javax.swing.JFrame.cinit>(3Frame.java:202)
at org.mozilla.javascript.tools.debugger.SwingGui.cinit>(SwingGui.java:1

I start manually by using catalina start, so windows services limitation is not the case.

Did anyone achieve success in running javascript debugger on win7 64 bit?

martinn
Champ in-the-making
Champ in-the-making
Yes, I got it runnig doing the following steps im my Alfresco version 3.4d running on Windows 7 Enterprise 64.bit:

1. Debugger will not start if Alfresco runs as a Service.
So stop the alfresco service and also the alfresco mysql service and set the startup property to "manual".
If you have configured a SSO it may be necessary to disable that.
On my machine there was an error
"java.lang.UnsatisfiedLinkError: org.alfresco.jlan.netbios.win32.Win32NetBIOS.GetLocalNetBIOSName()Ljava/lang/String;"
if I startet Alfresco as described below. After disabling SSO Alfresco started without error and also now I was able to start
the debugger.

2.change in c:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\log4j.properties under "Repository" near line 241:
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=warn
to
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=DEBUG

3.create alf_start.bat in c:\Alfresco  [adjust the path to your requirements] with content:
@echo off
rem —————————————————————————
rem Start script for the Alfresco Server
rem —————————————————————————

call "%~dp0alfresco.bat" start %1


4.create alf_stop.bat in c:\Alfresco with content:
@echo off
rem —————————————————————————
rem Stop script for the Alfresco Server
rem —————————————————————————

call "%~dp0alfresco.bat" stop %1


5. create alfresco.bat in c:\Alfresco with content
@echo off
rem —————————————————————————
rem Start script for the Alfresco Server
rem —————————————————————————

rem set Alfresco home (includes trailing \ e.g. c:\alfresco\)
set ALF_HOME=%~dps0
set CATALINA_HOME=%ALF_HOME%tomcat

rem Set any default JVM options
set JAVA_OPTS=-Xms512m -Xmx512m -Xss512k -XX:MaxPermSize=256m -XX:NewSize=256m -server -Dalfresco.home=%ALF_HOME% -Dcom.sun.management.jmxremote

rem — If SetPaths.bat already exists - assume set by hand and use as is
set PATH=%ALF_HOME%bin;%PATH%
if not exist "SetPaths.bat" goto getpaths
call SetPaths.bat
goto start

:getpaths
call RegPaths.exe
call SetPaths.bat
del SetPaths.bat

:start
rem — Test for Java settings
set BASEDIR=%CATALINA_HOME%
rem — Reset errorlevel hack
verify >nul
call "%CATALINA_HOME%\bin\setclasspath.bat"
if errorlevel 1 goto error
set PATH=%JAVA_HOME%\bin;%PATH%
rem —————————————
rem Start Components
rem —————————————

if not ""%1"" == ""start"" goto stop

if not exist "%ALF_HOME%mysql\my.ini" goto tomcat
rem —————————————
rem Start MySQL
rem —————————————
echo Starting MySQL…
start "MySQL" "%ALF_HOME%mysql\bin\mysqld" –defaults-file="%ALF_HOME%mysql\my.ini" –basedir="%ALF_HOME%mysql" –datadir="%ALF_HOME%mysql\data" –console

rem Uncomment below to pause for some seconds before starting Tomcat
rem Change 5 to the number of seconds delay required
rem ping 1.0.0.0 -n 5 -w 1000 >NUL

:tomcat
rem —————————————
rem Start Tomcat
rem —————————————

echo Starting Tomcat…
call "%CATALINA_HOME%\bin\startup.bat"

rem ———————————
rem Start Virtualization if available
rem ———————————
rem if exist "~dp0virtual_start.bat" call "~dp0virtual_start.bat"

goto end

:stop

rem —————————————
rem Stop Components
rem —————————————

if not ""%1"" == ""stop"" goto nostop

echo Shutting down Tomcat…
call "%CATALINA_HOME%\bin\shutdown.bat"

if not exist "%ALF_HOME%mysql\my.ini" goto nextstop
if ""%2"" == ""nouser"" goto tomcatwait
set /P pause="Please wait until Tomcat has shut down, then press ENTER to continue…"
goto stopmysql
:tomcatwait
rem Change 10 to the number of seconds delay required
ping 1.0.0.0 -n 10 -w 1000 >NUL

:stopmysql
echo Stopping MySQL…
call "%ALF_HOME%mysql\bin\mysqladmin" -u root shutdown

:nextstop
rem if exist "virtual_start.bat" call virtual_stop.bat

goto end

:error
echo Error encountered.
if ""%2"" == ""nouser"" goto end
set /P pause="Press ENTER to continue…"

:end


6. create setPath.bat in c:\Alfresco with content and modify the last line so that it is pointing to
the dir on your machine where the JDK (!!!) is installed. Do not point to a JRE path!
@ECHO OFF
REM Set Paths Utility - created by installer
SET JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_27

To start alfresco now doubleclick alf_start.bat in the explorer.
Wait a little time until alfresco is started completely.
And the debugger should start if you call the page http://localhost:8080/alfresco/s/ and there click on "Javascript debugger" and "enable" in the following page.

akalf
Champ in-the-making
Champ in-the-making
hi,
i used bitrock installer to build alfresco.exe
i get  alfresco-community-withpostgresql-3.4.b-1-windows-installer.exe file.
when i try to run this file i get this error :
There has been an error.
Error writing file C:/Alfresco/tomcat/bin/setenv.bat
The application will exit now.

i need ur help please

akalf
Champ in-the-making
Champ in-the-making
hi,
i used bitrock installer to build alfresco.exe
i get alfresco-community-withpostgresql-3.4.b-1-windows-installer.exe file.
when i try to run this file i get this error :
There has been an error.
Error writing file C:/Alfresco/tomcat/bin/setenv.bat
The application will exit now.

i need ur help please
akalf