This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

VaadinUI 1.0 with JVx Archetype

If you want to use VaadinUI 1.0 with your maven project it's not an easy task because VaadinUI is not available via maven repositories - right now. But I want to show you an easy way to use VaadinUI 1.0 together with JVx Archetype 1.2.0.

Simply create a new maven project (my IDE is Eclipse) based on JVx Archetype 1.2.0. This archetype references JVx 1.2. Older versions are not compatible with Vaadin UI 1.0 - because of new features in JVx' launcher interface. In order to use Vaadin for JVx applications, add following dependencies to the pom.xml of your server project:

<dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-server</artifactId>
        <version>${vaadin.version}</version>
</dependency>
<dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiled</artifactId>
        <version>${vaadin.version}</version>
</dependency>
<dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client</artifactId>
        <version>${vaadin.version}</version>
        <scope>provided</scope>
</dependency>
<dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-themes</artifactId>
        <version>${vaadin.version}</version>
</dependency>
<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
        <scope>provided</scope>
</dependency>

Set the global property in parent project pom.xml:

<properties>
        <jvx.version>1.2</jvx.version>
        <vaadin.version>7.0.6</vaadin.version>
</properties>

Because Vaadin runs on server-side, our client has to be deployed on server-side as well. Change pom.xml of your war project:

<dependency>
        <groupId>${project.parent.groupId}</groupId>
        <artifactId>${project.parent.artifactId}-client</artifactId>
        <version>${project.parent.version}</version>
</dependency>

This is not a perfect solution because jvxclient.jar will be added. This lib is not necessary because jvxall.jar is already available - but also not a problem!

The last step is the integration of JVx' VaadinUI. There are many solutions to integrate external libraries but maven is not a friend of external libraries. Using system scrope is evil and such libraries won't be added to war files. Deploying external jars to a local maven repository works but why should we do that? I did decide to use sort of a local maven repository placed in my project with following file structure in my server project:

mvn_repo_project

The integration in pom.xml of server project:

<repositories>
 ...  
 <repository>
    <id>in-project</id>
    <name>External libs</name>
    <url>file://${project.basedir}/lib</url>
 </repository>
</repositories>

Finally we need additional dependencies (server project):

<dependency>
        <groupId>com.sibvisions</groupId>
        <artifactId>jvxvaadin-client</artifactId>
        <version>1.0</version>
   </dependency>
<dependency>
        <groupId>com.sibvisions</groupId>
        <artifactId>jvxvaadin-server</artifactId>
        <version>1.0</version>
   </dependency>
<dependency>
        <groupId>com.sibvisions</groupId>
        <artifactId>jvxvaadin-themes</artifactId>
        <version>1.0</version>
</dependency>

The last integration step is the modification of web.xml in our war project:

<!-- Vaadin UI -->
 
  <servlet>
    <servlet-name>VaadinServlet</servlet-name>
    <servlet-class>com.sibvisions.rad.ui.vaadin.server.VaadinServlet</servlet-class>
               
    <init-param>
      <param-name>UI</param-name>
      <param-value>com.sibvisions.rad.ui.vaadin.impl.VaadinUI</param-value>
    </init-param>
               
    <init-param>
      <param-name>widgetset</param-name>
      <param-value>com.sibvisions.rad.ui.vaadin.ext.ui.Widgetset</param-value>
    </init-param>
               
    <init-param>
      <param-name>main</param-name>
      <param-value>com.sibvisions.apps.myproject.MainApplication</param-value>
    </init-param>
  </servlet>
       
  <servlet-mapping>
    <servlet-name>VaadinServlet</servlet-name>
    <url-pattern>/vaadinui/*</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>VaadinServlet</servlet-name>
    <url-pattern>/VAADIN/*</url-pattern>
  </servlet-mapping>

That's it.

Use the war project together with an application server in Eclipse and enter http://localhost/myproject/vaadinui/ in a web browser to start your application with VaadinUI - with debugging support. Create a war file, deploy it and it will work without problems.