Debug an Ubuntu/Debian Tomcat User Instance

tomcatI sometimes work on web application code that I test by deploying into a Tomcat servlet container. I develop on Ubuntu-based systems, and like to use the tomcat7-user (and/or tomcat8-user) package for testing. I believe this package is also available on Debian systems.

$ sudo apt-get install tomcat7-user

Once installed, a new command is available for creating local Tomcat instances. It saves me from dealing with a globally configured Tomcat server on my system:

$ tomcat7-create-instance my-tomcat
$ cd my-tomcat/bin
$ ls
setenv.sh  shutdown.sh  startup.sh
$ cat
startup.sh
#!/bin/sh 
export CATALINA_BASE="/home/dale/my-tomcat"
/usr/share/tomcat7/bin/startup.sh 
echo "Tomcat started"

Of course, the CATALINA_BASE value in your script will be slightly different. Sometimes I want the ability to connect an interactive debugger to my application’s running server-side code. The provisioned startup script doesn’t provide an easy way to enable JPDA so that I can do this. Let’s create a script that will:

$ cp startup.sh debug.sh

Use your favorite editor to modify debug.sh so it looks as follows:

#!/bin/sh 
export CATALINA_BASE="/home/dale/my-tomcat"
/usr/share/tomcat7/bin/catalina.sh jpda start 
echo "Tomcat started in debug mode" 

I use Eclipse as my development environment. If you do, too, then you can follow the useful guide at http://blogs.mulesoft.org/debugging-your-tomcat-webapp-with-eclipse/ to connect the interactive debugger to your application.

Recursively find all Symbolic Links with PowerShell

logo-horizontalI just started using SyncThing, and have found it to be a powerful way to keep the files on my various personal computers in sync. I like this solution. I sync on my own private network, avoiding privacy-risking cloud services. I discovered fairly quickly that SyncThing will give warning messages about any symbolic links it encounters, letting you know it won’t try to sync those. In my case, this was shortcut folders like My Videos and My Music in my ~/Documents folder.

powershellThis PowerShell script will let you discover any such symbolic links recursively under a given folder:

param([string]$Path)
if (-not (Test-Path $Path -PathType 'Container'))
{
  throw "$($Path) is not a valid folder"
}
$Current=Get-Item .
function Test-ReparsePoint($File) {
  if ([bool]($File.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
    $File
  } else {
    $FALSE
  }
  return
}
cd $Path
# Recurse through all files and folders, suppressing error messages.
# Return any file/folder that is actually a symbolic link.
ls -Force -Recurse -ErrorAction SilentlyContinue | ? { Test-ReparsePoint($_) }
cd $Current

The function in this script was derived by from the answer given by Keith Hill at https://stackoverflow.com/questions/817794/find-out-whether-a-file-is-a-symbolic-link-in-powershell. If you save the above script as ~/scripts/FindSymLinks.ps1, here is what a sample session looks like:

PS C:\Users\Dad\scripts> .\FindSymLinks.ps1 ..\Documents
    Directory: C:\Users\Dad\Documents
Mode               LastWriteTime     Length Name
----               -------------     ------ ----
d--hs       10/24/2009   2:09 PM           My Music
d--hs       10/24/2009   2:09 PM           My Pictures
d--hs       10/24/2009   2:09 PM           My Videos

I’m Making My PhD Thesis Available Online

GitHub-Mark-120px-plusOver 10 years ago, I defended my PhD thesis. Due to my moving to another state shortly thereafter, possibly combined with bureaucratic confusion at my alma mater, I never received bound copies of my dissertation. I have also lost any electronic copies I may have once had in the intervening time. Recently, though, my employer started subscribing to a dissertation service, and I was able to download a scanned version of my dissertation.

tumblr_lgabq4NUsR1qb1aw7o1_500Since I had the foresight to apply an open access license to my document, I am creating a web site on GitHub which will be an electronically accessible version of my thesis document. I also have some data backup disks lying around, and intend to upload that data as supplemental material. I have a large family, and not much spare time, but I am making slow progress. The front matter is complete and the first chapter is almost complete. The site is here:
Particle Decay Branching Ratios for States of Astrophysical Importance in 19Ne

Automatically Delete TEMP Folder in Windows (no installs required)

When I use Linux, I love that anything I place in /tmp will be wiped when I shut the system down. Windows, out of the box, doesn’t do this for your %TEMP% folder. Google this, and you’ll find many people advising to install one free tool or another. I am very wary of unnecessary installations on my Windows machines. The advice given here at WindowsForum.org requires no installations. It was meant for Windows XP Pro, but I found today that it worked just as well on my Windows 7 Professional system.

Unlike the fixed /tmp location in Linux, Windows determines the value of %TEMP% and create that folder dynamically at every login. Firefox doesn’t seem to accept %TEMP% as a valid value in browser.download.dir on about:config. Therefore, I

  1. keep a sidebar shortcut to %TEMP% in Windows Explorer, and
  2. select “Always ask me where to save files” in the Downloads section of the General tab of the Options dialog.

That way, it is easy for me to select my %TEMP% folder when downloading in Firefox, as well to access it from Windows Explorer.

Trouble installing Flash on Windows? Check your system clock.

When Adobe released their last security updates for Flash, I was unable to install them on one of my Windows PC’s for either Firefox (plugin version) or Internet Explorer (ActiveX version). I scoured the web and Adobe forums, and approached the problem many different ways, even completely removing Flash from my system, and downloading special MSI installer files from Adobe. Always, the same problem. The installation process starts, then goes nowhere. I get a process for the installation in Task Manager taking up about 10 MB of RAM, and 0% of CPU, that never goes away, and never does anything.

I had resigned that I was never going to have Flash on FF or IE on this system again, unless I re-installed Windows. Then the other day, I randomly noticed that the system clock was 5 hours fast. I’m not sure how or when this happened. I don’t pay attention to the clock on this system because it’s a living room television-attached system mostly for entertainment. Anyways, I corrected the time, and decided to try installing Flash again. Both Plugin-based (for Firefox) and ActiveX-based (for IE) installations went perfectly.

For the curious, the version of Windows is Windows 7 Home Premium, 64-bit.