Wednesday Sep 30, 2009

Running Summary Q3 2009 – 400 miles, 80% of running days

Here is the summary of my running logs from Q3 2009 (Jul - Sep):

Even though 3 days of less running than Q2, but the overall mileage was increased. Barely hit that 400 miles mark in Q3 and it did took some extra efforts to reach there ;-) But now tapering for the upcoming Rock-n-Roll 1/2 Marathon this weekend.

5 miles was the most favorite distance being run 17 times and 19.7 miles and 17.4 miles were run only once.

Would you like to generate similar charts for your running logs as well ?

This can be easily achieved using a Rails application or a Wicket application on GlassFish.

Technorati: rails wicket glassfish running rnrsj

Wednesday Sep 02, 2009

Track your running miles using Apache Wicket, GlassFish, NetBeans, MySQL, and YUI Charts

Track your running miles using Apache Wicket, GlassFish, NetBeans, MySQL, and YUI Charts

An earlier blog introduced an application that provides basic tracking of your running distance and generate charts to monitor progress. The idea is to build the same application using different Web frameworks and deploy on GlassFish and then evaluate each framework based upon a pre-defined critieria. The first version was built using JRuby and Ruby-on-Rails. This blog announces the completion of the Apache Wicket version of the application.

All efforts have been applied to ensure a consistent look-and-feel with the original application but there are minor inconsistencies to leverage the default behavior of the framework.

First here are some snapshots of the application deployed on GlassFish b3 build 61.

The home page looks like:

Here is a summary of all the runlogs:

All the records can be easily paginated through. There are a few validations while adding a new run:

The "datepicker" widget is used for selecting custom dates as shown in the following page:

Here is a line chart of last 30 days of running:

Notice, it also shows the complete summary as well. And finally a barchart for the entire year so far:

The complete instructions to check out and run the Wicket version of this application are available here.

Now comes the time to provide feedback on the Wicket framework based upon my experience of developing this application. The evaluation criteria is explained in detail here.

The feedback may be attributed to my ignorance of the Wicket framework. If so, please feel free to post a comment and I'll be happy to fix.

  1. MVC separation: Wicket promotes MVC architecture by providing abstract wrappers over model but the actual implementation still needs to be plugged. For example, the controllers need to written from scratch anyway. There is no recommended directory structure that makes MVC inherent. This is related to the fact that Wicket is not a full-stack framework (more on this below).

    The framework provides a clean separation between views in HTML/CSS and business logic using POJO. However a lot (quite a lot) of glue code needs to be written to stitch them together. And it gets verbose really fast because of the multiple inner classes that keeps popping everywhere in the Java code. Also by default POJO and HTML are packaged together and mixing views/models in the same directory is very confusing.
  2. DRY and CoC principles: The framework neither explicitly promote or prohibit DRY or CoC. The standard HTML/CSS/Java techniques can be used to achieve DRY. And because there is no generated code, there is no concept of CoC.
  3. Limited Ajax: The framework provides buttons/links that can make an Ajax request to the back end. But there is no explicit abstraction of XmlHTTPRequest in the framework. And so an external JavaScript library needs to pulled (Prototype in this case) for any direct Ajax invocations.

    The documentation on wicketstuff-prototype is kinda unclear on how the integration works.
  4. ORM: Apache Wicket is a framework for creating UI applications and that's exactly what it is, nothing beyond. It is not comparable with full stack frameworks like Java EE, Rails or Grails which provides a persistence mechanism, database connectivity, full MVC support, security and other similar features. As a result, this application could not be built using only Wicket. For example, Java Persistence API (JPA) was used for database access and Prototype was used for Ajax functionality. JPA and Prototype are just the chosen ones among other multiple options available.
    1. CRUD generation: Creating a basic CRUD applications required putting together a bunch of POJOs, corresponding HTML pages, JPA controllers and stitching them together.
    2. Table creation: Defined by the chosen persistence library.
    3. Loading data in the table: Defined by the chosen persistence library.
    4. Customizing queries: Defined by the chosen persistence library.
  5. Customization
    1. CSS & JavaScript: Standard HTML, CSS, and JavaScript techniques for packaging are used.
    2. Form Validation & Default Error Handling: There are validators available to enable basic checking like required, number / pattern / range / date validator. Anything above that needs to be custom built and adds to the verbose nature of the framework. For example a "FormValidator" was built to support the validation for each elements of the form. Custom messages for each validation message can be displayed as explained here. More user-friendly messages can be displayed as explained here.
    3. Templates: The template mechanism is really flexible and allows the repetitive code to be easily captured using "markup inheritance".
  6. 3rd Party Libraries: Adding 3rd-party libraries is quite a breeze because standard HTML/CSS/JavaScript integration techniques are used.
    1. Plugins: Wicket-extensions has some components in addition to the core framework. Wicket-stuff provides components that complement the core framework. The core functionality can be extended using wicket-stuff.
    2. Date picker: There are corresponding packages available for YUI, e.g. "org.apache.wicket.extensions.yui.calendar" for adding DatePicker widget.
    3. Pagination was quite simple to implement.
  7. IDEs: NetBeans provides the most advanced support for Wicket development. But the recommended way is to start with a Maven project and NetBeans provide good support for that as well. More on IDE support here. The Edit/Save/Deploy/Refresh cycle required by the Jetty is time consuming though.
  8. Browser Compatibility: The app was tested on Firefox 3.5.2 (on Mac), Safari 4.0.3 (on Mac) and IE 7.0.600.118000 (on Windows Vista) and no issues were encountered.
  9. Production Deployment: Generating a production deployment on GlassFish is very straight forward because of Maven, just create a WAR file using "mvn package" and deploy directly.
  10. Maintainability: The framework requires a good grasp of Object Oriented concepts like inheritance, encapsulation and inner classes. Even though these concepts are very powerful but they can be a maintenance nightmare. Also, the verbose nature of framework will likely make it cumbersome as a maintenance effort. However there is no real experience or feedback in this area.
  11. Any outstanding feature ? - The response time on the Wicket user list is truly outstanding. Most of my issues encountered during the development phase were resolved by asking questions there.
  12. Any pain point ? - As with any new framework, there is always a learning curve. The framework has a large set of APIs and so it takes a while to figure how the pieces fit together and can be assembled together to create a solution. If you are developing with Wicket, then the official documentation is pretty minimal and not much helpful. The very first link in the documentation actually points to Books on Wicket which is indeed a key resource. I borrowed "Wicket in Action" book from a colleague and it turned out to be helpful. But unfortunately the API has evolved since the book was released and so some of the recommendations from the book are already deprecated. The Wicket user list is definitely a very responsive resource and help me build a better understanding of the framework. Wicket Stuff provides a good set of examples as well with complete source code. But even here some of the samples are using deprecated APIs. Another pain point is that "search engine-driven development" paradigm cannot be applied easily because the search results are a mix from the pre- and post-Apache versions of blogs/docs/etc.
The latest version of this evaluation is available here.

TOTD #86 explains how to get started with using Apache Wicket and GlassFish. All other Wicket related entries on this blog are here.


Technorati: wicket glassfish netbeans mysql yahoo yui chart running miles framework

Monday Aug 10, 2009

TOTD #91: Applying Java EE 6 "web-fragment.xml" to Apache Wicket - Deploy on GlassFish v3


"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 some other similar mechanism to register the framework with the Web container. Thus your application and framework deployment descriptors are mixed together. As an application developer you need to figure out the magical descriptors of the framework that will make this registration.

What if you are using multiple frameworks ? Then "web.xml" need to have multiple of those listeners/servlets. So your deployment descriptor becomes daunting and maintenance nightmare even before any application deployment artifacts are added.

Instead you should focus on your application descriptors and let the framework developer provide the descriptors along with their jar file so that the registration is indeed magical.

For that, the Servlet 3.0 specification introduces "web module deployment descriptor fragment" (aka "web-fragment.xml"). The spec defines it as:

A web fragment is a logical partitioning of the web app in such a way that the frameworks being used within the web app can define all the artifacts without asking devlopers to edit or add information in the web.xml.

Basically, the framework configuration deployment descriptor can now be defined in "META-INF/web-fragment.xml" in the JAR file of the framework. The Web container picks up and use the configuration for registering the framework. The spec clearly defines the rules around ordering, duplicates and other complexities.

TOTD #86 explained how to get started with Apache Wicket on GlassFish. This Tip Of The Day (TOTD) explains how to leverage "web-fragment.xml" to deploy a Wicket application on GlassFish v3. The basic concepts are also discussed here.

For the "Hello World" app discussed in TOTD #86, the generated "web.xml" looks like:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4">

        <display-name>helloworld</display-name>

         <!-- 
              There are three means to configure Wickets configuration mode and they are
              tested in the order given.
              1) A system property: -Dwicket.configuration
              2) servlet specific <init-param>
              3) context specific <context-param>
              The value might be either "development" (reloading when templates change)
              or "deployment". If no configuration is found, "development" is the default.
        -->

        <filter>
                <filter-name>wicket.helloworld</filter-name>
                <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
                <init-param>
                        <param-name>applicationClassName</param-name>
                        <param-value>org.glassfish.samples.WicketApplication</param-value>
                </init-param>
        </filter>

 <filter-mapping>
  <filter-name>wicket.helloworld</filter-name>
        <url-pattern>/\*</url-pattern>
 </filter-mapping>


</web-app>

This deployment descriptor defines a Servlet Filter (wicket.helloworld) that registers the Wicket framework with the Web container. The filter specifies an initialization parameter that specifies the class name of the Wicket application to be loaded. And it also contains some other information that is also relevant to the framework. None of this application is either required or specified by the application. And so that makes this fragment a suitable candidate for "web-fragment.xml".

Here are the simple steps to make this change:
  1. Remove "src/main/webapp/WEB-INF/web.xml" because no application specific deployment descriptors are required.
  2. Include "wicket-quickstart-web-fragment.jar" in the "WEB-INF/lib" directory of your application by adding the following fragment in your "pom.xml":

        <dependencies>

            . . .
            <!-- web-fragment -->
            <dependency>
                <groupId>org.glassfish.extras</groupId>
                <artifactId>wicket-quickstart-web-fragment</artifactId>
                <version>1.0</version>
                <scope>runtime</scope>
            </dependency>
        </dependencies>

       . . .

        <repositories>
            <repository>
                <id>maven2-repository.dev.java.net</id>
                <name>Java.net Repository for Maven</name>
                <url>http://download.java.net/maven/2/</url>
            </repository>
        </repositories>

    This file contains only "META-INF/web-fragment.xml" with the following content:

    <web-fragment>
            <filter>
                    <filter-name>wicket.helloworld</filter-name>
                    <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
                    <init-param>
                            <param-name>applicationClassName</param-name>
                            <param-value>org.glassfish.samples.WicketApplication</param-value>
                    </init-param>
            </filter>

            <filter-mapping>
                    <filter-name>wicket.helloworld</filter-name>
                    <url-pattern>/\*</url-pattern>
            </filter-mapping>
    </web-fragment>

  3. Create the WAR file without "web.xml" by editing "pom.xml" and adding the following fragment:

          <plugins>
                . . .
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1-beta-1</version>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
                . . .
          </plugins>

That's it, now you can create a WAR file using "mvn package" and deploy this web application on GlassFish v3 latest promoted build (58 as of today) as explained in TOTD #86.

The updated WAR file structure looks like:

helloworld-1.0-SNAPSHOT
helloworld-1.0-SNAPSHOT/META-INF
helloworld-1.0-SNAPSHOT/WEB-INF
helloworld-1.0-SNAPSHOT/WEB-INF/classes
helloworld-1.0-SNAPSHOT/WEB-INF/classes/log4j.properties
helloworld-1.0-SNAPSHOT/WEB-INF/classes/org
helloworld-1.0-SNAPSHOT/WEB-INF/classes/org/glassfish
helloworld-1.0-SNAPSHOT/WEB-INF/classes/org/glassfish/samples
helloworld-1.0-SNAPSHOT/WEB-INF/classes/org/glassfish/samples/HomePage.class
helloworld-1.0-SNAPSHOT/WEB-INF/classes/org/glassfish/samples/HomePage.html
helloworld-1.0-SNAPSHOT/WEB-INF/classes/org/glassfish/samples/WicketApplication.class
helloworld-1.0-SNAPSHOT/WEB-INF/lib
helloworld-1.0-SNAPSHOT/WEB-INF/lib/log4j-1.2.14.jar
helloworld-1.0-SNAPSHOT/WEB-INF/lib/slf4j-api-1.4.2.jar
helloworld-1.0-SNAPSHOT/WEB-INF/lib/slf4j-log4j12-1.4.2.jar
helloworld-1.0-SNAPSHOT/WEB-INF/lib/wicket-1.4.0.jar
helloworld-1.0-SNAPSHOT/WEB-INF/lib/wicket-quickstart-web-fragment-1.0.jar

Notice, there is no "web.xml" and the additional "wicket-quickstart-web-fragment-1.0.jar" and everything works as is!

It would be nice if the next version of wicket-\*.jar can include "META-INF/web-fragment.xml" then everything will work out-of-the-box :)

Here is a snapshot of the deployed application:



Are you deploying your Wicket applications on GlassFish ?


Technorati: totd glassfish v3 wicket javaee6 servlet web-fragment

Wednesday Aug 05, 2009

TOTD #90: Migrating from Wicket 1.3.x to 1.4 - "Couldn't load DiskPageStore index from file" error


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:

<dependency>
  <groupId>org.apache.wicket</groupId>
  <artifactId>wicket</artifactId>
  <version>1.4.0</version>
</dependency>

or

<dependency>
  <groupId>org.apache.wicket</groupId>
  <artifactId>wicket</artifactId>
  <version>${wicket.version}</version>
</dependency>

You may encounter the following error:

2009-08-05 05:58:49.387::INFO:  No Transaction manager found - if your webapp requires one, please configure one.
ERROR - DiskPageStore              - Couldn't load DiskPageStore index from file /Users/arungupta/workspaces/runner~subversion/wicket/runner/target/work/wicket.runner-filestore/DiskPageStoreIndex.
java.lang.ClassNotFoundException: org.apache.wicket.util.concurrent.ConcurrentHashMap
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:319)

At least I did :)

Fortunately the fix is simple and intuitive. Instead of running "mvn jetty:run", invoke the command:

mvn clean jetty:run

Basically, "clean" will clean out references to older version of Wicket jars in your project and voila!

If you are deploying as WAR file, then bundle Wicket jars in WEB-INF/lib instead of copying them to the shared folder of your application server.

Other Wicket tips on this blog are available here. Specifically TOTD #86 shows how to get started with Apache Wicket on GlassFish.

Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. A complete archive of all the tips is available here.

Technorati: wicket glassfish migration

Tuesday Aug 04, 2009

TOTD #89: How to add pagination to an Apache Wicket application


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 with Netbeans" Part 1 and 2 explain in detail how to create a CRUD application using NetBeans, JPA, Hibernate and Wicket. This blog uses the data created in TOTD #38 for the database table.
  1. After creating the JPA Controller, adding the IDataProvider and DataView implementations and hooking together, the application is available at "http://localhost:8080/helloworld" and looks like:



    As noticed in the output, all the states are listed in one page. The HTML markup looks like:

    <html>
        <head>
            <title>Wicket Quickstart Archetype Homepage</title>
        </head>
        <body>
            <strong>Wicket Quickstart Archetype Homepage</strong>
            <br/><br/>
            <span wicket:id="message">message will be here</span>
            <table>
                <tr>
                    <th>ID</th>
                    <th>Abbreviation</th>
                    <th>Name</th>
                </tr>
                <tr wicket:id="rows">
                    <td><span wicket:id="id">ID</span></td>
                    <td><span wicket:id="abbrev">Abbreviation</span></td>
                    <td><span wicket:id="name">Name</span></td>
                </tr>
            </table>

        </body>
    </html>

    The backing POJO looks like:

    package org.glassfish.samples;

    import java.util.Iterator;
    import org.apache.wicket.PageParameters;
    import org.apache.wicket.markup.html.basic.Label;
    import org.apache.wicket.markup.html.WebPage;
    import org.apache.wicket.markup.repeater.Item;
    import org.apache.wicket.markup.repeater.data.DataView;
    import org.apache.wicket.markup.repeater.data.IDataProvider;
    import org.apache.wicket.model.CompoundPropertyModel;
    import org.apache.wicket.model.IModel;
    import org.apache.wicket.model.LoadableDetachableModel;
    import org.glassfish.samples.controller.StatesJpaController;
    import org.glassfish.samples.model.States;

    /\*\*
     \* Homepage
     \*/
    public class HomePage extends WebPage {

        private static final long serialVersionUID = 1L;

        // TODO Add any page properties or variables here

        /\*\*
         \* Constructor that is invoked when page is invoked without a session.
         \*
         \* @param parameters
         \*            Page parameters
         \*/
        public HomePage(final PageParameters parameters) {

            // Add the simplest type of label
            add(new Label("message", "If you see this message wicket is properly configured and running"));

            // TODO Add your page's components here

                    // create a Data Provider
            IDataProvider statesProvider = new IDataProvider() {
                public Iterator iterator(int first, int count) {
                    StatesJpaController sc = new StatesJpaController();
                    return sc.findStatesEntities(count, first).iterator();
                }

                public int size() {
                    StatesJpaController sc = new StatesJpaController();
                    return sc.getStatesCount();
                }

                public IModel model(final Object object) {
                    return new LoadableDetachableModel() {
                        @Override
                        protected States load() {
                            return (States)object;
                        }
                    };
                }

                public void detach() {
                }
            };

            // TODO Add your page's components here

            DataView dataView = new DataView("rows", statesProvider) {

                @Override
                protected void populateItem(Item item) {
                    States state = (States)item.getModelObject();
                    item.setModel(new CompoundPropertyModel(state));
                    item.add(new Label("id"));
                    item.add(new Label("abbrev"));
                    item.add(new Label("name"));
                }
            };

            add(dataView);
        }
    }

    and "persistence.xml" looks like:

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
      <persistence-unit name="helloworld" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>org.glassfish.samples.model.States</class>
        <properties>
          <property name="hibernate.connection.username" value="app"/>
          <property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.ClientDriver"/>
          <property name="hibernate.connection.password" value="app"/>
          <property name="hibernate.connection.url" value="jdbc:derby://localhost:1527/sample"/>
        </properties>
      </persistence-unit>
    </persistence>
  2. Lets add pagination to this simple sample.
    1. In the POJO, change DataView constructor so that it looks like:

              DataView dataView = new DataView("rows", statesProvider, 5)

      where "5" is the number of entries displayed per page. Alternatively you can also set the number of items per page by invoking:

      dataView.setItemsPerPage(5);

    2. In the HTML page, add the following right after "<table/>":

      <span wicket:id="pager">message will be here</span><br>

      as the last line. This is the placeholder for pagination controls.
    3. In the POJO, add the following:

              PagingNavigator pager = new PagingNavigator("pager", dataView);
              add(pager);

      right after "add(dateView);".

      The output now looks like:



      and clicking on ">" shows:



      And finally clicking on ">>" shows



      The information is now nicely split amongst multiple pages.
So just adding a pagination controls placeholder in the HTML and a corresponding configuration in DataView (in the backing POJO) did the trick for us.

Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. A complete archive of all the tips is available here.

Technorati: wicket glassfish pagination

Wednesday Jul 29, 2009

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