Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to build and deploy war file of e4 RAP application with tycho
How to build and deploy war file of e4 RAP application with tycho [message #1742473] Fri, 02 September 2016 05:21 Go to next message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 140
Registered: July 2009
Senior Member
I have an e4 RCP product which I want to deliver a e4 RAP application for. Thus, I added a new OSGi bundle which contributes the following implementation of the org.eclipse.rap.rwt.application.ApplicationConfiguration interface, which is declared in the contribution.xml in OSGI-INF folder:
public class BasicApplication implements ApplicationConfiguration {

    public void configure(Application application) {
        Map<String, String> properties = new HashMap<String, String>();
        properties.put(WebClient.PAGE_TITLE, "My RAP Application");
        Bundle bundle = FrameworkUtil.getBundle(my.package.E4LifeCycle.class);
        String symbolicName = bundle.getSymbolicName();
        String appXmiLocation = "platform:/plugin/" + symbolicName + "/Application.e4xmi";
        String lifeCycleLocation = "bundleclass://" + symbolicName + "/" + my.package.E4LifeCycle.class.getName();
        E4ApplicationConfig applicationConfig = E4ApplicationConfig.create(appXmiLocation, lifeCycleLocation);
        E4EntryPointFactory entryPointFactory = new E4EntryPointFactory(applicationConfig);
        application.addEntryPoint("/myapp", entryPointFactory, properties);
        application.setOperationMode(OperationMode.SWT_COMPATIBILITY);
    }

}

Following the example here, I created a new feature bundle including the required plugins and depending on all the required eclipse-related plugins/features (e4, rap, rwt, osgi, ...). It contains this pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <artifactId>my.app.rap.feature</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>eclipse-feature</packaging>

    <parent>
        <groupId>my.app</groupId>
        <artifactId>my.app.parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../../releng/my.app.parent</relativePath>
    </parent>

    <properties>
        <output.directory>${basedir}/target/WEB-INF</output.directory>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-packaging-plugin</artifactId>
                <version>${tycho.version}</version>
                <configuration>
                    <deployableFeature>true</deployableFeature>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>copy-web-inf</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${output.directory}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/templates/WEB-INF</directory>
                                    <includes>
                                        <include>**</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-plugins</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${output.directory}/eclipse</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/target/site</directory>
                                    <includes>
                                        <include>*/**</include>
                                    </includes>
                                    <excludes>
                                        <exclude>*.jar</exclude>
                                    </excludes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <descriptors>
                        <descriptor>assembly.xml</descriptor>
                    </descriptors>
                    <finalName>my-app</finalName>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Where the referred assembly.xml looks like this:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
    <id>rap</id>
    <formats>
        <format>war</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>${output.directory}</directory>
            <outputDirectory>/WEB-INF</outputDirectory>
        </fileSet>
    </fileSets>
</assembly>

For completeness, here is the parent's pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>my.app</groupId>
    <artifactId>my.app.parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <tycho.version>0.25.0</tycho.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-compiler-plugin</artifactId>
                <version>${tycho.version}</version>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-maven-plugin</artifactId>
                <version>${tycho.version}</version>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-versions-plugin</artifactId>
                <version>${tycho.version}</version>
            </plugin>
        </plugins>
    </build>


    <repositories>

        <repository>
            <id>eclipse-RAP</id>
            <url>http://download.eclipse.org/rt/rap/3.1</url>
            <layout>p2</layout>
        </repository>

        <repository>
            <id>eclipse-RAP-e4</id>
            <url>http://download.eclipse.org/rt/rap/incubator/nightly/e4/target/site</url>
            <layout>p2</layout>
        </repository>

        <repository>
            <id>neon-orbit</id>
            <url>http://download.eclipse.org/tools/orbit/downloads/drops/R20160520211859/repository/</url>
            <layout>p2</layout>
        </repository>
    </repositories>
</project>

In templates/WEB-INF I placed the web.xml and the launch.ini which was generated by the WAR products tool. The web.xml looks like:
<?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 --></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>

whereas the launch.ini is the following:
# Eclipse Runtime Configuration Overrides
# These properties are loaded prior to starting the framework and can also be used to override System Properties
# @null is a special value used to override and clear the framework's copy of a System Property prior to starting the framework
# "*" can be used together with @null to clear System Properties that match a prefix name. 

osgi.*=@null
org.osgi.*=@null
eclipse.*=@null

osgi.parentClassloader=app
osgi.contextClassLoaderParent=app

The build succeeds and a war file is generated. I placed it in the webapps dir of my Tomcat and it is unzipped automatically. But when I point my browser to http: //localhost:8080/my-app-rap I just get a 404. So I assume some configuration of which starting point to use is missing somewhere. Can you help me to figure this out?
Re: How to build and deploy war file of e4 RAP application with tycho [message #1742632 is a reply to message #1742473] Tue, 06 September 2016 08:41 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
the RAP e4 application is not different that any other RAP application. Please check:
1. All bundles are in ACTIVE state (enable OSGi console and type ss command)
2. There is no javax.servlet bundle included in the WAR
3. All needed resources are available in the WAR (including Application.e4xmi). Check your bundles build.properties file. There was a problem with Application.e4xmi (https://bugs.eclipse.org/bugs/show_bug.cgi?id=486598)
4. Check your URL - port, context path, servlet path

See also RAP/FAQ: https://wiki.eclipse.org/RAP/FAQ#Exported_WAR_file_does_not_work

HTH,
Ivan
Re: How to build and deploy war file of e4 RAP application with tycho [message #1742839 is a reply to message #1742632] Thu, 08 September 2016 06:48 Go to previous messageGo to next message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 140
Registered: July 2009
Senior Member
Ivan, thanks for responding. I applied your advises to a simpler project, namely the Hello RAP Demo described here. I activated the -console parameter in the web.xml and added a port to be able to telnet the console. I exported the war file for the demo and copied it into my webapps folder of the Tomcat. It is unzipped and I see the created folder. I also see the demo app in the Tomcat web application manager. When I telnet the console of the demo app and type 'ss' I also see all bundles being ACTIVE except the org.eclipse.equinox.servletbridge.extensionbundle being RESOLVED. This is supposed to be valid according to here. But when I press the link of the demo app in the Tomcat web application manager I get this error
HTTP Status 404 - ProxyServlet: /

type Status report

message ProxyServlet: /

description The requested resource is not available.
Apache Tomcat/8.5.4

Any further hints?
Re: How to build and deploy war file of e4 RAP application with tycho [message #1742842 is a reply to message #1742839] Thu, 08 September 2016 07:32 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
what is the URL that you try to access? When you deploy it in Tomcat the WAR file name appears as context path. The URL should look like this:
http://<server_address>:<port>/<WAR_filename_context_path>/<entry_point_path>
HTH,
Ivan
Re: How to build and deploy war file of e4 RAP application with tycho [message #1742983 is a reply to message #1742842] Fri, 09 September 2016 05:26 Go to previous message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 140
Registered: July 2009
Senior Member
Hi Ivan,
I got the example working with your hints. Previously, I tried to access the application just with http://<server_address>:<port>/<WAR_filename_context_path>/. Your advise with the following <entry_point_path> did it. In the example application, one can find the class BasicApplication implementing ApplicationConfiguration which contains this method:
    public void configure(Application application) {
    	Map<String, String> properties = new HashMap<String, String>();
        properties.put(WebClient.PAGE_TITLE, "Hello e4 RAP");
        application.addEntryPoint("/hello", new E4EntryPointFactory(E4ApplicationConfig.create("platform:/plugin/RapTest/Application.e4xmi")), properties);
        application.setOperationMode( OperationMode.SWT_COMPATIBILITY );
    }

So, I used "/hello" as the entry point in the URL and got it working. Thank you very much, now I try to fix my specific project and will post the final solution.
cheers

cheers
Previous Topic:news.eclipse.org is shutting down.
Next Topic:RichTextEditor handling of Focus and Traversal Events
Goto Forum:
  


Current Time: Thu Apr 25 23:13:20 GMT 2024

Powered by FUDForum. Page generated in 0.04410 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top