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

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


In the [step1] we have installed (My) WAR Product Plug-in. In this article we will create two WAR products from the 2 RAP launches:

  • RAP Client – JPA Dao launch starts RAP Application which displays paginated users list from Database Derby (it uses JPA implementation for Dao).
  • RAP Client – Mock Dao launch starts RAP Application which displays paginated users list from Java Map (it uses Mock implementation for Dao).

At the end of this article we will have 2 WAR Products :

In the next article [step3] we will generate two WARs from the two WAR Products created in this article by using the Export WAR action.

Download

WAR Products

You can download eclipse_spring_warproduct.zip which contains the two WAR Products created in this article.

Prerequisite

To follow this article you must :

  1. Download the eclipsespring_step10.zip which contains RAP Application explained in the Eclipse RCP/RAP with Spring DM, Spring Data JPA and Remoting [step10] article.
  2. import those projects in a workspace.
  3. open the TargetPlatform/eclipsespring_rap.target file and click on Set as Target Platform. If you have problem with Target Definition, please read Problem with Install with Nebula (Incubation) P2.

After that, your workspace looks like this:

Before creating WAR Product, I suggest you to test the 2 RAP launches which works with OSGi Jetty bundles :

  • select TargetPlatform/launch/RAP Client – Mock Dao.launch to test the RAP Application with Mock Dao and Run it.
  • select TargetPlatform/launch/RAP Client – JPA Dao.launch to test the RAP Application with JPA Dao and Run it.

Create WAR Product

Before creating WAR Product from a RAP launch (or OSGi bundles), I suggest you to install the RAP Target Platform (in our case the TargetPlatform/eclipsespring_rap.target) because the P2 of RAP http://download.eclipse.org/rt/rap/1.5/runtime provides ServletBridge bundles that we need to create a WAR. If you don’t know how to create RAP Target Platform and activate it, please read Install Eclipse RAP section.

To create a WAR with « WAR Product » you must before to create a *.warproduct file and after you can generate a WAR from this *.warproduct file.

Create WAR Product rap-jpa.warproduct of « RAP Client – JPA Dao »

In this section we will create the TargetPlatform/warproducts/rap-jpa/rap-jpa.warproduct file with (My) WAR Product by using RAP Client – JPA Dao launch.

Once you have opened the TargetPlatform/eclipsespring_rap.target file and click on Set as Target Platform to activate RAP Target Platform :

Create the TargetPlatform/warproducts/rap-jpa folder which will hosts the rap-jpa.warproduct :

Go to the File/New/Other… menu item, select Plug-in Development/WAR Product Configuration and click on Next button:

The New WAR Product Configuration wizard is displayed:

  1. Select the TargetPlatform/warproducts/rap-jpa folder.
  2. fill File name field with rap-jpa.warproduct.
  3. select the RAP Client – Jpa DAO launch because we will create a WAR Product from this launch.

Click on Finish button to generate the WAR Product:

The WAR Product wizard generates :

  • the WEB-INF folder which contains:
    • the launch.ini like this:
      osgi.*=@null
      org.osgi.*=@null
      eclipse.*=@null
      
      osgi.parentClassloader=app
      osgi.contextClassLoaderParent=app
      
    • the web.xml which declares the ServletBridge like this:
             
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
      <web-app id="WebApp">
        <servlet id="bridge">  
          <servlet-name>equinoxbridgeservlet</servlet-name>
          <display-name>Equinox Bridge Servlet</display-name>
          <description>Equinox Bridge Servlet</description>
          <servlet-class>org.eclipse.equinox.servletbridge.BridgeServlet</servlet-class>
      
          <!-- Framework Controls could be useful for testing purpose, but
               we disable it per default -->
          <init-param>
            <param-name>enableFrameworkControls</param-name>
            <param-value>false</param-value>      
          </init-param>
          
          <!-- Enable multi-language support for the extension registry -->
          <!-- the OSGi console is useful for trouble shooting but will fill up your 
               appserver log quickly, so deactivate on production use. Uncomment
               the -console parameter to enabled OSGi console access.  -->
          <init-param>
            <param-name>commandline</param-name>
            <param-value>-registryMultiLanguage <!-- -console --> -ws rap</param-value>     
          </init-param>
      
          <load-on-startup>1</load-on-startup>    
        </servlet>
        
        <servlet-mapping>
          <servlet-name>equinoxbridgeservlet</servlet-name>
          <url-pattern>/*</url-pattern>
        </servlet-mapping>
      
      </web-app>
      
  • rap-jpa.warproduct, the WAR Product.

WAR Product Editor

When you open the rap-jpa.warproduct file, the WAR Product Editor is lanched and displays three tabs :

  • Overview tab.
  • Configuration tab, which configures the WAR Product:
  • web.xml tab, which displays the content of the WEB-INF/web.xml:

Configuration

The configuration tab allow you to :

  • configure the Plug-In and Fragments that you wish to use in the exported WAR. In our case we need do nothing because we have created the WAR Product from the launch.
    You can notice that the WAR Product contains almost the same Plug-Ins Fragments than the launch except :

    1. some (HTTP) OSGi bundles are banned like :
      • javax.servlet
      • org.eclipse.update.configurator
      • org.eclipse.equinox.http.jetty
      • org.eclipse.jetty.continuation
      • org.eclipse.jetty.http
      • org.eclipse.jetty.io
      • org.eclipse.jetty.security
      • org.eclipse.jetty.server
      • org.eclipse.jetty.servlet
      • org.eclipse.jetty.util
    2. ServletBridge bundles are added:
      • org.eclipse.equinox.servletbridge.extensionbundle
      • org.eclipse.equinox.http.registry
      • org.eclipse.equinox.http.servlet
      • org.eclipse.equinox.http.servletbridge
    3. Add libraries in the WEB-INF/lib folder. To use ServletBridge, the org.eclipse.servletbridge*.jar must be added in this folder.

Create WAR rap-mock of « RAP Client – Mock Dao »

You can generate the TargetPlatform/warproducts/rap-mock/rap-mock.warproduct file with (My) WAR Product by using RAP Client – Mock Dao launch
like explained below.

Conclusion

In this article we have generated WAR Product from RAP launches. In the next article [step3] we will generate WAR with Export WAR product action of WAR Product and test the WAR with a Non OSGi HTTP Server Apache Tomcat.

Catégories :Eclipse RAP, Libra, WAR Product