on Aug 10th, 2011How to extend the Virgo Jetty Server to support the RAP Widget Toolkit
First, a bit of news for developers following the Virgo project: The release day for Virgo Maya is getting closer[1] with the successful RC1 release a few weeks ago.
Meantime, in this blog post I’ll describe another way of running RWT (the RAP Widget Tookit) based applications on the Virgo Jetty Server. I want to use Virgo’s RFC66 support to deploy web applications in OSGi.
The RFC66 Web Container specification creates an open standard that enables developers to deploy WAR files on OSGi. With a few modifications (see below) it is possible to deploy an RWT standalone application into an RFC66 container like Virgo.
Note: In addition to using the HttpService described here[2] with RAP 1.5 you can register RWT directly with an OSGi HTTP service. We’ll describe this in a follow-up post.
To extend Virgo you need to:
- Get a Virgo Jetty Server Release Candidate[3].
- Install our extension of Virgo as suggested here[4] into /repository/ext.
Note: You can get a patched RWT bundle here that supports RFC66 deployment of RWT applications and the plan here. The Virgo deployment plan describes all bundles needed to support RWT applications in Virgo.
Copy the two downloaded artifacts into repository/ext:
~virgo-jetty-server> ls -1 repository/ext/*rwt* repository/ext/org.eclipse.rap.rwt-1.5.0.plan repository/ext/org.eclipse.rap.rwt_1.5.0.201108081102.jar
Next I added our RWT extension to the initial Virgo artifacts. This is configured in
config/org.eclipse.virgo.kernel.userregion.properties. We simply add our plan:
initialArtifacts=repository:plan/org.eclipse.virgo.kernel.userregion.springdm,\
repository:plan/org.eclipse.virgo.jetty.web,\
repository:plan/org.eclipse.rap.rwtThat’s all that has to be done on the Virgo side. If you start Virgo Jetty Server you should
see the extension starting properly:
[2011-08-08 12:23:45.909] system-artifacts Installing plan 'org.eclipse.rap.rwt' version '1.5.0'. [2011-08-08 12:23:47.626] system-artifacts Installing bundle 'org.eclipse.rap.rwt' version '1.5.0.201108081102'. [2011-08-08 12:23:47.663] system-artifacts Installed bundle 'org.eclipse.rap.rwt' version '1.5.0.201108081102'. [2011-08-08 12:23:47.665] system-artifacts Installed plan 'org.eclipse.rap.rwt' version '1.5.0'. [2011-08-08 12:23:47.725] system-artifacts Starting plan 'org.eclipse.rap.rwt' version '1.5.0'. [2011-08-08 12:23:47.729] system-artifacts Starting bundle 'org.eclipse.rap.rwt' version '1.5.0.201108081102'. [2011-08-08 12:23:47.734] start-signalling-2 Started bundle 'org.eclipse.rap.rwt' version '1.5.0.201108081102'. [2011-08-08 12:23:47.737] start-signalling-2 Started plan 'org.eclipse.rap.rwt' version '1.5.0'.
Because an RWT standalone application doesn’t know about OSGi classloading, I thought that one solution might be to use buddy classloading. First, I enabled buddy classloading in org.eclipse.rap.rwt.
Bundle-SymbolicName: org.eclipse.rap.rwt Bundle-Version: 1.5.0.qualifier ... Eclipse-BuddyPolicy: registered
Then I registered the RWT application com.eclipsesource.sovereign.swt.layout.web as a buddy:
Bundle-SymbolicName: com.eclipsesource.sovereign.swt.dialog ... Require-Bundle: org.eclipse.rap.rwt Export-Package: com.eclipsesource.sovereign.swt.dialog Eclipse-RegisterBuddy: org.eclipse.rap.rwt Web-ContextPath: /rap
Note: In the MANIFEST.MF of the web bundle we specified the context path to “/rap”.
Next I setup the RAP web application. The web.xml almost looks like that of a standard RWT standalone application. For more details please go to the RAP Wiki [5]:
<context-param> <param-name>org.eclipse.rwt.entryPoints</param-name> <param-value>com.eclipsesource.sovereign.swt.dialog.SwtDialogEntryPoint</param-value> </context-param> <listener> <listener-class>org.eclipse.rwt.internal.engine.RWTServletContextListener</listener-class> </listener> <servlet> <servlet-name>rwtDelegate</servlet-name> <servlet-class>org.eclipse.rwt.internal.engine.RWTDelegate</servlet-class> </servlet> <servlet-mapping> <servlet-name>rwtDelegate</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
You’ll see an additional section for the RWT resources:
<servlet> <servlet-name>rwtResources</servlet-name> <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>rwtResources</servlet-name> <url-pattern>/rwt-resources/*</url-pattern> </servlet-mapping>
Now I was ready to deploy my RAP application. I simply copied the webbundle into Virgo’s pickup folder.
Note: You can get the sample RAP webbundle here.
[2011-08-08 12:25:34.421] fs-watcher Hot deployer processing 'CREATED' event for file 'com.eclipsesource.sovereign.swt.dialog_0.1.0.201108081127.jar'. [2011-08-08 12:25:34.476] fs-watcher Installing bundle 'com.eclipsesource.sovereign.swt.dialog' version '0.1.0.201108081127'. [2011-08-08 12:25:34.486] fs-watcher Installed bundle 'com.eclipsesource.sovereign.swt.dialog' version '0.1.0.201108081127'. [2011-08-08 12:25:34.492] fs-watcher Starting bundle 'com.eclipsesource.sovereign.swt.dialog' version '0.1.0.201108081127'. [2011-08-08 12:25:34.494] start-signalling-3 Started bundle 'com.eclipsesource.sovereign.swt.dialog' version '0.1.0.201108081127'.
And the application is available at localhost:8080/rap
[1] Virgo 3.0 (Maya) Release Candidate 1
[2] Running RAP on Virgo
[3] Milestone Downloads
[4] Extending Virgo with a HttpService
[5] How do I use an RWT standalone application in Tomcat


