The RAP Tools provide two dedicated launchers to start RAP applications directly from the IDE: the RWT Launcher, used for snippets and stand-alone applications, and the RAP Launcher, used for applications based on OSGi. The latter you can also be started without the RAP Tools, using the plain OSGi Launcher.
Contents:
The RWT Launcher is the simplest way to start a RAP application. It requires no OSGi, application configuration or Branding, only an entry point. Consequentially, this method does not allow multiple entry points or any customization of the application (e.g. using a custom theme).
Before the RWT launcher starts the application, it terminates any possibly running
instance of the same application.
After a successful start, you should see a message like this one in the Console view:
INFO: Started SocketListener on 0.0.0.0:<port>
.
Whenever you start an application as described above, a launch configuration is created and added to the Run > Run History menu. The created launch configuration is based on your Java project and your IDE preferences. It can later be edited and refined with custom or additional parameters.
To create a new launch configuration or to alter an existing one, select Run > Run Configurations… or Run > Debug Configurations…. This opens a dialog that lets you create, modify, and delete launch configurations of different types. To create a new RWT Application launch configuration, select RWT Application from the list of launch configuration types on the left, and press the New button in the toolbar. The tabs on the right allow you control specific aspects of the launch.
On the Main tab you can control the following aspects of the launch:
Use a fixed port configuration lets you select a fixed network port to start your application at. If you don't configure a port, the launcher will choose a free port, which may be different on every launch.
Session Timeout specifies the servlet session timeout in minutes. If the checkbox is unselected, the session will never expire.
Context Path selects an optional context path for the web application.
The context path is part of a web application's URL, e.g.
http://<server>:<port>/contextPath/servletPath
.
In a servlet container, every web app is available at its own context path.
This setting lets you simulate the same context path that your application will be accessible
at in the production environment.
The option Start in development mode selects the variant of the RWT JavaScript library that will be delivered to the client. If development mode is on, the client maintains the JavaScript code in its original, human-readable form. If it is off, the client is optimized for speed and size by compressing the JavaScript code. It will also print non-critical JavaScript errors to the browsers console instead of crashing the entire client.
For an explanation of the other tabs see the topic Creating a Java application launch configuration
The RAP Launcher is based on the OSGi Launcher and adds a Main tab page to it. Please note that the RAP Launcher only works when the Equinox OSGi Framework is selected, which is the default setting on page Bundles.
This setting lets you control whether the application should be opened in a browser after a successful start. The application can be opened either in an internal browser, i.e. embedded in the Eclipse IDE, or in an external browser. The external browser application can be configured in the Web Browser preference of your IDE, the link Configure browsers… lets you jump right there.
The Servlet Path field lets you configure the URL that will be opened in the browser. Which path is mapped to which entry point is configured in the application configuration.
Use a fixed port configuration lets you select a fixed network port to start your application at. If you don't configure a port, the launcher will choose a free port, which may be different on every launch.
Session Timeout specifies the servlet session timeout in seconds. If the checkbox is unselected, the session will never expire.
Context Path selects an optional context path for the web application.
The context path is part of a web application's URL, e.g.
http://<server>:<port>/contextPath/servletPath
.
In a servlet container, every webapp is available at its own context path.
This setting lets you simulate the same context path that your application will be accessible
at in the production environment.
The option Start in development mode selects the variant of the RWT JavaScript library that will be delivered to the client. If development mode is on, the client maintains the JavaScript code in its original, human-readable form. If it is off, the client is optimized for speed and size by compressing the JavaScript code. It will also print non-critical JavaScript errors to the browsers console instead of crashing the entire client.
The instance area location sets the Program Arguments to define the osgi.instance.area. Bundles use this location to store their state location data.
In the Bundles tab, the following bundles need to be activated:
Basic RAP bundles
Basic Equinox OSGi platform
The Jetty servlet container
Servlet API (remove when deploying to a servlet container)
Optional RAP bundles (require additional platform bundles - see below)
Eclipse platform bundles required by applications using JFace or the Workbench (only a subset may be required, please check for the actual dependencies)
To launch an existing launch configuration you may use the launch shortcut keys Alt+Shift+X, R (run) and Alt+Shift+D, R (debug).
Alternatively, you can also use the plain OSGi Launcher to start RAP applications. In this case, you have to set the necessary system properties and program arguments on your own. At minimum, you have to specify the HTTP port for the server with this VM argument:
-Dorg.osgi.service.http.port=<PORT>
To run RAP in development mode, add this system property, too:
-Dorg.eclipse.rap.rwt.developmentMode=true
By default the servlet engine (namely Jetty) is configured to suppress most logging information. This can be changed by adding this VM argument to the launch configuration:
-Dorg.eclipse.equinox.http.jetty.log.stderr.threshold=<log level>
Valid log levels are debug, info, warn, error, and off. The default value is warn.
Unsupported JRE version
java.lang.UnsupportedClassVersionError: Bad version number in .class file
The launcher requires JavaSE 1.6 or higher. If your project is configured with a JRE < 1.6, the launcher will try to start with a matching JRE. If you have a 1.5 JRE configured in your IDE, it will fail with an exception like the one shown above. In this case, edit the launch configuration and set the JRE to a Java 6 or higher.
Unsupported Operation mode
java.lang.UnsupportedOperationException: The SimpleLifeCycle does not support Display#sleep()
The RWT launcher starts applications in the
JEE compatibility mode.
This mode does not support Display.sleep()
, specifically, it does not support
the SWT main loop. When starting an SWT snippet, this code may not be used:
while( !shell.isDisposed() ) { if( !display.readAndDispatch() ) display.sleep(); } display.dispose();
It is recommended to extend AbstractEntryPoint instead of implementing the EntryPoint interface directly. With AbstractEntryPoint no main loop is required, no matter which operation mode is used.
UI does not react to user input
This happens if the application starts in SWT compatibility mode and no SWT main loop is present. Basically the reverse of the above issue. Either add a main loop, or extend AbstractEntryPoint instead of implementing the EntryPoint interface.
404 Error Page
There are two reasons a 404 page may be displayed in the browser. Either the URL is incorrect (check the servlet path), or the browser opened faster than the application could start. In that case, simply hit F5 (refresh).