Migrating from Vaadin 7 to Vaadin 8

Hohoho, Vaadin 8 is out!

Last night I couldn’t sleep and having read the release announcement of Vaadin 8 on the Vaadin Blog ( https://vaadin.com/blog/-/blogs/vaadin-framework-8-is-out ) I was curious to give the new version a try.

For quite some time I had ignored the reminders to migrate my addon the ComponentRenderer ( https://vaadin.com/directory#!addon/componentrenderer ) to Vaadin 8, so I thought this is a good start.

My goal was to just run the component-renderer and demo application with Vaadin 8 but using the compatibility layer to prevent bigger code changes for now. A rewrite embracing Vaadin 8 concepts is planned.

Info

Preparation

If you plan to use the automatic migration tool (will be explained further down in the text) make sure you don’t have com.vaadin.ui.* imports in your code. You want to configure your IDE to not automatically “star” imports if you import a couple of classes from a package. Then just search your code for any star-imports, remove them and import every class explicitly. The migration tool later will change these classes to Vaadin 7 compatibility imports and can’t work with * imports.

Updating POM

The next step was to update my maven pom.xml manifests to the new version. I had to change vaadin-server and vaadin-client to the corresponding compatibility packages vaadin-compatibility-server and vaadin-compatibility-client.

 
	<properties>
		<vaadin.version>8.0.0</vaadin.version>
 
        ... more ...
 
		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-compatibility-server</artifactId>
		</dependency>
		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-compatibility-client</artifactId>
			<scope>provided</scope>
		</dependency>

First I made the error of also changing vaadin-themes into vaadin-compatibility-themes. But I am using the valo theme and that one is still in vaadin-themes. So if you get the error that valo is not found, check if you accidentally also made that mistake.

[ERROR] Feb 24, 2017 2:42:08 AM com.vaadin.sass.internal.handler.SCSSErrorHandler severe
[ERROR] SEVERE: Import '../valo/valo' in '/data/jonas/privat/projekte/vaadin/widgets/componentrenderer-release/componentrenderer-demo/src/main/webapp/VAADIN/themes/demotheme/styles.scss' could not be found
[ERROR] Feb 24, 2017 2:42:08 AM com.vaadin.sass.internal.handler.SCSSErrorHandler severe
[ERROR] SEVERE: Mixin Definition: valo not found

Updating Widgetset

Also change your Widgetset from the com.vaadin.DefaultWidgetSet to the compatibility Widgetset com.vaadin.v7.Vaadin7WidgetSet (search your whole code for that, you might have it defined in multiple places)

Vaadin 7

<module>
    <inherits name="com.vaadin.DefaultWidgetSet"/>
</module>

Vaadin 8 with v7 compatibility layer

<module>
    <inherits name="com.vaadin.v7.Vaadin7WidgetSet"/>
</module>

Rewrite imports using the migration tool

You probably already use the vaadin-maven-plugin anyway to build, so you can use the awesome Vaadin 8 compatibility upgrade mechanism (see github page of migration-tool). Just run the following command and it will automatically change all your imports to the compatibility layer.

mvn vaadin:upgrade8

Cleanup errors

All components are now immediate, and AbstractComponent::setImmediate(boolean immediate) has been removed. So I had to remove calls to the function from my code as well.

Check Memory of Widgetset Compiler

Make sure you give enough memory to the widgetset compile (mine was at 512MB and I had to increase it to 1024MB to get rid of this error):

[INFO] --- vaadin-maven-plugin:8.0.0:compile (default) @ componentrenderer-demo ---
[INFO] auto discovered modules [de.datenhahn.vaadin.componentrenderer.demo.DemoWidgetSet]
[INFO] Compiling module de.datenhahn.vaadin.componentrenderer.demo.DemoWidgetSet
[ERROR] Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
[ERROR] 	at java.util.Arrays.copyOfRange(Arrays.java:3664)
[ERROR] 	at java.lang.String.(String.java:201)
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-maven-plugin</artifactId>
                <version>${vaadin.plugin.version}</version>
                <configuration>
                    <extraJvmArgs>-Xmx1024M -Xss1024k</extraJvmArgs>

Build the project with Vaadin 8

Preparations done, now rebuild your project (e.g. mvn clean install). You might have to correct minor build errors, but for me the overall migration worked very well.

mvn clean install
pixelstats trackingpixel

Comments (2)

MounirFebruary 27th, 2017 at %I:%M %p

Hello, I already have migrated my application (Spring boot and vaadin no widgetsets) from vaadin 7 to vaadin 8, but I get the following error :
Widgetset ‘com.vaadin.DefaultWidgetSet’ does not contain an implementation for com.vaadin.v7.TextField, ……….

MounirFebruary 27th, 2017 at %I:%M %p

Thanks, I missed the @Widgetset(), now it works!

Leave a comment

Your comment

Time limit is exhausted. Please reload the CAPTCHA.