Thursday, August 13, 2009

Hello World Wicket Development without the Maven burden

For most of us in Nigeria (this does not apply to the privileged few) learning a new technology nowadays is usually a challenge. Imagine a situation where I am trying to learn how to use a technology like Tapestry 5 or Wicket for the first time and having to pick up another technology like Maven. Don't get me wrong Maven is cool (hope the Ant people are not annoyed. Ant is cool too).

Okay I was in my little room feeling happy that I had just downloaded the Wicket 1.4 stable release using a free connection (I don't have one at home don't ask why) and I would like to try it out with its support for generics among others. I open up my Eclipse 3.4.0 and then I remember what happened when I first used Wicket 1.3 (refer to the Wicket Quickstart if you don't know what I am blabbing about). No Maven on this computer and no Internet. Damn. Hence this post was written to teach you how to use Wicket without relying on Maven. Read on if you are interested.

This post assumes that you are familiar with Java, Eclipse (with the Java EE perspective) and that you have downloaded Wicket 1.4. Your Eclipse environment should also have been setup to run on a server like Apache Tomcat 6.

These are the basic steps:
a) In your Eclipse IDE start a new Dynamic Web Project (name the project HelloWorldWicket)

b) Unzip your Wicket download to anywhere you like (for example, C:\apache-wicket-1.4.0)

c) Navigate to the lib folder under the the folder where you unzipped Wicket and copy the file named wicket-1.4.0.jar to the WEB-INF/lib of your Eclipse project.

d) Create 2 Java class files and under the package helloworld (copy and paste the code for these files from this post)

e) Create an html file called HelloWorld.html and place it in the sample package folder as the (copy and paste the code for this file from this post)

f) Copy and paste the code for the web.xml file from this post and replace the WEB-INF/web.xml file in your eclipse project.

g) If you try to run the project now your will get an error java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory. The tricky part starts now

h) Navigate to the lib folder under the the folder where you unzipped Wicket. You will see a file called wicket-examples-1.4.0.war. Use the jar command to unzip the WEB/lib folder (for those that do not know the command is "<path_to_java_jdk_installation>/bin/jar -xvf <path_to_unzipped_wicket>/wicket-examples-1.4.0.war WEB-INF/lib" without the curly braces). The files we are interested in are called log4j-1.2.13.jar, slf4j-api-1.4.2.jar and slf4j-log4j12-1.4.2.jar. Copy these files to the WEB/lib of your Eclipse project and run the application. You should now see a nice Hello World by navigating your browser to http://localhost:8080/HelloWorldWicket/

Hope this post is useful. As I promised the code for this post is found below.
package helloworld;

import org.apache.wicket.Page;   
import org.apache.wicket.protocol.http.WebApplication;

public class HelloWorldApplication extends WebApplication {
    public Class getHomePage() {      
        return HelloWorld.class;    
package helloworld;  

import org.apache.wicket.markup.html.WebPage; 
import org.apache.wicket.markup.html.basic.Label;  

public class HelloWorld extends WebPage {  
    public HelloWorld() {      
        add(new Label("message""HelloWorld"));    

<span wicket:id="message" id="message" />
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="" xmlns="" xmlns:web="" xsi:schemaLocation="" id="HelloWorldWicket" version="2.5">

Monday, July 27, 2009

My First Post - Fun and Supposedly Meaningless

Thank God it seems I am finally able to post something. Awesome... I wasn't sure what it should be so I decided to practice with this somewhat meaningless writeup. Not much for my first post right.
Some of my posts may be tutorial-style while others may be just random babbling. When they do seem like random babbling take note that I have probably been overworked and I am probable just letting off some steam.
I am hoping that some of my posts will be useful to some people just as the posts of others have been useful to me (the 80-20 rule).
Have fun.....