First use of Grails problems

June 17th, 2010

I’ve recently been reading ‘The Definitive Guide to Grails’ Second Edition, by Graeme Rocher and Jeff Brown.

It made sense to try and work my way through the examples in a practical manner as well as read the book, so I downloaded Grails 1.3 (the book suggests 1.1, but what the hell) and followed various installation instructions. The instructions on the Grails site and in the book are very similar, so that sounded promising.

I followed the first example, you create a grails-app called gTunes, you create a controller called StoreController, you add one line of code to the controller and two lines of code to a unit test, you run the unit test and it confirms that the response it’s expecting is equal to what the controller index is generating. So far so good.

You’re then supposed to run grails run-app, which I did… The book then suggests i’ll eventually get a suggestion that the application has been started, I never did.

I tried the browser link I was expecting anyway and it just sat there waiting for data.

I looked at netstat, it confirmed that there was a Java process listening on port 8080.

I could telnet to port 8080, but couldn’t get any response from the server.

Top suggested the process was using 100% CPU and the memory usage was slowly increasing. After about an hour, the memory usage went from about 256M up to 1G. Something was clearly wrong. The application was doing something, but what?!

I couldn’t find any obvious way of debugging what grails was doing, so I eventually reverted to trusty strace.

To my amazement, after the output whizzed by very quickly and unreadable, it slowed slightly and I could see lots and lots of stat’s against files on the filestystem. Stopping the process and then lokoing back through my scrollback, it seemed to be stat’ing EVERY file on the filesystem?!

Further investigation eventually suggested that the java process had the argument

--classpath /

It’s the only reference of / I could find anywhere, so overriding it in the current shell to . , my grails app started.

It turns out that I set my CLASSPATH to / for some other applications (dont’ ask). But it seems that grails parses every file on your classpath, which was causing my problem!

Shaker Bar School Review

April 1st, 2010

I bought my partner an ‘Introduction to Cocktail Making’ course as a present from Shaker Bar School in London, it happened to be two for the price of one, so I was lucky enough to be able to tag along and enjoy the experience.

When I booked the course, I couldn’t find any obvious reviews of the course, so I thought i’d document my thoughts here.

The London school is located a few minutes walk from Old Street underground station. Walking up the road we almost missed the entrance, which we would have done if it weren’t for the logo on the front door. From the outside, the front look really small and uninviting, simply a black door and a frosted glass window. We knocked and someone let us into the building. On the other side of the door we were greeted be a small reception area, where the other attendees were sitting waiting for everyone to arrive, sipping cocktails. Further back is a pretty long fairly impressive looking bar (there are images on the front page of their website), fully stocked with all manner of alcohol and bar equipment.

Once everyone arrived (there were about 11 people on our course, but the bar could probably have seated 15-16 people, maybe a few more) we were all issued an introduction to cocktail making manual and were asked to sign the liability waiver form in case you injure yourself whilst making your drinks! After signing my life away we were introduced to the team. There were three main people behind the bar, seemingly lead by one lady, all of whom were professional bartenders and a fourth person who kept everyone topped up with water, cleared away unwanted cocktails etc.

The lady gave us all a fairly short background on cocktails and cocktail making in general, some information on bar safety and then they got into making the first cocktail. All of the attendees tend to move down towards the middle of the bar and watch one of the professsional bartenders make the first drink in the manual. Again there’s a small amount of background information on (one of) the backgrounds on how the cocktail was invented and by whom. They then proceed to work through the steps involved in making a specific cocktail, everyone watches and asks questions then gets to try the cocktail (using their method of taking a small amount of drink with a straw by holding your finger over the tip of the straw). We all go back to our places and then two at a time in each of our small groups we get to go behind the bar with our bartender and get to reproduce the drink. The bartenders know so much and can easily suggest ideas on how you can modify the base cocktail so that everyone gets to try to make something different if they like. They help you through all the steps, freshly squeezing your lemon/lime, icing your glass/shaker, measuring spirits, free pouring, shaking, stirring, garnishing, etc. Everyone then gets to try each others drinks (using the same method as described above). There’s generally some more chat about everyones drinks, what has worked and what hasn’t, etc. Then the whole process pretty much repeats for the rest of the day. You learn perhaps 8-10 different styles of base cocktail and get to quiz the bartenders for special recipes of their own, etc.

The whole day was great and needless to say, the Mrs and I left about 6:30pm (the course is 1pm – 6pm with a short break) very happy, content and a little bit drunk.

This is definitely a great afternoon out.

Gentoo kvm to qemu-kvm goodness

December 8th, 2009

I run Linux KVM on a Gentoo server and recently noticed that the kvm package had been moved to qemu-kvm, apparently something to do with merging of qemu and kvm upstream…

Anyhow, I thought i’d update as this is mainly a test machine rather than production, what could possibly go wrong?

Libvirtd and a few other packages were updated at the same time, things seemed fairly promising, no special output from any of the updates meant that I assumed I could simply restart libvirtd and everything would just magically work again. Unfortunately it didn’t. None of my virtual machines started up.

I started up virsh and tried to start a machine, receiving the error:

Error starting domain: Cannot find QEMU binary /usr/bin/kvm: No such
file or directory

Erm… ok, perhaps the binary has moved, or changed names? The package was renamed from kvm to qemu-kvm after all… Lo and behold, there’s actually a /usr/bin/qemu now. So fire up virsh, edit my virtual machine config and replace

<emulator>/usr/bin/kvm</emulator>

with

<emulator>/usr/bin/qemu</emulator>

That ought to solve the problem, so again, try to start the virtual machine… ooh, ok, it looks like it starts, so I connect to the serial console and twiddle my thumbs for a bit… nothing. Eventually give in and connect to the vnc port for this machine. Rather annoyingly after trying to boot my x86_64 kernel on what turns out to be x86 qemu I see the message

This kernel requires an x86-64 CPU, but only detected an i686 CPU.

ARGH! Ok, so there must be some sort of flag I can pass to qemu to tell it to be x86_64? Or perhaps an qemu-x86_64, yes, that’s it /usr/bin/qemu-x86_64, so I edit my machine within virsh again and this time change emulator to:

<emulator>/usr/bin/qemu-x86_64</emulator>

Surely that will solve my problems? Nope, now when I try to start the VM with virsh it tells me:

error cannot parse QEMU version number in 'qemu-x86_64 version 0.11.0
(qemu-kvm-0.11.0), Copyright (c) 2003-2008 Fabrice Bellard'

Eh?! So does virsh do some sort of parsing of the qemu version number and if so, what’s wrong with that?

It turns out (I learn after much random googlage), that there’s also a qemu-system-x86_64 (obviously), so once again, edit the virtual machine config in virsh and change emulator to that

<emulator>/usr/bin/qemu-system-x86_64</emulator>

Start the VM, watch the console…. and YaY, it boots. Finally. All I need to do now is update the rest of my virtual machine configs and everything should be ready to go again.

Whoever decided this update was a good idea without at least warning people that things were going to break needs to be flogged with a wet kipper. I know this is technically ‘unstable’ Gentoo, but come on people, give us a chance!

Flashing your HTC phone in Linux

May 24th, 2009

Ever since i’ve been using HTC based phones i’ve found that the stock OS is generally slow. I know it’s running Windows Mobile… but until recently trying to get a nice PDA that runs anything else is difficult.

I do have a windows box that’s lying around for random uses, but its hard disk died recently and i’ve been wanting to flash my phone (a T-Mobile MDA Vario III , aka HTC Kaiser) for a while… Not really wanting to spend time rebuilding the windows box anytime soon I had a look around to see if there was a way of doing this stuff on my Linux boxes. Needless to say I found HTCFlasher.

Much to my surprise I found some ebuilds in the Gentoo bugzilla for it, which saved m having to do any of the real work… A couple of mins later it was installed so I had a poke around. To my surprise it worked very well, below are some notes I put together.

If you’ve never done any of this stuff before I highly recommend reading the XDA Developers Forum post for some useful notes. It’s the basic steps I followed with some slight differences noted below.

Ignore anything in the forum post that mentions ActiveS(t)ync as luckily that doesn’t apply to us. Also, anything that mentions KaiserCustomRUU.exe is what we’re replacing with HTCFlasher.

Flash HardSPL:

Download the correct JumpSPL for your phone onto your phones storage. Execute it and you should end up at the tri colour screen, it should have slightly different text to the text that you would usual tri colour screen that you would see if you turned on your phone whilst holding the camera button down.

Plug the USB cable into your phone and wait a few moments for USB device scanning to take place and then check the dmesg output for the following:

$ dmesg | tail
ipaq 7-1:1.0: PocketPC PDA converter detected
usb 7-1: PocketPC PDA converter now attached to ttyUSB0

If it doesn’t then I found that I needed the usbserial and ipaq kernel modules loaded. Also take a note at this stage as to which ttyUSBX (where X is 0, 1, 2… etc.) as it it’s not ttyUSB0 you need to specify it later.

As a quick test at this stage you should be able to use HTCFlasher to query your device for some basic information. It’s a nice simple test to see if you can actually talk to the phone before you try to do anything more serious with it. You can do this with:

$ HTCFlasher -i
=== HTCflasher v3.1
=== Open source RUU for HTC devices
=== (c) 2007-2008 Pau Oliva Fora
[] Getting device info...
[] CID: SuperCID
[] ModelID: KAIS1300

Now to actually flash the phone with HardSPL

$ HTCFlasher -F /path/to/Kaiser-HardSPL-3.29/Kaiser-HardSPL-3.29.nbh
=== HTCflasher v3.1
=== Open source RUU for HTC devices
=== (c) 2007-2008 Pau Oliva Fora
[] Flash NBH file '/path/to/Kaiser-HardSPL-3.29/Kaiser-HardSPL-3.29.nbh'
[] Setting RUU mode, please wait............done
[] SPL auth result (T=True, F=False): T
100% [###########################################]
Done!

If all went well, your phone should reboot and you probably won’t notice any difference!

I had no current reason to SIM Unlock my phone, so I skipped this step from the forum post and went straight on to…

Download and Flash your Preferred Rom

Again, follow the forum post as with the previous step, still ignoring Activesync and using HTCFlasher instead of KaiserCustomRUU.exe.

The only obvious thing to note as this stage is that when in Windows, you run the KaiserCustomRUU.exe and that seems to signal your phone to reboot etc. As far as I can tell, we don’t have that luxury, so we have to get the phone onto the tri-coloured screen ourselves. Fortunately it’s pretty easy, simply turn your Kaiser off, wait a second or two to ensure it’s really off, press and hold the camera button and then press the power button, after a few seconds the device should turn on and be at the tr-colour screen (you can then let go of the two buttons ;) )

Everything from this point you’ve already done when flashing HardSPL. But instead of flashing the HardSPL.nbh, you flash the .nbh file from your downloaded ROM. It really should be that simple.

Also note that some ROMs require a specific radio version. So if some features of your newly flashed ROM don’t work correctly, you may have to find a matching radio (usually noted in the ROMs forum post or in some sort of README, if it’s not already part of the nbh).

That about wraps up this post. It’s worth noting that there’s a gtk frontend for HTCFlasher and the various other tools and utilities. But it’s no real hardship to flash your phone from the command line.

Perhaps in the future i’ll try to discuss using the Linux Rom Kitchen to build/modify a ROM.

Ubuntu for parents feasibility study

March 16th, 2009

I’ve become fed up trying to support my parents Windows machine, an AMD Athlon 2100+ with 512M of RAM, more than enough you would think for the fairly limited stuff they do on it.

The machine ran fine when I originally built it for them, Windows XP, SP1…. of course you eventually add/update things such as a virus scanner, .net framework, Windows Live Messenger/Hotmail, Service Pack 3 and eventually it feels like you’ve gone back to your 486.

Being a Linux man, i’ve been pondering simply nuking their machine and replacing it with Linux. But then you face the dilemma, which flavour? For the last few years i’ve mainly used Gentoo for anything that I put together, not really suitable as an OS for my parents though. Alot of people have raved at me about Ubuntu, so I eventually gave in and downloaded the Umbongo Ubuntu cd’s and fired them up in a test box.

To my surprise, I think my mum could have installed Ubuntu. A couple of pages of fairly simple questions, a 5 minute wait and a reboot later and I was looking at the Gnome branded Ubuntu desktop. Just a few minutes quicker than my last Gentoo install ;)

Anyway, I know there’s lots of alternatives to various pieces of Windows software, so it’s Firefox instead of Internet Explorer, OpenOffice.org instead of Office, Pidgin instead of Windows Resource Hogging Messenger… I think they can handle that! But then what about various other things? Scanning, Printing, Zuma (some crazy addictive Windows game that my dad likes), Putting pictures onto a Digital Photo Frame, etc.

So I started with the scanning, I hate scanners in Windows, almost as much as I hate printers, put I pulled out my trusty scanner and plugged it into the test box. Twiddled thumbs, nothing bad seemed to happen which was a bonus. I looked in the list of applications and Ubuntu seems to come with Xsane installed by default. I’ve heard of but not yet tried ‘Gnome Scan’, but as XSane was installed it makes sense to at least give it a try. I started it up, it told me that it was searching for devices, it found one device and then presented me with about four crazy looking windows. Now it only took me a few moments to familiarise myself with them,within a minute or two i’d already previewed what I wanted to scan, cropped around the item in the preview window and then scanned the image into a viewer. I was pretty impressed, i’m just not sure that it would have been that easy for my Mum, perhaps with a little training. So I need to investigate other alternatives at some point, Gnome Scan being he top of the list I guess.

The next thing I looked into was running Zuma on Linux. I couldn’t find a ported Linux alternative, so I was forced down the route of trying Wine. I’d looked at it in the past for something and had limited success. But thought i’d give it a go, I had nothing to lose. I opened the add/remove programs, typed ‘wine’ in the search bar, selected the wine package for install and a few clicks later the package manager did its thing and I had Wine installed. I opened the Wine Config screen first to check that everything made sense, as I expected it did… There was a ‘virtual’ c_drive mapped to a directory within the users home directory, presumably where Wine puts installed program files etc. I downloaded the Zuma Deluxe demo from the Internet to the Desktop and double clicked the executable installer (wow I feel like a Windows user again ;) ) . Needless to say, I was presented with the Zuma installer… A few clicks later (and a few error messages about not being able to create links to the manufacturers website), I had a Zuma Deluxe icon on the desktop. That was nice and easy. As things were going so well, it made sense to at least try playing Zuma for a bit, just to ensure that it was up to the standard that my dad would be expecting. I was mightily impressed, Zuma worked just as well (probably better) as it did on the Windows machine. That’s another item off the list.

I’m yet to try printing, USB attached storage, a few other Windows only applications, a sensible way to backup their system to one of mine and of course, rolling this out to my parents to try.

But so far, it’s umbongo++ from me.

Not working to easily tested in one simple step

February 28th, 2009

Anyone that read my ‘working to not working in one simple step’ post may have wondered what I did to solve the problem.

It turns out that although these crazy server motherboards have all these slightly different PSU connectors on them, when in reality, they’re just an ATX mothermoard. Admittedly not everything worked, but I had enough working to know that it really was the old PSU that was the problem rather than the new motherboard.

To make this work, I had to understand what the various other connectors on the board are actually for.

The server motherboard I have has the following PSU connections:

  • 24 pin ATX power connector
  • 4 pin 12V PWR connector ‘to provide adequate power to the system’
  • 8 pin CPU PWR connector

A normal desktop PSU has the following connectors:

  • 20 pin ATX power connector
  • 4 pin 12V PWR connector

The 20 pin ATX connector pinouts and 20 of the 24 pins of the ATX socket on the motherboard pinouts match up, which is what I was expecting. Rather helpfully, the 20 pin conector even fits perfectly into the  24 pin ATX socket on the motherboard if you line up the correct parts. Obviously four of the pins in the socket have nothing going into them, but it seems to be that they’re just used for additional power feeds. I hoped they weren’t required to at least turn the motherboard on for my testing.

The 4 pin 12V power obviously fits into the 4 pin 12V power socket on the motherboard.

So at this stage, I have nothing connected to the 8pin CPU PWR socket. I hoped that this would still let me turn the system on, but unfortunately it doesn’t. According to the server motherboard manual, the CPU PWR connector is just 4 Ground connections and 4 12V connections. I tested the various CPU PWR socket pins with a multimeter and it seems that two of the 12V pins connect together on the board and the other two connect together on the board. But not all four 12V pins are connected. This suggests that 4pins were for CPU PWR to one  CPU and 4 pins were CPU PWR to the other CPU.

Now again, working on assumption, if you need 12V CPU PWR what on earth are the additional 12V PWR lines/socket for? I’m sure when this socket was introduced a number of years ago onto desktop motherboards it was to provide additional power to the ‘power hungry’ new CPUs that had been released at the time, was it not?

Seeing as the 12V PWR and the CPU PWR are all 12V/GND combos, I unplugged the 12V PWR and tested whether it conneced up to any of the 8 pin CPU PWR connector. Needless to say, it plugged straight into the first four pins (presumably for CPU0). I checked the motherboard manual against the colours of the wires going into each pin and the yellow wires were connecting to the 12V pins and the black wires to the GND pins. So it all made sense in my head.

So at this stage, I have a motherboard, 1 CPU installed into CPU0 socket, and two sticks of RAM (the setup requires memory to be installed in pairs). I have the 20 pin ATX power connector plugged into the 24 pin ATX socket. And the 4 pin 12V PWR connector plugged into the first 4 pins of the 8 pin CPU PWR socket.

I bridged the pins that a power on switch should connect to with a small screw driver…. And the system powered up!

So testing my server motherboard with a desktop PSU was actually pretty simple once I thought about it.

One thing to note… As we only hooked up to four of the pins in the CPU PWR socket. Installing the second CPU into the CPU1 socket. The system powers on but never POSTs. This kinda makes sense as the second CPU doesn’t have its CPU PWR connections.

But yeah… I’ve now invested in a new PSU for the server… I paid additional money for a dual redundant PSU caddy, one redundant PSU (yeah I know… only one, just in case the testing i’d done above was telling me lies!). I now have a working new server.

Rapid Fire

February 5th, 2009

My brother wanted to mod an Xbox 360 controller so that one of the triggers could be used in a rapid fire fashion.

There’s things online that suggested he could literally wire one end of one of the LEDs to a switch and the other side of the switch to the middle pin of the variable resistor that creates the variable trigger in the controller. Presumably the crystal on the board is supposed to be hooked up to drive the LED in the controller. But it didn’t seem to work. I didn’t have an oscilliscope handy so I couldn’t see what the signals were doing, so I wasn’t sure if it should work or not anyway. So it was back to the drawing board…

Luckily on his search around the Internet, he’d come across this blog

The principle is simple enough, take a 555 timer, stick a few components on it to set the interval of the timer and hook the timer output up to the controller.

A little measuring around things suggested to me that the variable trigger is simply just a variable resistor. The resistance between ither CW or CCW and the common pin were 2K at one extent and 3K at the other extent. I guess that’s a nice simple way to make a variable trigger work. Knowing the resistances and such, I then measured the voltages between CW and GND, CCW and GND, common and GND. One result was 0V, one was about 1.6V and commond was about 1.3V. That kinda makes sense, as the voltage of the common pin moved between 0V and 1.6V presumably the system would think it was either fully on or fully off. Nice and simple.

Now the Xbox360 controllers are USB, so i’d got 5V and GND to power the 555 chip. I knocked the circuit up quickly, using a 100K variable resistor in place of the 22K and hooked the chip up to the USB 5V and GND pins to power it. Again i’d not got an oscilliscope, but using a voltmeter I could see the output of the 555 was oscillating to some extent.

I was mildly concerned about hooking up the 5V output of the 555 directly to the common point of the triggers variable resistor as the controller was only providing 1.6V maximum as far as I could tell. But seeing as the 3.3V line that my brother had hooked up to it based on the ‘one wire and a switch’ method hadn’t broken anything, we gave it a try anyway.

A few minutes later (and after tweaking the variable resistor a bit) my brother was happy that he would empty the entire clip of what appeared to be a single shot hand gun in Call of Duty in around 1 second, rather than the 3 or so seconds it would take to mash the trigger frantically otherwise.

Working to not working in one simple step.

February 4th, 2009

Don’t you just hate it when something that’s working breaks for no real reason?

I recently bought a new server motherboard, processors, RAM… planning to swap out the parts in an old server. Up until a week or so before the bits arrived the old system was working fine.

Queue swapping out the motherboard etc. with the new ones once they arrive. Hrm, no power. Fiddle around a little and eventually realise the PSU appears to not be working. I fear the worst and wonder if it’s something that i’ve done, but I can’t see any issues with how the new board mounts in the case so i’m certain that there’s no shorting or anything crazy like that.

So it looks to me like the PSU in this old system has just died between now and when it was working perfectly a week ago. New PSU… £145 + VAT. Unless I want the redundant PSU option, which is £160 per PSU, £50 for the PSU ‘connector’ and £20 for a caddy for it to all connect together.

So now, I have no way to work out whether the motherboard actually works, without shelling out at least £145 for a new PSU, which (you never know) could be the actual problem in the first place and have for whatever reason broken my original PSU.

I hate computers sometimes.