Few days ago I’ve created a simple interceptors spike-solution at Github. Its purpose was to show my colleagues that in the EJB’s interceptors you can implement a code that exists in the same transaction and the same security context as the called EJB business method. Moreover, you can benefit from all the dependency injection you need.

This project uses the following resources injected by the Application Server:

  • TransactionSynchronizationRegistry – used for getting current transaction key and checking if we’re in the same transaction (I’ve written about it e.g. here),
  • SessionContext – for reading user’s principal – user’s security context is also available in the interceptor,
  • EntityManager – to persist some data before invoking the business method; it exists in the same transaction as the called method, so either both: the interceptor persistence and business method ends with success or both of them will be rolled-back.

This example also shows how easily you can add RESTful Web Service to your application (take a look at com.piotrnowicki.interceptors.web package).

It also shows that you can define interceptors in the deployment descriptor – without recompilation of your code. Such interceptors will be invoked for every business method in the given module (assuming no exclusion through annotation or DD occurs). An alternative is to define what beans or methods should be intercepted.

Once again Windows know exactly how to surprise me.

I’ve added entries to the Windows/System32/drivers/etc/hosts on my remote Windows 2008 Server. The entry was resolved properly as it could be tested from the command line (ping, telnet, etc.) but in IE and FF browsers it didn’t work.

DNS flushing, clearing browsers data or restart didn’t help a bit. It occurs that the IE had a proxy settings and apparently (when any proxy is set) it refuses to take hosts file under consideration. It affects not only IE but also the FF.

The solution was to remove the proxy setup in IE and from this moment the hosts file entries were resolved properly.

I was trying to find a way to capture the network interface traffic on a remote server, just to see what (or who!) messed up the Web Services based communication.

I didn’t have to search too long, because my favorite capturing software, Wireshark, can listen on a named pipe. So, below you can find the simplest solution I found (SSH + FIFO) [based on this tutorial]:

On the client side (my computer – GNU/Linux) type:

mkfifo /tmp/pipe
ssh user@remote-host "tshark -w - not port 22" > /tmp/pipe

Still on the client side, open another terminal and type:

wireshark -k -i /tmp/pipe

Now type the SSH password in the first terminal. Of course you don’t have to do this if you have configured your connection to use the certificates.

Just remember that on the server side you need to install the console-version of the Wireshark named tshark and to log in as a user which has privileges to capture the network traffic.

Now using your client-side Wireshark you can listen to the traffic which comes to and from your remote server.

I wondered why the same word has different MD5 checksum if I use the PHP md5(-) method and BASH md5sum command. What I mean is:

<?php echo md5("sol"); ?>

The result is:

12313a3d28f802e3a22b07d2e01c6dcf

$ echo "sol"|md5sum

The result is:

56717d999058f0e053d4b580c9396a92


It’s so because the echo command — by default — adds a newline character after its execution, so it really creates a MD5 checksum of:  “sol\n“. To avoid it, you can use the -n echo switch which disables the trailing newline character for this command.

$ echo -n "sol"|md5sum

The result is now:

12313a3d28f802e3a22b07d2e01c6dcf which is what it should be in the first place :-)

If you are looking for a script which will allow you to publish videos on your website – the Flowplayer would be a very good choice. It’s usage is as simple as it can be – you just pass the link to the file you want to be played and that’s it!

The link you’ll provide the script with, need to be an *.flv file which you can obtain using ffmpeg or mencoder. The MP3 files can also be played by Flowplayer – just transcode your *.mp3 file to *.flv.

Posted in WWW.

Today I was wondering how to get rid of files in my “temp” directory.

This “temp”, in time, gets so huge that it seems that there is more stuff in it than on the rest of the disk :-)
Because it’s on the hosted server I was looking for some app that will allow me to explore it’s contents from the WWW.

And so I found the Ajaxplorer project which is quite intuitive and powerful. Just take a look at the demo before you install it.

Posted in WWW.