[fleXive] Developer Blog

November 29, 2008

Getting started with [fleXive] and Maven 2

Filed under: Development News — Tags: , , , , , , , , — Daniel Lichtenberger @ 11:30

Currently the [fleXive] distribution is based on a set of Apache Ant buildfiles for managing [fleXive] JavaEE projects and performing administration tasks like datasource setup. Although this approach allows for a rather convenient development of new [fleXive] applications, it is neither modular nor particularly well-suited for integration in existing projects.

Thus we decided to add support for the other big build tool, Apache Maven 2. Our goal was to provide a modularized version of [fleXive] that can be added to existing Maven applications by adding a few dependencies.

As of today, our (experimental) Maven repository is online at http://repo.flexive.org/maven2/. It provides all [fleXive] libraries with correct dependencies, as well as a project archetype for a [fleXive] application. In this post, I’ll show how to create a new mavenized project and start the application using an integrated servlet container.

  1. If you haven’t done so already, install Apache Maven.
  2. In a local directory, enter the following command:
    mvn archetype:generate -DarchetypeGroupId=com.flexive -DarchetypeArtifactId=flexive-archetype-ear -DarchetypeVersion=1.0-SNAPSHOT -DarchetypeRepository=http://repo.flexive.org/maven2/ -DgroupId=mygroup -DartifactId=hello-flexive -Dversion=0.1-SNAPSHOT

    This will create a new [fleXive]/EAR project in the directory hello-flexive.

  3. cd hello-flexive
  4. mvn install

    This will compile, package and install the sample application in your local repository, and setup the H2 database schema (when run for the first time.)
    Update 2008/12/18: You can still reset the H2 database manually with mvn install -Pflexive-db-setup-h2.

  5. cd war
  6. mvn jetty:run

    We start an instance of the Jetty WebServer to deploy our application (including the [fleXive] backend application) and OpenEJB. You know that Jetty’s ready to handle requests when it prints the line

    [INFO] Started Jetty Server.

    Update: Depending on your system settings, you may need to increase the memory available for Maven 2 by setting the MAVEN_OPTS environment variable (e.g. EXPORT MAVEN_OPTS="-Xmx512M" on Linux or SET MAVEN_OPTS=-Xmx512M on Windows)

  7. Point your web browser at http://localhost:8080/flexive-backend-war/ and login using the default login privileges (supervisor/supervisor). The [fleXive] initialization scripts will execute, and a fully functional [fleXive] installation is at your hands.
  8. The original intention of course was to develop your own application – open http://localhost:8080/war/ to see a very simple [fleXive] application consisting of a JSF page, a JSF bean, and an EJB that accesses [fleXive] APIs.
  9. To get started, edit hello-flexive/war/src/main/webapp/index.xhtml and watch your changes being applied immediately by the Jetty server. Did I mention that Netbeans 6.5 natively supports Maven projects? More on that in a future post.
  10. You can just package your whole application using mvn package and deploy it on your Glassfish or JBoss server as well.

This project utilizes two major enhancements of the current development (3.1) version: support for the pure Java database H2 (in addition to MySQL), especially suited for development environments, and compatibility with the OpenEJB container. These improvements were necessary to allow us to run in a pure Java environment, without database or application server dependencies.

[Update 2009/09/14: set archetype version to 1.0-SNAPSHOT]

4 Comments »

  1. […] to be resource hogs? It turns out that the combination of Jetty, OpenEJB and H2 mentioned in the Maven integration article is actually relatively lightweight in terms of memory usage (for a JavaEE application, that […]

    Pingback by A [fleXive] server in 150 MB RAM « [fleXive] Developer Blog — December 4, 2008 @ 16:33

  2. […] and contains an embedded MySQL 5.0 installation. Another reason – as Daniel mentioned in his blog entry about Maven – was to be able to download and distribute [fleXive] using the Maven 2.0 buildsystem […]

    Pingback by Porting [fleXive] to the H2 Database « [fleXive] Developer Blog — December 5, 2008 @ 11:41

  3. […] an example create a new project using the current version of our EAR archetype for Maven (instructions). In the “shared” module you find two scripts that will be executed at application […]

    Pingback by Run-once and startup scripts in the classpath « [fleXive] Developer Blog — December 18, 2008 @ 16:00

  4. […] current snapshot versions (currently only available through the automated 3.1-SNAPSHOT Maven builds) include the following […]

    Pingback by Improved result preferences « [fleXive] Developer Blog — April 8, 2009 @ 14:11


RSS feed for comments on this post. TrackBack URI

Leave a comment

Create a free website or blog at WordPress.com.