Miles to go …

July 29, 2009

TOTD# 86: Getting Started with Apache Wicket on GlassFish

Filed under: web2.0 — arungupta @ 11:00 pm

Apache Wicket is an application framework to build web applications using HTML for markup and POJOs to capture the business logic and all other processing. Why Wicket digs more into the motivation behind this framework.

This Tip Of The Day (TOTD) shows how to create a simple Wicket application and get it running on GlassFish:

  1. Create a Wicket project as:

    ~/samples/wicket >mvn archetype:create -DarchetypeGroupId=org.apache.wicket -DarchetypeArtifactId=wicket-archetype-quickstart -DarchetypeVersion=1.3.6 -DgroupId=org.glassfish.samples -DartifactId=helloworld
    [INFO] Scanning for projects…
    [INFO] Searching repository for plugin with prefix: ‘archetype’.
    [INFO] ————————————————————————
    [INFO] Building Maven Default Project
    [INFO]    task-segment: [archetype:create] (aggregator-style)
    [INFO] ————————————————————————
    [INFO] Setting property: classpath.resource.loader.class => ‘org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader’.
    [INFO] Setting property: velocimacro.messages.on => ‘false’.
    [INFO] Setting property: resource.loader => ‘classpath’.
    [INFO] Setting property: resource.manager.logwhenfound => ‘false’.
    [INFO] [archetype:create]
    [WARNING] This goal is deprecated. Please use mvn archetype:generate instead
    [INFO] Defaulting package to group ID: org.glassfish.samples
    [INFO] —————————————————————————-
    [INFO] Using following parameters for creating OldArchetype: wicket-archetype-quickstart:1.3.6
    [INFO] —————————————————————————-
    [INFO] Parameter: groupId, Value: org.glassfish.samples
    [INFO] Parameter: packageName, Value: org.glassfish.samples
    [INFO] Parameter: package, Value: org.glassfish.samples
    [INFO] Parameter: artifactId, Value: helloworld
    [INFO] Parameter: basedir, Value: /Users/arungupta/samples/wicket
    [INFO] Parameter: version, Value: 1.0-SNAPSHOT
    [INFO] ********************* End of debug info from resources from generated POM ***********************
    [INFO] OldArchetype created in dir: /Users/arungupta/samples/wicket/helloworld
    [INFO] ————————————————————————
    [INFO] ————————————————————————
    [INFO] Total time: 3 seconds
    [INFO] Finished at: Tue Jul 28 15:30:21 PDT 2009
    [INFO] Final Memory: 12M/80M
    [INFO] ————————————————————————
  2. Run it using the pre-configured Jetty plugin as:
    ~/samples/wicket/helloworld >mvn jetty:run
    [INFO] Scanning for projects…
    [INFO] Searching repository for plugin with prefix: ‘jetty’.
    [INFO] ————————————————————————
    [INFO] Building quickstart
    [INFO]    task-segment: [jetty:run]
    [INFO] ————————————————————————
    [INFO] Preparing jetty:run
    [INFO] [resources:resources]
    [INFO] Using default encoding to copy filtered resources.
    [INFO] [compiler:compile]
    [INFO] Compiling 2 source files to /Users/arungupta/samples/wicket/helloworld/target/classes
    [INFO] [resources:testResources]
    [INFO] Using default encoding to copy filtered resources.
    [INFO] [compiler:testCompile]
    [INFO] Compiling 2 source files to /Users/arungupta/samples/wicket/helloworld/target/test-classes
    [INFO] [jetty:run]
    [INFO] Configuring Jetty for project: quickstart
    [INFO] Webapp source directory = /Users/arungupta/samples/wicket/helloworld/src/main/webapp
    [INFO] Reload Mechanic: automatic
    [INFO] Classes = /Users/arungupta/samples/wicket/helloworld/target/classes
    2009-07-28 15:31:35.820::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
    [INFO] Context path = /helloworld
    [INFO] Tmp directory =  determined at runtime
    [INFO] Web defaults = org/mortbay/jetty/webapp/webdefault.xml
    [INFO] Web overrides =  none

    . . .

    INFO  – WebApplication             – [WicketApplication] Started Wicket version 1.3.6 in development mode
    *** WARNING: Wicket is running in DEVELOPMENT mode.              ***
    ***                               ^^^^^^^^^^^                    ***
    *** Do NOT deploy to your live server(s) without changing this.  ***
    *** See Application#getConfigurationType() for more information. ***
    2009-07-28 15:31:37.333::INFO:  Started [email protected]:8080
    [INFO] Started Jetty Server

    And the default web page is available at “http://localhost:8080/helloworld” and looks like:

    A later blog will show how to run this application using Embedded GlassFish. But for now lets package the application as a WAR file and deploy it on GlassFish.

  3. Download GlassFish v3 Preview and unzip.
  4. Create a WAR file as:
    ~/samples/wicket/helloworld >mvn package
    [INFO] Scanning for projects…
    [INFO] ————————————————————————
    [INFO] Building quickstart
    [INFO]    task-segment: [package]

    . . .

    [INFO] Processing war project
    [INFO] Webapp assembled in[494 msecs]
    [INFO] Building war: /Users/arungupta/samples/wicket/helloworld/target/helloworld-1.0-SNAPSHOT.war
    [INFO] ————————————————————————
    [INFO] ————————————————————————
    [INFO] Total time: 6 seconds
    [INFO] Finished at: Tue Jul 28 15:35:59 PDT 2009
    [INFO] Final Memory: 14M/80M
    [INFO] ——————————————

    and deploy as:

    ~/samples/wicket/helloworld >~/tools/glassfish/v3/preview/glassfishv3/bin/asadmin deploy target/helloworld-1.0-SNAPSHOT.war

    Command deploy executed successfully.

    The app is now accessible at “http://localhost:8080/helloworld-1.0-SNAPSHOT” and looks like:

Cool, that was pretty straight forward!

Now that’s a very vanilla application but at least shows that Wicket applications can be deployed on GlassFish out-of-the-box. A slightly more complex application will be shared on this blog in future.

Here are some more useful links for Wicket:

  • Wicket Quickstart shows how to create a Wicket application and get started easily.
  • Wicket Examples provide a flavor of how the code is structured.
  • Wicket in Action is a great book that explains the concepts very well.
  • May want to look at wicket-extensions for a list of gadgets/widgets that extend the core capability of the framework.

A few related blog posts planned:

  • Run Wicket application using Embedded GlassFish
  • Use Servlet 3.0 web-fragments.xml and leverage GlassFish v3 Pluggability to run Wicket applications
  • A Wicket version of Track your running miles application
  • Deploying Wicket applications from NetBeans to GlassFish

In the meanwhile, let us know if you are deploying your Wicket applications on GlassFish.

Please leave suggestions on other TOTD that you’d like to see. A complete archive of all the tips is available here.

Technorati: totd wicket glassfish netbeans

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • Facebook
  • Google Bookmarks
  • DZone
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
Related posts:
  1. TOTD #91: Applying Java EE 6 “web-fragment.xml” to Apache Wicket – Deploy on GlassFish v3
  2. TOTD #100: Getting Started with Scala Lift on GlassFish v3
  3. TOTD #89: How to add pagination to an Apache Wicket application
  4. TOTD #56: Simple RESTful Web service using Jersey and Embeddable GlassFish – Text and JSON output
  5. Getting Started with Grails on GlassFish


  1. [Trackback] TOTD #86 explained how to get started with deploying a Apache Wicket application on GlassFish. This Tip Of The Day (TOTD) will show how to add pagination to your Wicket application. The blog entry "JPA/Hibernate and Wicket Repeating Views…

    Comment by Arun Gupta's Blog — August 5, 2009 @ 6:14 am

  2. [Trackback] Now that Apache Wicket 1.4 is available, migrating from previous versions is pretty straight forward. Change the version in your POM file as: <wicket.version>1.4.0</wicket.version> And that’s it! The complete dependency may look like: <…

    Comment by Arun Gupta's Blog — August 6, 2009 @ 10:44 am

  3. [Trackback] "Extensibility" is a major theme of Java EE 6. This theme enables seamless pluggability of other popular Web frameworks with Java EE 6. Before Java EE 6, these frameworks have to rely upon registering servlet listeners/filters in "web.xml" or…

    Comment by Arun Gupta's Blog — August 11, 2009 @ 5:42 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Powered by WordPress