If you are using MySQL and Hibernate, maybe you are familar with an exception like this one:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was79095 seconds ago.The last packet sent successfully to the server was 79095 seconds ago, which is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

To me, this problem occurred whenever my web application was not used for a certain amount of time. For some reason, Hibernate (?) does not close the connection properly, but the database system does after the wait_timeout has passed. Now Hibernate wants to use a connection that is not valid any more.

It took me some effort to overcome this problem, but I figured out a clean solution (setting the ‘wait_timeout’ setting of mysqld to days or weeks is NOT a good approach ;)).

The trick is to use connection pooling with c3p0. This way, you can make sure that a connection is revalidated after being idle for a long time. Configuration is quite easy. Just add the following properties to your Hibernate configuration (persistence.xml or hibernate.cfg.xml):

<property name="hibernate.c3p0.min_size" value="3" />
<property name="hibernate.c3p0.max_size" value="50" />
<property name="hibernate.c3p0.timeout" value="1800" />
<property name="hibernate.c3p0.max_statements" value="50" />
<!– this property forces the revalidation of a connection after the given amount of time (in secs) –>
<!– it must be set to LESS than the wait_timout setting for the mysql server (this setting defaults to 28800 secs (8 hours)) –>
<property name="hibernate.c3p0.idle_test_period" value="28680" />

Furthermore, you have to add the c3p0 jar to the classpath of your application.

Well, currently I’m working on my project filesio, a platform for distributing large files via web interface instead of FTP.

One of the core abilities of my application is to provide widgets for third-party sites, allowing my users to include download-links to their files in their own web pages. These widgets are simple iframes that load content from my domain.

However, when implementing my app I struggled with the problem that Microsoft Internet Explorer per default blocks cookies set from within an iframe (of course, all other browsers don’t do this).

Lucklily, I found a really ..hm…interesting solution for this problem:

Read more…

There are a lot of commercial stress and load testing tools available, but in general they are really expensive, so buying one is probably not the best idea if you just want to stress-test a single web application for one time, like I did.

Instead, I checked out some Open Source tools and found Webload, an Open Source variant of a more comprehensive tool developed by Radview. The download can be found here (it’s not available on the official website any more).

The tool comes with a graphical user interface both for creating test scripts (Webload IDE) and for launching and monitoring tests (Webload console).

Scripts can be recorded by simply clicking links in your browser. Afterwards, the script can be used to create the actual test, consisting of an arbitrary number of virtual users that follow the actions defined in the script. Webload allows monitoring of any values you can think of, ranging from the number of executed requests to throughput in bytes per second.

Because of all those features that seem unique for an Open Source stress test tool, Webload is really worth a tip here at codingclues :)

Well, the following post does not cover a typical programming topic, but maybe even as a software engineer you might have to deal with (web) design from time to time. At least I did when developing a new website for a customer (http://heilmann-software.de).

While creating shiny and glossy effects seems to be a trivial task for the experts using Photoshop, I tried a lot until I got some good results with Gimp, the Open Source image editor.

My goal was to develop a “shiny table” effect from a screenshot that was rotated into the view. Below you can see an example (of the result, of course ;))

Read more…

If you have ever wondered what the nice color names from the .NET Color structure in namespace System.Drawing.Color actually mean, you will find this page very useful.
They present a listing of the named colors in .NET, show how they look like and also specify the corresponding hexadecimal values.

When designing or coding a website, there is an easy method for including favicons next to the links. You cannot assume that a favicon is always at /favicon.ico of the URL, as there are different ways to specify which favicon a browser should display!

Read more…

Today I want to introduce my new project Cloud42, an Open Source management framework for Cloud Computing with Amazon EC2.
This is not intended to be a dumb advertisement. Instead, the main cause for this post here is that Cloud42 is very interesting for developers and therefore can be of value for you, too.

Cloud42 is a web application written in Java. It provides both a AJAX-enabled GUI and an extensive Web service interface, allowing you to invoke its functionalities from your own application or from within BPEL processes.

Besides the basic functionalities like starting, stopping and monitoring EC2 AMI instances, Cloud42 offers some enhanced functions like transferring files and bundling new AMIs. Furthermore, it is possible to control your instances remotely by sending arbitrary commands through the Web service interface (or by using the GUI). A notification mechanism following the publish/subscribe pattern allows you to subscribe any endpoint to events that occur on an AMI instance.

This sounds interesting? Then visit the website at cloud42.net!
And don’t forget to drop a comment here!

While YouTube has an API to get thumbnails of its videos, there is also the possibility to construct the URLs of the thumbnails out of the URL of the video.

Read more…