Accueil > Eclipse RAP, Libra, WAR Product > Create a WAR from RAP Application with Libra WAR Product [step1]

Create a WAR from RAP Application with Libra WAR Product [step1]


In the Eclipse RCP/RAP with Spring DM, Spring Data JPA and Remoting [step10] article we have created a RAP Application which displays list of user with pagination :

Now we wish create a classic WAR of the RAP Application to deploy the RAP Application with any HTTP Server (which doesn’t support OSGi, like Apache Tomcat). This WAR will be created by using the Libra WAR Product.

You can see the online demo of the rap-jpa.war created with WAR Product deployed on CloudBees which provides an Apache Tomcat at http://rap-war.opensagres.cloudbees.net/eclipsespring.

Server-Side Equinox

RAP Application needs an HTTP Server and an OSGi container Equinox. Server-Side Equinox is targetted at eliminating barriers to using and integrating OSGi (and Equinox more specifically) on the server. Server-Side Equinox provides the capability to manage OSGi bundles in WEB Application with 2 means :

  • Embedding an HTTP server in OSGi container : it means that HTTP server and WEB application are OSGi bundles. The OSGi container start the HTTP server bundle. Embedding an HTTP server in Equinox explains how this mean is done with Equinox.

    You can resume « embedding an HTTP server in OSGi container » like this :

    OSGi container -> HTTP Server (bundle) -> WEB Application (bundle).

  • Embedding OSGi container in a servlet container : it means that it’s a WEB Application which contains the OSGi container (and another bundles) which start the OSGi container. Equinox in a Servlet Container explains how this mean is done with Equinox.
    You can resume « embedding OSGi container in a servlet container » like this :

    HTTP Server -> WEB Application -> OSGi container.

Embedding an HTTP server in OSGi container

In the [step 10] our RAP Application works with « Embedding an HTTP server in OSGi container ». It is started with the launch RAP Client – JPA Dao (to use JPA implementation for Dao) and RAP Client – Mock Dao (to use Mock implementation for Dao) :

In those launch you can check that OSGi bundles Jetty org.eclipse.jetty.* are used as HTTP server. It works great but sometimes (in your professional job), you have not the luck to choose the HTTP server and generally it doesn’t support the OSGi features.

Equinox in a Servlet Container (ServletBridge)

To launch RAP Application in an HTTP Server which doesn’t support OSGi (eg: Apache Tomcat), you can create a WAR which :

  • declares the ServletBridge Servlet in the web.xml.
  • contains the OSGi bundles (RAP Application).

Here OSGi Jetty bundles will be not used. If you need more information about ServletBridge, please read my OSGi Equinox in a Servlet Container articles.

Libra WAR Product

This WAR will be created by using the Libra WAR Product provides tools to create a WAR from a RAP Application launch (and even OSGi launch).
The Create a WAR from RAP Application with Libra WAR Product articles explains step by step how to create a WAR by using our RAP launches.

I suggest you too to read How to Deploy a RAP Application to a Servlet Container? documentation.

Why My WAR Product?

When I tried the current version (0.1.1.201202130952) of WAR Product that you can install with P2 http://download.eclipse.org/libra/releases, to create a WAR with my RAP Application which uses Spring, I had this cycle error :

This problem is known in the bug 342802. After posting my question [WAR Product] What is the state of WAR Product?, I decided for the moment to create my own WAR Product which resolves this cycle and fix 3 bugs :

  • Add checkbox « allow for binary cycles » in the export wizard to fix problem with cycle.
  • WAR product creation fails when you have in our workspace 3 kinds of launches (OSGi, RCP and RAP).
  • ban org.eclipse.jetty* Plug-In when WAR product is created.

I have created the bug 382267 which contains my (little) modification of WAR Product. In this article we will install My WAR Product by waiting release of WAR Product.

Install WAR Product

In this section we will install My WAR Product which is local Update Site bute once time WAR Product will be released with those 3 fixes, I suggest you to install it with the P2 URL http://download.eclipse.org/libra/releases.

My WAR Product – Local Update site

To install « My WAR Product » :

  • Download the zip of « My WAR product »mywarproduct.zip
  • unzip it in a folder (in my case C:/) .

Install (My) WAR Product

CLick on Help/Install New Software… menu item :

This action opens the Install wizard:

Click on Add… button to open the Add Repository dialog and click on Local… button to select the root folder of mywarproduct :

Once the root folder of mywarproduct is selected, click on OK button :

This action close the dialog and display « My WAR Product Features« . Select it and click on Next button :

This action opens this wizard page:

Click on Next button, accept the license and click on Finish button :

This dialog opens, click on OK button :

« My WAR Product » is installing:

Once installation is finished, this dialog opens :

Click on Restart Now to open a workspace with My WAR Product installed..

To check My WAR Product is wellinstalled go at the File/New/Other… menu and check you have Plug-in Development/WAR Product Configuration menu item :

Conclusion

In this article we have installed « My WAR Product » by waiting the release of « WAR Product » to fix problems while creating the WAR with the Spring bundles. In the next article [step2] we will create a WAR Product (which looks like a RCP product) to create a WAR from our launch of RAP Application.

Catégories :Eclipse RAP, Libra, WAR Product
  1. juin 22, 2012 à 8:28

    Hi Angelo,

    Maybe a noob question but why do you not use Maven/Tycho for creating a WAR artifact ?

    Thanks

    • juin 22, 2012 à 10:37

      Hi Mickael,

      You are right, it seems that you can use Maven/Tycho for creating a WAR artifact, but never tested. If you do that, I’m very interested with that.

      Regards Angelo

  2. Jack Kilian
    septembre 18, 2014 à 1:38

    Hi Angelo,

    I have some urgent Problems to Build a WAR File of a RAP Product based on LIBRA with Kepler and RAP 2.2. Can you build me a WAR Product based on the current 0.3.x version which allow me the cycles.

    Or can you give me a hint in which class I have to enable that cycles before running the PDE Build?

    Best regards
    – JK

  1. juin 13, 2012 à 7:23
  2. juin 18, 2012 à 7:31

Laisser un commentaire