Documentation versions (currently viewingVaadin 8)

Vaadin 8 reached End of Life on February 21, 2022. Discover how to make your Vaadin 8 app futureproof →

Deploying to a Portal

For OSGi portlets in Liferay 7, see "Publishing a Portlet With OSGi". The text below applies mostly to non-OSGi portlets.

To deploy a portlet WAR in a portal, you need to provide a portlet.xml descriptor specified in the Java Portlet API 2.0 standard (JSR-286). In addition, you may need to include possible portal vendor specific deployment descriptors. The ones required by Liferay are described below.

Deploying a Vaadin UI as a portlet is essentially just as easy as deploying a regular application to an application server. You do not need to make any changes to the UI itself, but only the following:

  • Application packaged as a WAR

    • WEB-INF/portlet.xml descriptor

    • WEB-INF/liferay-portlet.xml descriptor for Liferay

    • WEB-INF/liferay-display.xml descriptor for Liferay

    • WEB-INF/ for Liferay

  • Widget set installed to portal (optional)

  • Themes installed to portal (optional)

  • Vaadin libraries installed to portal (optional)

  • Portal configuration settings (optional)

Installing the widget set and themes to the portal is required for running two or more Vaadin portlets simultaneously in a single portal page. As this situation occurs quite easily, we recommend installing them in any case. Instructions for Liferay are given in "Developing Vaadin Portlets for Liferay" and the procedure is similar for other portals.

In addition to the Vaadin libraries, you will need to have the portlet.jar in your project classpath. However, notice that you must not put the portlet.jar in the same WEB-INF/lib directory as the Vaadin JAR or otherwise include it in the WAR to be deployed, because it would create a conflict with the internal portlet library of the portal. The conflict would cause errors such as " ClassCastException: ...VaadinPortlet cannot be cast to javax.portlet.Portlet".

Portlet Deployment Descriptor

The portlet WAR must include a portlet descriptor located at WEB-INF/portlet.xml. A portlet definition includes the portlet name, mapping to a servlet, modes supported by the portlet, and other configuration. Below is an example of a simple portlet definition in portlet.xml descriptor.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

    <portlet-name>Portlet Example portlet</portlet-name>
    <display-name>Vaadin Portlet Example</display-name>

    <!-- Map portlet to a servlet. -->

      <!-- The application class with package name. -->

    <!-- Supported portlet modes and content types. -->

    <!-- Not always required but Liferay requires these. -->
      <title>Vaadin Portlet Example</title>
      <short-title>Portlet Example</short-title>

The mode definitions enable the corresponding portlet controls in the portal. The portlet controls allow changing the mode of the portlet, as described later.

Liferay Portlet Descriptor

Liferay requires a special liferay-portlet.xml descriptor file that defines Liferay-specific parameters. Especially, Vaadin portlets must be defined as " instanceable", but not " ajaxable".

Below is an example descriptor for the earlier portlet example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE liferay-portlet-app PUBLIC
  "-//Liferay//DTD Portlet Application 4.3.0//EN"

        <!-- Matches definition in portlet.xml.          -->
        <!-- Note: Must not be the same as servlet name. -->
        <portlet-name>Portlet Example portlet</portlet-name>


See Liferay documentation for further details on the liferay-portlet.xml deployment descriptor.

Liferay Display Descriptor

The WEB-INF/liferay-display.xml file defines the portlet category under which portlets are located in the Add Application window in Liferay. Without this definition, portlets will be organized under the "Undefined" category.

The following display configuration, which is included in the demo WAR, puts the Vaadin portlets under the "Vaadin" category, as shown in Portlet Categories in Add Application Window.

<?xml version="1.0"?>
  "-//Liferay//DTD Display 4.0.0//EN"

    <category name="Vaadin">
        <portlet id="Portlet Example portlet" />
liferay display hi
Portlet Categories in Add Application Window

See Liferay documentation for further details on how to configure the categories in the liferay-display.xml deployment descriptor.

Liferay Plugin Package Properties

The file defines a number of settings for the portlet, most importantly the Vaadin JAR to be used.

name=Portlet Example portlet

The plugin name must match the portlet name.


A short description of the plugin. This is by default the project name.


The application group, same as the category id defined in liferay-display.xml.


The plugin license type; "proprietary" by default.


The JAR libraries on which this portlet depends. This should have value vaadin.jar, unless you need to use a specific version. The JAR must be installed in the portal, for example, in Liferay bundled with Tomcat to tomcat-x.x.x/webapps/ROOT/WEB-INF/lib/vaadin.jar.

Using a Single Widget Set

If you have just one Vaadin application that you ever need to run in your portal, you can just deploy the WAR as described above and that’s it. However, if you have multiple applications, especially ones that use different custom widget sets, you run into problems, because a portal window can load only a single Vaadin widget set at a time. You can solve this problem by combining all the different widget sets in your different applications into a single widget set using inheritance or composition.

For example, if using the default widget set for portlets, you should have the following for all portlets so that they will all use the same widget set:

  <!-- Use the portal default widget set for all portal demos. -->

The PortalDefaultWidgetSet extends SamplerWidgetSet, which extends the DefaultWidgetSet. The DefaultWidgetSet is therefore essentially a subset of PortalDefaultWidgetSet, which contains also the widgets required by the Sampler demo. Other applications that would otherwise require only the regular DefaultWidgetSet, and do not define their own widgets, can just as well use the larger set, making them compatible with the demos. The PortalDefaultWidgetSet will also be the default Vaadin widgetset bundled in Liferay 5.3 and later.

If your portlets are contained in multiple WARs, which can happen quite typically, you need to install the widget set and theme portal-wide so that all the portlets can use them. See "Developing Vaadin Portlets for Liferay" on configuring the widget sets in the portal itself.

Building the WAR Package

To deploy the portlet, you need to build a WAR package. For production deployment, you probably want to either use Maven or an Ant script to build the package. In Eclipse, you can right-click on the project and select Export  WAR. Choose a name for the package and a target. If you have installed Vaadin in the portal as described in "Developing Vaadin Portlets for Liferay", you should exclude all the Vaadin libraries, as well as widget set and themes from the WAR.

Deploying the WAR Package

How you actually deploy a WAR package depends on the portal. In Liferay, you simply drop it to the deploy subdirectory under the Liferay installation directory. The deployment depends on the application server under which Liferay runs; for example, if you use Liferay bundled with Tomcat, you will find the extracted package in the webapps directory under the Tomcat installation directory included in Liferay.