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

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.

Solved Issue with VirtualBox Shared Folders and Lubuntu 13.10 Guest

Yesterday, I upgraded my Ubuntu Gnome 13.04 (64-bit) virtual machine to Lubuntu 13.10. I rely on the VirtualBox Shared Folders feature to keep my git repositories in sync with bare copies on network drives at my workplace. (My Host OS is Windows 7, and my workplace IT infrastructure is Windows-based.)

To my horror, today I discovered I could not access my shared folders from my new Guest OS. I even created a “clean” new Lubuntu 13.10 guest machine, which exhibited the same issue. (Yes, I carefully performed the dance of apt-get update, upgrade, install dkms, install guest additions, and rebooting after each install.) So I knew it wasn’t an issue with the upgrade process.

Then, I remembered that the other day, I saw an Oracle announcement that VirtualBox 4.3.0 had been released. I’m running version 4.2.18. Sure enough, upgrading to the latest VirtualBox, and installing its Guest Additions solved the issue. I’m assuming there have been changes in the Linux Kernel (Ubuntu 13.10 is running the 3.11 kernel) that necessitated updates to Guest Additions.