Blog

Thursday, January 21, 2010
Remote monitoring of Tomcat

Got memory leaks? Dogged by OutOfMemoryErrors?

JDK 1.5 and later come with jconsole.

First you have to tell Tomcat how to publish it's inner workings for jconsole. This process differs by platform and also depends on how you installed Tomcat.

The typical MacOS X install consists of downloading the zip and expanding it somewhere. The "somewhere" is your CATALINA_HOME. If that's how you installed Tomcat, go to $CATALINA_HOME/bin and create a file called setenv.sh. Into it put this line:

export CATALINA_OPTS="-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=8086 -Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false"

On RHEL, Tomcat is typically installed via rpm – I use yum. In that case, you need to add the CATALINA_OPTS to /etc/sysconfig/tomcat6 Leave out the "export" since this file is not a shell script.

Now reboot Tomcat and you're good to go.

Connecting is trivial. Start jconsole. On MacOS X, simply type jconsole at the command line and it opens. For other other platforms, let me know and I will add it.

When jconsole comes up, it will have discovered any local tomcats so simply connect. For a remote tomcat, connect using port 8086 as specified above, and leave user name and password empty.

That's it!

Labels: , ,

1 comments

Saturday, January 02, 2010
Automating your MacPorts upgrades

Porticus is a very nice tool for maintaining your MacPorts. I find it easier than the command line port utility. But mostly, I use it for routinely updating (uh, sorry — “upgrading”) my ports. What if that could be automated?

Here's how.

Create /etc/daily.local with this content

#!/bin/sh
#
# /etc/daily.local
#
# I got this from http://hacks.oreilly.com/pub/h/336

# General parameters
PATH=/bin:/usr/bin:/sbin:/usr/sbin
. /etc/hostconfig

# Update MacPorts, if present
if [ -f /opt/local/bin/port ]; then
    /opt/local/bin/port selfupdate >> macports.log 2>&1 && /opt/local/bin/port upgrade installed >> macports.log 2>&1
fi


This adds the MacPorts update to your daily maintenance regimen. Typically, the Mac's periodic scripts are run at around 3:00 AM and they take care of all kids of things like updating your locate database. The /etc/daily.local file is executed if present.

Naturally, if you would rather do your MacPorts update weekly or monthly, then use /etc/weekly.local or /etc/monthly.local instead.

Create /etc/newsyslog.d/macports.conf with this content

# logfilename          [owner:group]    mode count size when  flags [/pid_file] [sig_num]
/var/log/macports.log                   640  7     *    @T00  J

This additional config file for newsyslog says to rotate the macports.log file created by our daily.local. For more info, use man newsyslog

And so on…

Obviously, you can use this trick for other things you'd like to run periodically. For example, you can update Fink be putting this into your daily.local:


# Update Fink, if present
if [ -f /sw/bin/fink ]; then
    /sw/bin/fink selfupdate >> fink.log 2>&1 && /sw/bin/fink update-all && /sw/bin/fink cleanup >> fink.log 2>&1
fi


Labels:

0 comments

Wednesday, December 09, 2009
Selenium won't launch Firefox under Snow Leopard

The latest FireFox (3.5.*) includes a version of sqlite that drives Selenium nuts. The basic problem is that Selenium is allowing FireFox's (whacko) version of sqlite to take precedence over the OS-supplied one.

The error message you'll see in the Selenium server log files looks like this:

dyld: Library not loaded: /usr/lib/libsqlite3.dylib
Referenced from: /System/Library/Frameworks/Security.framework/
Versions/A/Security
Reason: Incompatible library version: Security requires version
9.0.0 or later, but libsqlite3.dylib provides version 1.0.0

The fix is to disavow Selenium of that silly notion, which entails setting the DYLD_LIBRARY_PATH correctly. This is all explicated in the Selenium bug report.

The problem has already been fixed in the Selenium trunk, so the solution is to build your own Selenium. It's quite trivial, so here goes:

First, grab the patch, then execute these commands:

svn co http://svn.openqa.org/svn/selenium-rc/trunk .
patch -p0 < snow-leopard.patch
mvn install
cd $WHEREEVER_YOU_KEEP_SELENIUM
cp selenium-server.jar selenium-server.jar.bak
cp selenium-server/target/selenium-server-1.0.2-SNAPSHOT-standalone.jar selenium-server.jar

That takes care of the prob.

Labels: , ,

0 comments

Saturday, June 13, 2009
Mumble or Skype?

We use Skype a lot at Industrial Logic. But we also use VNC, and if the person running the VNC server has a low upstream bandwidth, the voice quality is unusable. We thought we might give Mumble/Murmur a try.

As it happens, I have done a bunch of research on VoIP technologies and speech codecs, so when I saw that Mumble uses Speex, I knew that it is on the right footing.

Two thing need to happen in order to get to the point where we can do some tests. The first is to set up the server. The Windows download of mumble includes murmur, and there are RPMs and static builds of murmur for Linux-based systems. As it happens, MacPorts has a murmur install, so on MacOS it's a simple matter of

port install murmur

Configuring the server — something I have yet to try — appears to be documented, but the proof is in the pudding.

Just for giggles, I fired up mumble in an attempt to connect to a public server. It seems that much of the goodness of mumble comes from it being configured correctly. In particular, it needs to be trained so that the background noise-filtering works correctly.

I have not reached on conclusion on whether mumble can replace skype for my bandwidth-challenged brethren. If I get 'round to installing murmur, we can give it a try.

Labels: ,

0 comments

Notes on making a simple auth app using Wicket

Follow the instructions here and add the junk to your pom. You'll need to add a repositories element in which to put you repository. I put mine near the end, after the build

Run mvn install

I prefer JUnit 4 to 3.8, so I removed the generated "variable" ref from my class path and added Eclipse's built-in library for JUnit 4.

To keep things consistent, I modified the pom to refer to JUnit 4.. Maybe I should have let the Eclipse build reference the Maven repo rather than Eclipse for its JUnit. Hmm.

Added "variable" ref for both swarm and wasp (sheesh - why two? This is so confusing) and changed my application to extend SwarmWebApplication as described in the swarm getting started doc.

Of course, Eclipse helped me out with the stubs of the overrides of the abstract methods, so on to filling them in.

So, starting with a bare-bones app, start adding security. Hmm. Not working.

OK, so start with the kitchen-sink security demo app and begin deleting unneeded code. Hard, because I don't have a project and have to rely on reconstructing one from the war.

Aaargh! Give up on swarm. The guy's dead anyway, so who's maintaining it?

So auth-roles is the next.

Generate a project using mvn. Modify the pom to include auth-roles:
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-auth-roles</artifactId>
<version>1.4-rc4</version>
</dependency>

Then use mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true to make the eclipse project. Import into eclipse.

Copy gibblies from the "wicket-auth-roles-example" available on Sourceforge. (It's in maven too if you know how to get it. I don't.) It has a weird structure, not like the autogenerated one with the embedded Jelly, so that's why we have to copy/paste.

A couple little syntax errors: Stuff that's presumably changed in more recent releases. An overridden constructor needs to be deleted, since the thing it overrides no longer exists. Stuff like that.

And the source needs to be reformatted. What's with all this C#-like source formatting anyway? Sheesh, this is Java, guys.

Labels: ,

0 comments

PHP Again

Since my last post about PHP dev, Eclipse PDT seems to have matured a bit. So I am having a go at installing it.

First, I uninstalled PHPEclipse and the xdebug plugins, and installed PDT. The instructions, mysteriously, are quite complex. Find them here.

I had a very frustrating time getting dependencies to resolve properly, until I found a hint somewhere that suggested that my Eclipse install was "messed up." So I downloaded a fresh Eclipse for J2EE and finally got PDT 2.0 installed.

This came at the cost of all the gaziilion other plugins I had installed, like the Google App Engine support, Ruby and Python support and so on. Feh. I'll live.

I disliked all the UI clutter introduced by the xdebug plugin so, contrary to Paul Scott's advice, I am giving zend debugger a whirl.

It seems that PDT comes with the "client" end of the Zend debugger, so all we need is the server. These instructions purport to guide one through that.

Make a phpinfo.php file containing only and execute it to see what php thinks about itself and its world.

Follow the instructions in the readme that comes with the download. First, I copied ZendDebugger.so into /usr/local/lib. Then I made /etc/php.ini by copying the default found in the same directory. This is what I added:

[Zend]
zend_extension=/usr/local/lib/ZendDebugger.so
zend_debugger.allow_hosts=127.0.0.1, 192.168.1.0/16
zend_debugger.expose_remotely=always

I was also told to copy dummy.php into your Apache docroot, but I don't know why. I put mine in /Library/WebServer/Documents/

To confirm that it's installed, we use our phpinfo.php and search for "debugger". There will be a reference next to the copyright as well as an entire section of zend debugger-related info.

We need the client end of the debugger which is not provided by Eclipse for licensing reasons. Get it here. (The referring page is here.) Hmmm. It seems you can get it from an Eclipse update site as well.

Leopard comes without pear so we have to install it:

cd /usr/local
curl http://pear.php.net/go-pear > go-pear.php
sudo php -q go-pear.php

Note that the go-pear script is very fragile and pretty badly written. It is easily confused. Make sure you are in the directory you want it to install into (/usr/local in our case), or it will get things horribly wrong. When it's done, it will have fixed your php include_path too. Use pear config-show to see how it's been set up.

Now, to install PHPUnit, all we need do is

sudo pear channel-discover pear.phpunit.de
sudo pear install phpunit/PHPUnit
It turns out that PDT does not support running PHPUnit directly, so I created an "external" run configuration in Eclipse to make it happen. [how? Maybe I'll fill in the details some time. Not now. It's my blog and I will write what I like.] I can finally test-drive some code! Next, deploy it. Zend Framework likes to assume it's at the root of your docroot, so people typically create a virtual host to make that happen. I found that Zend Framework apps really want to see Zend on the include_path so we add it in php.ini. But first we put a copy of the framework in a central spot. I chose /usr/local. So the whole download lives in /usr/local/ZendFramework-1.8.1. We'll want a symlink to isolate us from version lockin, so inside /usr/local, I did a
ln -s ZendFramework-1.8.1 ZendFramework
Now my include_path looks like this:
include_path=".:/usr/local/PEAR:/usr/local/ZendFramework/library"
Then, in things like the quickstart app, I just went into the library directory and did
ln -s /usr/local/ZendFramework/library/Zend
Finally, in the quickstart, I did the requisite
php scripts/load.sqlite.php --withdata
as dictated in the quickstart readme, and the db was created. Still following the instructions in the quickstart readme, I created the virtual host. I put it into /etc/apache2/extra/httpd-vhosts.conf and uncommented the include in httpd.conf. I added the line in /etc/host but here's the thing: Add ::1 as well as 127.0.0.1 since, being a futurtistic Mac, it uses IPv6. Apache had trouble with permissions when my docroot was in my home directory, so my virtual host's docroot ended up being /Library/WebServer/ZendFrameworkQuickstart-20090430 If you have permissions issues (you will), look in the apache log and chmod everything in sight. Finally, the app worked! Next, I tried making an app from scratch using the zh.sh script that comes with the framework. It's a bit like the RoR script(s) and is used to generate a new app, a new controller, a new view, etc. I made a do-nothing app and voila! it worked!
zf.sh create controller auth 
zf.sh create action login auth
zf.sh create action logout auth --view-included=0
Still, the virtual host stuff has to be set up or nothing else will work. That's very troubling, as I can't imagine many ISPs being open to that level of messing with their Apache instance. More on that particular nightmare another time.

Labels: ,

0 comments

Sunday, April 05, 2009
Installing MySQL gem on Leopard

Ordinarily, installing a gem on Mac OS X is as simple as

sudo gem install foo.

However, a little extra magic is required to install the mysql gem:

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

I found this reference to back me up.

Labels: ,

0 comments

Thursday, November 27, 2008
Ecto

So it's a holiday, and what better way to spend it than fiddling with an app on a Mac?

I looked around – once again – for a better blog posting client than ecto. The only contender is blogo. It's very nice, but it lacks some of the power features of ecto like a twitter plugin (I still don't have that working..), the ability to ping a bunch of servers, and, most important, custom HTML tags for doing stuff like posting code. Sure, you can hand-edit the HTML, but that gets very old very quickly.

So back to ecto. Time to pimp it up and get all the gibblies to work together. The UI has always frustrated me. Nothing is where I expect it to be. But at least this version (3.0b55) is reasonably stable.

Now, having got it the way I want it, I need to set it up again on my desktop machine. What a pain! I copied the .plist file from ~/Library/Preferences to the other Mac, but some things are still not there, like the list of servers to ping. With a little digging and some help from sudo fs_usage -filesys |fgrep -i ecto I see that all that stuff lives in ~Library/Application Support/ecto3/accounts.plist Bingo!

Labels:

0 comments

Saturday, October 11, 2008
PHP and FMP

Get FM_API_for_PHP_Standalone from within the FM server download. Use the trial if necessary.

Expand it and copy it into /usr/local/php/fmp. Make the parent directories as needed

Copy /etc/php.ini.default to/etc/php.ini

Edit php.ini. Uncomment and modify include_path = ".:/usr/local/php/includes"

I set up eclipse by copying the features and plugins after downloading from http://www.eclipse.org/pdt/downloads/ I couldn't get the update site to work (mysterious errors.) Finally, after messing with it for ages, I concluded that Eclipse PDT doesn't work with Ganymede. I now use PHPEclipse.

For debugging, we need xdebug. Oopsie. Must install pear to get pecl to get xdebug.

So,

curl http://pear.php.net/go-pear > go-pear.php
sudo php -q go-pear.php

Let the script update php.ini. And don't forget to update PATH like the script told you to.

Then it's

sudo pecl install xdebug

And do NOT do what it says (You should add "extension=xdebug.so" to php.ini")

Instead, add this:

[xdebug]
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so

Then confirm that it's working by doing php -mxdebug will show up both under [PHP Modules] and [Zend Modules]

Get phpUnit installed. See Sebastian Bergmann's site: http://www.phpunit.de/manual/3.4/en/installation.html

sudo pear channel-discover pear.phpunit.de
sudo pear install phpunit/PHPUnit

Labels: , ,

0 comments

Sunday, May 11, 2008
AFP and Bonjour on DS-107+

Here are some notes I took when getting a Synology DS-107+ to play nicely on an all-Mac network. I installed an AFP server and mDNS daemon, also known as Bonjour or Zeroconf.

The first pitfall: Use firefox - bugs prevent proper privileges and path installation if you use Safari.

Instal EnableSSH. See Synology's instructions

Check "Hide this share in My Network Places". This prevents them from being published as samba shares. They're still accessible via samba, and AFS only publishes to people who have access anyway.

Install ipkg by following the instructions on Maarten Damen's site

If you're a Unix geek, you'll recognize ipkg as being a package manager something along the lines of Debian's apt or the Mac port, fink.

We'll install avahi next. It's the Bonjour bit. The ipkg install is in the "unstable" tree so we need to tell ipkg about it by adding

src http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable

to /opt/etc/ipkg.conf

Then avahi will install by simply running

ipkg install avahi

We need to give avahi the wherewithal to boot and be useful. I found that the slackware distro has the closest to what I wanted.

Copy the init script from

/avahi-0.6.22/initscript/slackware/avahi-daemon.in to /opt/etc/init.d

Also change the @sbindir@ to /opt/sbin

This is easiest if you mount /opt via smb (the share is published by ipkg bootstrap)

Start all the daemons by running

/opt/etc/rc.optware

In /opt/etc/avahi/services

delete sftp-ssh.service and replace with afpd.service:

(see http://gentoo-wiki.com/HOWTO_Share_Directories_via_AFP)

Hacked the S20dbus script in /opt/etc/init.d to NOT check for pid file. I think the pid is not properly cleaned up on shutdown so dbus fails to boot. This causes it to run, which allows avahi to run too.

Labels: ,

0 comments

Thursday, April 17, 2008
Macworld | Mac OS X Hints | Add more power to 10.5's screen sharing

[From Macworld | Mac OS X Hints | Add more power to 10.5's screen sharing]

I live by VNC, since we are a distributed XP team. So I was thrilled when I found this MacWorld article on tweaking the build-in VNC client on Leopard.

Now if only it would get over some of its temperamentality so I can use it reliably over an SSH tunnel or to a non-Mac machine.

Labels: ,

0 comments

Friday, March 14, 2008
Leopard: Connect As... does nothing

In Finder, Connect As says "Connecting" but does nothing. That's because NetAuthAgent is dead or wedged. See this thread: http://discussions.apple.com/message.jspa?messageID=5785124#5785124

The only cure I can find is to log out/in again.

Labels:

0 comments

Getting Postfix running on Leopard

1) Enable the service by changing the "disabled" flag in /System/Library/LaunchDaemons/org.postfix.master.plist I just use Lingon for this.

2) Edit /etc/postfix/main.cf and uncomment and edit this line:

myhostname = host.domain.tld
Also uncomment this line:
myorigin = $mydomain
That's it!

Labels:

0 comments

Wednesday, January 21, 2004
Country and Western
I now have two old(er) Macs with two different accelerators. Interesting contrast! Both the Sonnet Crescendo (800 MHz G4 installed in an old 8500) and Powerlogix PowerForce (1.x GHz G4 in stalled in a sawtooth G4) work flawlessly and installation was easy. The installation dox from Sonnet were better. The Sonnet web site and product lit made it easy to determine which unit to buy. (And Amazon's vague description made for a good price!) Powelogix, by comparison, use different product descriptions in the main part of their web site and the online store. Most confusing. Regardless, I now have two fast(er) Macs where I only had an aged, slow one before.

Labels:

0 comments

AddThis Feed Button

Twitter Updates

    follow me on Twitter

    Archives