TOTD# 86: Getting Started with Apache Wicket on GlassFish


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] BUILD SUCCESSFUL
    [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 SelectChannelConnector@0.0.0.0: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] BUILD SUCCESSFUL
    [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:
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
Comments:

[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...

Posted by Arun Gupta's Blog on August 04, 2009 at 11:14 PM PDT #

[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: <...

Posted by Arun Gupta's Blog on August 06, 2009 at 03:44 AM PDT #

[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...

Posted by Arun Gupta's Blog on August 10, 2009 at 10:42 PM PDT #

Post a Comment:
Comments are closed for this entry.
About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today