| Subcribe via RSS

More Warped Wicket

August 17th, 2008 | No Comments | Posted in Java, Wicket

Earlier this year I wrote a post on integrating wicket and warp persist, and I thought it was about time I posted an update, but this time I included working example projects.

The first project is a basic wicket / warp persist setup with hibernate and an apache derby database.  It allows you to persist the Event class used in the hibernate examples.

wicketwarp.zip

The second project is the same, but also makes use of warp-servlet for hooking up all your other servlets and filters in guicy way.

wicketwarpservlet.zip

In both cases i’ve tried to keep xml configuration down to a minimum, as I hate xml config.  So the hibernate classes are configured with hibernate annotations.  Wicket itself involves no xml configuration as always.

As warp persist and warp servlet are not in a maven repository (as far as I know) you will need to manually add them into your maven repository in the normal way.

Thoughts, Code patches, Comments, etc are welcome.

Tags: ,

August update

August 12th, 2008 | No Comments | Posted in General

Just thought that I should write something on here as i’ve been really lazy since i started my new job, so here is a list (we all love lists right?) of what i’ve been up to, in no particular order.

  • New job, we already know that.  But it turns out that if you mention the company name, then it turns up in a google alert at work and everyone reads your blog.  Well not everyone, but some people.  Lucky theres nothing incriminating on here :)
  • Went to see former zoomf college’s band play in the legendary (apparently) Hope and Anchor, and they were quite good.  You can check them out at http://www.myspace.com/thecommissarsmusic.  And now i’ve mentioned zoomf, they are gonna see this in a google alert too.
  • Went to the august london wicket user group, talked about wicket and geeky stuff in general, and drunk beer, the usuall really.  Wicket RAD looks like a really nice project for speeding up application development, if you don’t mind annotations.
  • Went on Team Fortress 2 for the first time in ages, and I still kick ass :)

Thats about it, all the interesting stuff anyway.  I will get round to writing another technical post soon, provided I can think of something worthwhile to write about.

New Job

July 20th, 2008 | 1 Comment | Posted in General

After 13 months at Zoomf, ive decided to move on and I start work for online supermarket Ocado on monday.  This should mean much less messing around with html and css which will be most welcome.

How to run terracotta as a service

July 11th, 2008 | 4 Comments | Posted in Java

I’ve blogged about terracotta before and if you want to find out more about it I suggest you start on their website.

One thing that terracotta doesn’t provide out of the box is a way of running as a background service. While it is pretty easy to run the command in the background with a combination of & and nohup on linux e.g.:

~> nohup start-terracotta-command.sh &

However this doesn’t provide all of the functionally that you might want, like automatic restarts or remote management with JMX. It also doesn’t work on windows (if you care about that).

Luckily it is pretty simple to integrate terracotta with the java service wrapper which is an open source library to run any java program as a service. These are the steps I used to get it working:

  1. Create an environment variable that points to your terracotta install directory, I use $TERRACOTTA_HOME.
  2. Extract the correct version of the service wrapper for your platform inside $TERRACOTTA_HOME, my version was wrapper-linux-x86-32-3.3.0.
  3. Edit your $TERRACOTTA_HOME/wrapper-linux-x86-32-3.3.0/conf/wrapper.conf so it looks something like this:
    wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
    
    wrapper.java.classpath.1=../lib/wrapper.jar
    wrapper.java.classpath.2=../../lib/tc.jar
    
    wrapper.java.library.path.1=../lib
    
    wrapper.java.additional.1=-server
    wrapper.java.additional.2=-Dcom.sun.management.jmxremote
    wrapper.java.additional.3=-Dtc.install-root=../../
    
    wrapper.java.initmemory=256
    
    wrapper.java.maxmemory=256
    
    wrapper.app.parameter.1=com.tc.server.TCServerMain
    wrapper.app.parameter.2=-f ../../tc-config.xml
    
    wrapper.logfile=../logs/terracotta.log
    

    Of course you can customise most of these options fit your requirements (for example memory options or log file) or add additional parameters. Also in the conf file there are other options which you may want to look at such as logging level.

  4. Edit your $TERRACOTTA_HOME/wrapper-linux-x86-32-3.3.0/bin/testwrapper so it looks something like this:
    APP_NAME="Terracotta 2.6.2" 
    APP_LONG_NAME="Terracotta 2.6.2"
     
    WRAPPER_CMD="$TERRACOTTA_HOME/wrapper-linux-x86-32-3.3.0/bin/wrapper"
    WRAPPER_CONF="$TERRACOTTA_HOME/wrapper-linux-x86-32-3.3.0/conf/wrapper.conf"
     
    PIDDIR="$TERRACOTTA_HOME/wrapper-linux-x86-32-3.3.0/"
  5. You should also rename $TERRACOTTA_HOME/wrapper-linux-x86-32-3.3.0/bin/testwrapper to a sensible name e.g. $TERRACOTTA_HOME/wrapper-linux-x86-32-3.3.0/bin/terracotta-wrapper.
  6. You can optionally move this terracotta-wrapper file to a different location, for example /etc/init.d/ on linux.
  7. Thats it. To run use this:
    /etc/init.d/terracotta-wrapper start

    To stop use this:

    /etc/init.d/terracotta-wrapper stop

    You can use ‘restart’ to stop and start the service, ’status’ to see the status of the service and ‘dump’ to take a thread dump of the running java program.

  8. Anything sent to System.out will be logged to the text file defined earlier (wrapper.logfile)

These instructions are only the basic ones needed to get up and running and I recommend that you read through the service wrapper docs so that you get the system that fits best with your requirements.

Please let me know if this is of some use to you, or if you have any other ideas on how to run terracotta as a service.

Tags: ,

Web 2.0 crisis

July 2nd, 2008 | No Comments | Posted in General

I’ve recently had a web 2.0 crisis, specifically I decided that for a computer geek that works for a web 2.0 search engine I needed to be using more web 2.0 services than just facebook and google reader. So to rectify this I have signed up to twitter and and to retaggr.

I’m sure you have all heard about twitter, if you haven’t then what are you doing reading the blog of a computer geek? You can follow me here. I did have a niftly little twitter gadget on this blog, but twitter is a bit unreliable at the moment (overloaded) and was slowing down my page load too much.

Retaggr is a kind of on line profile aggregator, like an online business card. It provides a neat way of showing all of your online accounts, like facebook, linkedin, or last.fm all in one place. They also provide a wordpress plugin so you can retaggr enable your blog. This basically means that if you leave a comment and are signed up to retaggr then your profile card will popup when someone hovers over your name (sign up and make a comment here if you dont believe me). You can see my retaggr profile by clicking on the retaggr button in the right hand side of my blog.

I am also going to sign up to del.icio.us when I get time, which I know isn’t really that new, but is still something that I feel I should be using, especially since I now have nothing to synchronise my firefox bookmarks easily.

p.s. sorry for the over enthusiastic use of the term web 2.0 in this post, I know it doesn’t really mean anything :-)

Tags:

New look

June 29th, 2008 | No Comments | Posted in General

I’ve had the same theme for a while now, so I decided it was time for a change.  I think you will agree that it looks alot better now, thanks to the free Statement theme from here.

Now I just need to brush up on my image editing skills to create a better icon for the top left.

A GMail eureka moment

June 27th, 2008 | No Comments | Posted in General

Today I had a eureka moment with GMail.  As with many other people I get loads of so joke emails with embedded pictures.  Sometimes I get ones which actually are quite funny so I want to forward them on, but up until today GMail would always turn the mail to plain text and remove the images.

Its not just with joke emails either, any email which has embedded images, fancy formatting would get stripped out.

Turns out the solution to this problem is to make GMail send html emails rather than plain text ones.  To do this click ‘Rich formatting’ link just below the subject line.

Thankfully GMail remembers your preference so you won’t need to do it every time.

Happy Emailing :)

Tags:

In the brain of Ari Zilka

June 25th, 2008 | 2 Comments | Posted in Java

Last night I attended a free session at skills matter by the terracotta founder and cto Ari Zilka.

While I was already a terracotta user it was useful to see some other terracotta use cases, apart from http session clustering.

After the session at the pub (where else :) ) I got to talk to Ari about my wicket issues (see my previous post), although I had actually been having a conversation on the terracotta forum with him about it anyway.  Regardless I think its always nice to be able to put a face to someone you have been conversing with on the internet.  It was interesting to hear about the super large scale systems that he has worked on in the past.  I also learned one of the tricks how to sell software in China, which I’m sure will come in handy one day.

I would also like to thank they guy who paid for the drinks, but as I’m terrible with names I managed to forget yours.  Thank you anyway.

Tags:

More on terracotta and wicket

June 22nd, 2008 | 4 Comments | Posted in Java, Wicket, Zoomf

So recently I have been working on session clustering on Zoomf, which is written in apache wicket.

We decided to go down the terracotta route, because at the time we were running on Jetty and I couldn’t get the WADI clustering to work right, plus terracotta claimed to be easy to get up and running, which in fairness it was. All was going to plan and we deployed the code to our production site. Unfortunately we started running into problems. Basically loads of wicket objects were being created and distributed, because of the way wicket stores pages in its session. With the amount of traffic our site was getting the terracotta distributed garbage collector (dgc) couldn’t keep up, and so the persistent disk store was using up more and more disk space. We’re talking tens of gigabytes here, which is clearly a problem.

After playing around with the different terracotta config options it became apparent that a wicket solution to limit what was distributed was needed.

The simplest solution I could think of was instead of storing the wicket pages as page objects I should serialize them and store them as byte arrays instead. This proved to be as easy as implementing a new wicket IPageMapEntry which does the serialization and deserialization and overriding the getPageMapEntry() method in my base page to make all my pages use the new class.

The new class itself is really simple:

public class NewPageMapEntry extends AbstractPageMapEntry
{
        private transient Page page;
        private byte[] data;
 
        public NewPageMapEntry(final Page page)
        {
                this.page = page;
 
                data = Objects.objectToByteArray(page);
 
                setNumericId(page.getNumericId());
        }
 
        @Override
        public Page getPage()
        {
                if(this.page == null)
                {
                        page = (Page) Objects.byteArrayToObject(data);
                }
                return page;
        }
}

With any luck the new code should be running Zoomf next week and on Tomcat too (tomcats terracotta support is more mature than jettys). If are are interested seeing the progress of this you can read this thread on the terracotta forum, which was extremely useful. A big thanks to all the guys who helped me on there!

EDIT:

I am now working on a better way for to integrate wicket and terracotta, see this thread for more information.

Tags: ,

Last week’s london wicket event

June 10th, 2008 | 1 Comment | Posted in Java, Javascript, Wicket

I just thought I’d talk about last weeks wicket event at google.

I gave a presentation on how to integrate google maps and wicket, and while it isn’t the definitive answer on how to do it, should give people some idea where to start.

The code can be checked out from the london wicket google code project and uses maven2 to build so you wont need to worry about those pesky dependencies, if you don’t use maven then you will need the normal wicket jar and jdom.

The slides from my presentation (plus the others too) are also available from the london wicket google group and you should also check out the london wicket website too.

Also if you are wanting to check out a real world example of google maps and wicket integration head over to the map based search page on Zoomf at www.zoomf.com/map.

Tags: ,
View Richard Wilkinson's profile on LinkedIn