Hibernate can be a bad choice for client server models

When writing a client-server model in Java it is almost always described using an Object Relational Mapping tool such as Hibernate.There is a lot of pressure to use Hibernate to keep up with the latest technologies. However this causes a lot of problems if the data management is provided by the wrong framework such as BlazeDS. BlazeDS is easy to get running and can be OK for a tiny project, but using something like GraniteDS or maybe LCDS is the only way to go in the longer term. Without this life can be miserable, and I only found out way to late. I now have to rewrite a lot of my code to work around the issues caused by my choice of technologies. I honestly believe that I would have been much, much better using the standards from a decade ago and getting my own Connection manually, handling the Query, the ResultSet and manually re-hydrating my Object. Sometimes the latest technologies are just not progress!

Read More

Prevent USB (Belkin Mini Bluetooth Adapter) from waking computer

A Belkin Mini Bluetooth Adapter adapter was waking a Windows 7 machine. This stops it:

Control panel > Power options > Edit power plan > Change advanced power settings > Sleep > Allow wake timers > Disable

As long as the USB device is disconnected before you send the machine to sleep. As it is an IPhone that is waking the machine, it is necessary to turn off bluetooth on the phone to sever the connection, it can be turned on again immediately. Then the machine can be put to sleep.

It would be better if the entire bluetooth device would have a setting to prevent it waking the computer, but I could not find one. The only solution here seemed to be to turn off the USB controllers ability to wake the computer, and that seems like overkill as I may one day plug another USB device (mouse, keyboard etc.) into that port which I would want to wake the machine.

Debian WPA wireless configuration

Wireless in Linux has always been a pain if you don't have a GUI such as Gnome or KDE. In Debisn 6.03 (Squeeze) add the following to /etc/networking/interfaces:

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
    wpa-ssid YOUR_SSID_HERE
    wpa-proto WPA
    wpa-group TKIP
    wpa-pairwise TKIP
    wpa-key-mgmt WPA-PSK
    wpa-psk YOUR_KEY_HERE

replace wlan0 with your wireless interface name, which you can get by typing 'ifconfig -a' into a konsole. You will need root (or sudo) access to get the 'ifconfig -a' command to output anything.

Firefox looks awful in Kubuntu

While re-configuring KDE (yet again) after deleting ~/.kde in order to get a new configuration, I found that firefox looked terrible. I eventually found this post that suggested installing lxappearance, and as I was desperate I gave it a go. I clicked on my theme 'QtCurve' in the widget panel and changed the font from sans to sherif, and then clicked Apply. Amazingly, Firefox looked a lot better.

I am not sure why this seemed to work, but I will mention that I also uninstalled qtcurve and then reinstalled it - so maybe that was it.

Linux: wake up from sleep from keyboard

Resume From Suspend With Keyboard/Mouse is a post by Bobby Baker that shows how to get a Linux machine to resume from a sleep state by pressing the keyboard. At the end of his post he mentions that some people can't keep the fix after a reboot. I had the problem due to having two USB devices in /proc/acpi/wakeup and echo'ing them both to activate them. When I removed one of the echos, everything worked fine.

 

Read More

Amarok preventing hibernate (Kubuntu 10.10) with remote samba share.

My machines hibernate feature was failing due to Amarok's 'Watch folders for changes' option. This is probably caused as the music partition is mounted from a remote share using Gigalo (but the problem also occurs using Samba/CIFS). Disabling it re-enables hibernate again.

Read More

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure and Database connection failed. Error received from database was #2013: Lost connection to MySQL server at 'reading initial communication packet', system error: 0

For me, deny-hosts caused this error by adding ALL: 127.0.0.1 to the /etc/hosts.deny file.

Read More

NXServer: nxssh process exit with status 255

All of a sudden I couldn't log into the server using NX. I tried re-installing it, re-generating the public/private key pair, reinstalling openssh-server, but all to no-avail. It turned out that the /tmp directory had the permissions changed so that it was not world writable. The syslog with nxnode debugging turned up to 7 gave me the clue.

Read More

Apache, Tomcat, CAS and certified SSL for free on Linux.

I found getting the Apache HTTP server, the Tomcat Servlet Container, Jasig's Central Authentication Service and SSL all configured and working together a complete pain in the arse. This documents a way which works for me without throwing any errors and with the minimum of effort. Even so there is still quite a bit to understand but at least it is now all in one place rather than grabbing small smatterings of information from different places overt the internet (thanks to everyone who has put up the information I have used to compile this).

Read More

Struts2 table with paging ability provided by the pager tag library

I couldn't find any really good examples of using the Struts2 table tag plugin and so decided to provide one. I also didn't really like the implementation of the pager tag that comes with it and so decided to incorporate the pager tag library from JSPTags instead. While this does tie your action to the HttpServletRequest object I found the tag to be easier to understand and use than the one provided by the Struts2 table tag. I also think it is probably possible to not tie yourself to the HttpServletRequest object but I dodn't have that requirement.

Read More

Struts2 s:include and passing parameters

While using the Struts2 <s:include ... > tag with the <s:param ... > I found that I had to convert from Struts2 into JSP and then back into Struts2. This is how I did it and I haven't found a better way so far, the documentation suggested that I am doing it the right way but there may be a more Struts2-ey way.

Read More

Struggling with the <s:action .. /> tag

This was partly my fault but it took me several hours to work out how to use this tag. I found the information on the Struts2 wiki misleading and although it worked a better method is available on the Nabble forums. It was only after I wrote this post that I found out the best way to use this tag. I have updated this post to reflect the improved method.

Read More

Struggling with struts iterator tag and Object[] array

It took me a good 4 hours to work out how to iterate over an Object[] using the Struts2 <s:iterate ... />. I am hoping that either you would have had the same problem or it was because I am drunk and tired! Anyway, this is how to do it.

Read More

Struts2 Spring plugin can be called multiple times at startup

This gave me some trouble as the multiple calls were overriding my calls to set the org.apache.struts2.spring.StrutsSpringObjectFactory setApplicationContext() method. It just happened that my call came in the middle of the two initialisation calls. I should probably dig deeper and find out where the second call comes from but I came up with this solution along the way and have stuck with it for now.

Read More

Adding support for the canonical value of the rel attribute of the link tag in Apache Roller blogging software

I wanted to add the newly supported <link rel="canonical" href="www.example.com/handle/post_title"/> value to my blogs in order to prevent issues with canonicalisation. I had to dig a little to find out how the URL is generated using Apache Roller but this is the code you need.

Read More