Building and testing ADF applications with Maven, JSFUnit, Arquillian and Embedded Glassfish

Some time ago I have been playing with Java Server Faces 2.0 (e.g. JSF 2) and JSFUnit in combination with Arquillian and Embedded Glassfish as a Proof Of Concept for unit testing JSF applications.

As our applications are being developped with the Oracle ADF framework, I was wondering if it would be possible to do the same with ADF based applications.  The purpose is to build ADF applications with Maven, which is not that hard, but also test it on an Embedded Glassfish, which is quite challenging.  Once this is working, we could use Jenkins as our continuous integration platform.

The first challenge was to determine the required ADF libraries.  As those libraries are defined as a shared library in Weblogic, I had to determine which where needed to make the ADF application run on Glassfish.  To do this, I added the libraries one by one until the ClassNotFoundExceptions were gone.

Then I made a script (e.g. bat-file) which installs all those libraries in my local Maven repository.  I also made some parent POM’s so I could bundle some related libraries together in a logical way.  I know that the latest JDevelopper has an option to install those ADF libraries in Maven, but I wanted to do it manually.

Once this was done, it was only a matter of configuring Arquillian to deploy the ADF application on the Embedded Glassfish.  As I previously did a POC with JSF 2 and Arquillian, most of the configuration settings where already there for reuse. The main challenge with Arquillian, JSFUnit and Glassfish is combining the corresponding versions of the dependencies to make it all work together.  Also the ADF version that we are using runs on JSF 1.2, while Glassfish ships with version 2, so I googled how I could fix that.  Just add a sun-web.xml-file to make it work (see solution at http://stackoverflow.com/questions/2333330/jsf-1-2-app-not-working-with-glassfish-v3).

The setup of the Maven project consists of 3 sub projects, namely a Model, a ViewController and an ear project. The Model project is for holding the models of course. In this example I added a simple BC4J component.  For the moment, it still connects to a local installed Oracle database (Express Edition).  In the future, I would like to change it to a local embedded Derby database to make the tests totally isolated.  I also have to add some concrete tests to test the BC4J component completely.

The ViewController project holds my managed bean with the JSP-page, the ADF configuration and the page binding files.  The ear project speaks for itself so the main focus will be on the ViewController project, which is of course the most important one.

As I spent quite a few days on it to make it all work, I decided to share this research as I’m sure this could be useful for other ADF/JSF developers.

You can find the complete project on https://github.com/dabla/adf-maven-demo.

Note that the project holds a setup directory.  This directory contains a bat-file which adds the ADF libraries to your local Maven repository and also copies some parent POM-files for grouping purposes.

About these ads
Tagged , , , , , , , , , ,

5 thoughts on “Building and testing ADF applications with Maven, JSFUnit, Arquillian and Embedded Glassfish

  1. soverbosch says:

    Hi, I’ve been in the process of configuring an existing ADF JDeveloper project to be build using maven. At this moment I get an ear which seams to resemble the ear generated by JDeveloper but when I deploy it, then it won’t succeed. The message I get is attache below, my question is if you have encountered this problem (my application does use security so the problem could be caused by the wallet, but then again how can I solve that)

    #### #### <>
    #### <> <Failure occurred in the execution of deployment request with ID '1328701347397' for task '0'. Error is: 'weblogic.application.ModuleException: Failed to load webapp: '/transitietable-view''
    weblogic.application.ModuleException: Failed to load webapp: '/transitietable-view'
    at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:393)
    at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176)
    at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
    at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:517)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:159)
    at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:45)
    at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:613)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:184)
    at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)

    • dablomatique says:

      Hi,

      Is this the complete stacktrace? I suspect it couldn’t be posted completly. Maybe you should put it on pastebin and post the url here. Do you deploy from JDeveloper or form the web console on weblogic? I haven’t encountered this error yet, it is also difficult to help as I can’t see the code and what you’re trying to achieve…

  2. Erik Wramner says:

    Nice post. Looking at the code it seems that you are developing with Eclipse, is that correct? I’m trying to use Maven with ADF applications developed using JDeveloper 11.1.1.5 and it is not easy to get Maven and JDeveloper to agree on the project structure. The Maven plugin doesn’t help. Perhaps 11.1.2 is better, but we can’t upgrade. Have you done or seen something similar with JDeveloper as well?

  3. I was taking a look at this. To resolve your error try looking into the contents of weblogic.xml. If you are not sure what is missing try running the app from within jdev and see the contents in weblogic.xml in the generated ear file.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Erik Wramner

Tips and tricks

Java Enterprise Development

Java / Oracle SOA blog

Java Enterprise Development

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: