Working with OpenXava

This page contains resources designed to assist you in working with OpenXava.

Installation and Configuration

ABL requires the use of Hibernate, either native or JPA, so you must configure OpenXava accordingly.  General instructions are below.  

Note: for specific instructions for the BusLogicDemo OpenXava application, click here.

Define your annotated Domain Objects as shown below:

Configure Hibernate/JPA as shown below:
  1. Configure persistence.xml to 
    1. Identity the Data Source to be used (line 13)
    2. Register ABL as the event listener(line 19)
  2. Configure the Data Source location in context.xml

Basic App Definition

Application construction is unchanged.  Once you define / configure your JPA Beans, you can define the default application.xml file as shown below.  Using this default means you do not need to define html/jsp files, or controllers.

Enable Logging

To ensure you get important logic logging:
  1. Include log4j in your web/WEB-INF/lib folder
  2. Include properties/

Constraint Exception Handling

The screen shot below illustrates the code to translates ABL com.autobizlogic.abl.businesslogicengine.constraintexcp.ConstraintException into javax.validation.ConstraintViolationException, as expected by OpenXava, by using the ExceptionFactoryClass configuration provided by ABL

Commit Configuration

You must also alter the properties/ file entry to be as shown below:

Naviox - menu and user login

You can obtain naviox to provide application menus, and provide user authentication.  In addition to the provided documentation, please note:
  1. Note that on first execution, Naviox will create several tables such as OXUSERS, OXROLES etc.  These will be created in your application's data source.
  2. Take care to merge Naviox files into your project as shown at right (in particular, it is not a separate project, as in project > properties > build path > Projects Eclipse)
    1. The concept is that you already have a fully created, running OpenXava project, into which you want to inject Naviox
  3. The Naviox instructions refer to UpdateOX - note this is a target inside build.xml (located in your project root)
  4. After merging and running UpdateOX, you may need to refresh and clean your project.
  5. Early per-GA Naviox releases had issues with defining new users; as a temporary workaround, make com.openxava.naviox.model.User#encrypt(source) return source, and dropping the OX** tables in your database to force their recreation on the next run 
An example is shown below.  It's rather simple and elegant:
  1. The Module list (on the left) can be opened and closed
  2. The Horizontal Menu (at the top) is built automatically as users execute desired modules

Refresh after Update

Business Logic makes updates to attributes per derivation rules.  In the demo, for example, altering a PurchaseOrder's Paid flag will adjust the Customer's balance.  Recall we had to click the Refresh button to see these effects.

So that End Users can see the results of such changes automatically, you may wish to refresh after updates.  One way is to define an application.xml as show below:

Note in particular the indicated lines:


        <controller name="TypicalNotResetOnSave"/>        



     <controller name="TypicalNotResetOnSave">

        <extends controller="Typical"/>

        <action name="save" mode="detail"





            <set property="resetAfter" value="false"/>



Data Loader

You may find it convenient to develop and test with a version of HQLDB that supports in-memory operation, with options to create the database tables when you open the database.  This section describes how you can use this to simplify test data management.

You may find the idea of a database that disappears when it is closed is at first quite odd.  But, it can be very useful in testing when combined with a DataLoader that initializes the database every time the application starts up:
  • Development - when you run your app, you can be sure of the initial database state.  Updates from prior test runs are no longer a concern

  • Test Suites - you can ensure that each step in a Test Suite is unaffected by preceding tests

  • Logic aware - the DataLoader implementation below loads data through Hibernate/JPA, which thus reflects your business logic.  This means that new derivations are reflected when you restart the application.  It also means your data is checked for correctness because all the constraints are run!
You can configure OpenXava to load your test data illustrated below, and described in the following sub-sections:

DataServer Configuration

Configure your servers/context.xml like this:


The critical part here is the last line: mem instructs HSQL to use an in-memory database, and memdb is just an arbitrary name for that database.

Persistence configured to create tables

As shown in the screen shot above, update your persistence/META-INF/persistence.xml file to include the following:

<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>

<property name="" value="create" />

web/WEB-INF updates
First, create your servlets.xml,and enter its contents as follows:



The parameter (entityForDataCheck) is optional but can be set to the name of a persistent entity. If it is set, the data loader will check whether the database already has data for this entity, and if it does, it will not load any more data.

You must also execute the deployWar (default) target of your project's build.xml.  This will update web.xml (which should normally not be edited directly).

Update lib and classpath

The DataLoader requires these jars:
  1. Place them in web/WEB-INF/lib, and 
  2. Add commons-beanutils and gson to your class path (Select your project, Properties > Java Build Path > Libraries > Add Jars...)

Provide DataLoaderServlet and DataLoader

You must also provide an implementation of the src/buslogicox/dataload/DataLoaderServlet and DataLoader.  You can obtain implementations used in the BusLogicOX Tutorial here:
  1. Create a package called buslogicox.dataload
  2. Copy the unzipped files into this package

Provide Data

The sample DataLoaderServlet reads input data from a json file, as shown in the screen shot above.
  1. Click here to download the sample data (and images) 
  2. Unzip and paste under your projects' persistence folder (verify the folder structure matches the screen shot illustrated above)

You can use the BusLogicOX Tutorial to explore these procedures.

Val Huber,
Jul 7, 2012, 3:17 PM
Val Huber,
Jul 26, 2012, 9:10 AM
Val Huber,
Jul 22, 2012, 4:46 PM
Val Huber,
Jul 20, 2012, 8:53 AM
Val Huber,
Jul 24, 2012, 9:30 PM