Vaadin Custom Components/Widgets with Maven and Spring Boot

2

I am relatively new to vaadin and started out with a spring boot application and the vaadin spring boot plugin. Everything worked fine until I got to the point where I tried to create my own components/widgets.

Unfortunately I didn't find any "official" example/documentation how to set up custom components within a spring boot application so I had to search the web to find out how to set up additional plugin(s) in maven to compile the code for the client side widgets. As far as I can tell from the log output the compilation of these components work, but when I try to access these components on the webpage I get an error:

Widgetset 'com.vaadin.DefaultWidgetSet' does not contain implementation for net.gtidev.test.components.MyComponent. Check its component connector's @Connect mapping, widgetsets GWT module description file and re-compile your widgetset. [...]

Here is the widget compiler log:

[INFO] Using com.vaadin:vaadin-client-compiler version 7.6.4
[ERROR] Mar 22, 2016 10:22:43 AM java.util.prefs.WindowsPreferences <init>
[ERROR] WARNUNG: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
[INFO] Compiling module net.gtidev.test.components.TestWidgetset
[INFO]    Computing all possible rebind results for 'com.vaadin.client.metadata.ConnectorBundleLoader'
[INFO]       Rebinding com.vaadin.client.metadata.ConnectorBundleLoader
[INFO]          Invoking generator com.vaadin.server.widgetsetutils.ConnectorBundleLoaderFactory
[INFO]             Populating eager bundle

. . . . . 250 more lines

[INFO]    Computing all possible rebind results for 'com.vaadin.client.ui.dd.VAcceptCriterionFactory'
[INFO]       Rebinding com.vaadin.client.ui.dd.VAcceptCriterionFactory
[INFO]          Invoking generator com.vaadin.server.widgetsetutils.AcceptCriteriaFactoryGenerator
[INFO]             Detecting available criteria ...
[INFO]             creating mapping for com.vaadin.event.dd.acceptcriteria.AcceptAll
[INFO]             creating mapping for com.vaadin.event.dd.acceptcriteria.And
[INFO]             creating mapping for com.vaadin.event.dd.acceptcriteria.ContainsDataFlavor
[INFO]             creating mapping for com.vaadin.event.dd.acceptcriteria.SourceIs
[INFO]             creating mapping for com.vaadin.ui.AbstractSelect.TargetItemIs
[INFO]             creating mapping for com.vaadin.ui.AbstractSelect.AcceptItem
[INFO]             creating mapping for com.vaadin.ui.Table.TableDropCriterion
[INFO]             creating mapping for com.vaadin.ui.Tree.TreeDropCriterion
[INFO]             creating mapping for com.vaadin.event.dd.acceptcriteria.Not
[INFO]             creating mapping for com.vaadin.event.dd.acceptcriteria.Or
[INFO]             creating mapping for com.vaadin.event.dd.acceptcriteria.ServerSideCriterion
[INFO]             creating mapping for com.vaadin.event.dd.acceptcriteria.SourceIsTarget
[INFO]             creating mapping for com.vaadin.event.dd.acceptcriteria.TargetDetailIs
[INFO]             creating mapping for com.vaadin.ui.Tree.TargetInSubtree
[INFO]             Done. (0seconds)
[INFO]    Compiling 1 permutation
[INFO]       Compiling permutation 0...
[INFO]    Compile of permutations succeeded
[INFO]    Compilation succeeded -- 59,217s
[INFO] Linking into C:\projects\misc\vaadin-boot\target\vaadin-boot-0.0.1-SNAPSHOT\net.gtidev.test.components.TestWidgetset
[INFO]    Link succeeded
[INFO]    Linking succeeded -- 0,492s

The files I use for my custom component were generated by the eclipse vaadin addon within a vaadin 7 project which I created only for this purpose. When I started this vaadin 7 project in eclipse the component worked. I then copied these files into my spring boot maven project where the custom component does not get loaded any more.

I know that spring boot applications have a slightly different bootstrap mechanism and layout than "classic" webapps and that amongst other things static resources are not loaded from the webapp-folder but from the classpath:/static folder. I think that the core of the problem has something to do with this fact but I don't know what to do to fix it.

My Plugin configuration (I tried with and without the commented options):

<plugin>
  <groupId>com.vaadin</groupId>
  <artifactId>vaadin-maven-plugin</artifactId>
  <version>7.6.4</version>
  <configuration>
    <strict>true</strict>
    <force>true</force>
    <!-- Enable during development to speed compiling. -->
    <!-- <draftCompile>true</draftCompile>
    <style>DETAILED</style> -->
    <!-- End development options -->
    <!--<webappDirectory>src/main/webapp/VAADIN/widgetsets</webappDirectory>-->
    <modules>
      <module>net.gtidev.test.components.TestWidgetset</module>
    </modules>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>resources</goal>
        <goal>compile</goal>
      </goals>
    </execution>
  </executions>
</plugin>

I tried different maven plugin combinations and configurations. In one example, there was also a Google-GWT Plugin mentioned, but running this plugin on the code produced the same log output as the vaadin plugin:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>gwt-maven-plugin</artifactId>
  <version>2.5.1</version>
  <!--<configuration>-->
  <!--<webappDirectory>src/main/webapp/VAADIN/widgetsets</webappDirectory>-->
  <!--<extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>-->
  <!--<runTarget>clean</runTarget>-->
  <!--<hostedWebapp>${project.build.directory}/${project.build.finalName}</hostedWebapp>-->
  <!--<noServer>true</noServer>-->
  <!--<port>8080</port>-->
  <!--<soycDetailed>false</soycDetailed>-->
  <!--</configuration>-->
  <executions>
    <execution>
      <goals>
        <goal>resources</goal>
        <goal>compile</goal>
      </goals>
    </execution>
  </executions>
</plugin>
maven
gwt
spring-boot
vaadin7
asked on Stack Overflow Mar 22, 2016 by gofrm • edited Mar 22, 2016 by Matt

1 Answer

3

To use custom client side extensions, Vaadin Add-ons, you'll need to add vaadin-maven-plugin to your project. It will scan the add-ons you use and GWT compile a new widgetset for your project that contains those extensions.

If you created the project with start.spring.io the maven plugin is not in your project by default. Create an example project for example using this Vaadin+Spring archetype or the official servlet based archetype and copy the vaadin-maven-plugin related parts from the pom.xml to your projects pom.xml. Then do a full build and everything should works as expected.

answered on Stack Overflow Mar 22, 2016 by mstahv • edited Mar 2, 2018 by mstahv

User contributions licensed under CC BY-SA 3.0