Saturday, October 19, 2013

[Alfresco] How to Remote Debug an Alfresco Windows Service in Eclipse

This article refers to Tomcat 6 and Alfresco 3.4.0

Problem:

So you have the Alfresco system installed on the Microsoft Windows platform and it is installed as a service. You have trawled the web for hours trying to figure out how to enable remote debugging from Eclipse. A lot of sites talk about changing the Tomcat configuration and you’ve tried modifying all the .bat files in the tomcat/bin folder within your Alfresco installation and nothing works?

Solution:

This problem is compounded by lots of conflicting information on the web with some resolution methods to be used on a UNIX install rather than Windows or with the Windows version when it is not installed as a service.  You may have seen the following argument string to be included in the Tomcat configuration mentioned but don’t know where to put it?

-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

The answer, it turns out, is not so easy to find. Essentially you need to configure the “alfrescoTomcat” service by doing the following:

1.  Open a Command Prompt (START –> Run –> cmd).
2.  Change to the “tomcat\bin” folder (e.g. cd c:\alfresco\tomcat\bin).
3.  Enter the command tomcat6w.exe //ES//alfrescoTomcat which launches the service configuration dialog box. Note that if you try to run the executable by double-clicking it you will get the following error message:

    The specified service does not exist as an installed service.

4. Click on the JAVA tab and enter the following text at the bottom of the “Java Options” field as per the below screenshot (note that that line break is significant):

-Xdebug
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

Enjoy!

Monday, September 30, 2013

[Linux] Creating Shortkeys for Common Commands

In Linux, you can assign short keys to commands you are required to run more often. These are called ‘alias’ and could be added in your .bashrc file. This really helps in quickly doing things and also avoid unnecessary mistakes while writing the commands. Below are some example:

To list all the files in current directory, including hidden files, you can assign a short key for it, say "ls" like mentioned below:
alias ls="ls -a"

View some properties file at particular location:
alias vdp="vi $JBOSS_HOME/server/default/conf/props/some.properties"

To get the running process:
alias jbp="ps -ef | grep jboss"

To view logs:
alias tlog="tail -f $JBOSS_HOME/bin/nohup.out"

Remove some files inside a directory:
alias clrjb="rm -rf $JBOSS_HOME/server/default/work/jboss.web"

Changing directory:
alias jb="cd $JBOSS_HOME/bin"

Beside this, the most useful is one here under. You can use this as “update <relative_directory_path>” to perform some steps in a sequence, one after another. This is called 'function' in linux, and are slightly different from alias, as they expect argument to be passed to them.

function update () {
  cd $SRC_HOME/"$1";
  mvn clean install -DskipTests -o -e;
  cd $SRC_HOME/someOtherFolder;
  mvn clean generate-resources -o -e;
  cd $JBOSS_HOME/bin/;
  sh runit.sh;
  tail -f $JBOSS_HOME/bin/nohup.out;
}

To have these effective, run "source .bashrc" command. 

NOTE: $JBOSS_HOME is an environment variable set as follows:
export JBOSS_HOME=/home/systest/web/jboss/jboss-5.1.0.GA

Enjoy!