Wednesday, 7 April 2010

Vaadin addons and maven and eclipse.

Afters struggling for almost 3 days, I finally got some vaadin add-ons working for me.
No matter what I did, I could not get maven to compile the custom widget sets :'-(

Wanting to do it with maven I started off with the instructions at http://dev.vaadin.com/wiki/Articles/MavenIntegration.

I got error messages like:
Failed to load the widgetset: 
/my-project/VAADIN/widgetsets/my.company.my.project.widgetset.My_ProjectWidgetset/
my.company.my.project.widgetset.My_ProjectWidgetset.nocache.js?1270654337749

Building it with the eclipse plugin said:
Compiling widgetset my.company.my.project.widgetset.My_ProjectWidgetset
Updating GWT module description file...
07 Apr 2010 5:46:09 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
INFO: Widgetsets found from classpath:
com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:/stf/opt/maven/repository/com/vaadin/vaadin/6.2.6/vaadin-6.2.6.jar!/
my.company.my.project.widgetset.My_ProjectWidgetset in file:/stf/prj/My_Project/src/main/resources

Done.
Starting GWT compiler
Widgetset compilation completed

But when running the webapp, I got:
Widgetset does not contain implementation for org.vaadin.browsercookies.BrowserCookies. Check its @ClientWidget mapping, widgetsets GWT module descrioption file and re-compile your widgetset. Unrendered UIDL:

org.vaadin.browsercookies.BrowserCookies(NO CLIENT IMPLEMENTATION FOUND) id=PID7

variables
Widgetset does not contain implementation for com.github.wolfie.meteorcursor.MeteorCursor. Check its @ClientWidget mapping, widgetsets GWT module descrioption file and re-compile your widgetset. Unrendered UIDL:

com.github.wolfie.meteorcursor.MeteorCursor(NO CLIENT IMPLEMENTATION FOUND) id=PID8 gr=75 th=10 pl=1000 di=2 im=theme://images/logo.png fr=0 disabled=false

I thought that it was building, since the addons that I wanted to use got detected.
Little did I know that it was not actually building!
Building with maven said:
[INFO] Updating widgetset my.company.my.project.widgetset.My_ProjectWidgetset
[INFO] establishing classpath list (scope = compile)
[ERROR] 07 Apr 2010 5:38:31 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
[ERROR] INFO: Widgetsets found from classpath:
[ERROR] com.github.wolfie.meteorcursor.MeteorcursorWidgetset in jar:file:/stf/opt/maven/repository/com/github/wolfie/meteorcursor/1.0.0/meteorcursor-1.0.0.jar!/
[ERROR] org.vaadin.browsercookies.widgetset.BrowserCookiesApplicationWidgetset in jar:file:/stf/opt/maven/repository/com/vaadin/sami/browsercookies/1.0.2/browsercookies-1.0.2.jar!/
[ERROR] com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:/stf/opt/maven/repository/com/vaadin/vaadin/6.2.6/vaadin-6.2.6.jar!/
[ERROR] my.company.my.project.widgetset.My_ProjectWidgetset in file:/stf/prj/My_Project/src/main/resources
[ERROR]


The reason it was not building was because I was trying to use the stable version of the gwt-maven-plugin: 1.2
After reading this forum post again, I tried 1.3-SNAPSHOT of this plugin; and all my troubles went away.


So now I build it with maven, and it should give output like this:
[INFO] [gwt:compile {execution: default}]                                                                                                                    
[INFO] using GWT jars from project dependencies : 1.7.1
[INFO] auto discovered modules [za.co.enerweb.ebr.gui.vaadin.widgetset.Ebr_vaadin_webWidgetset]
[INFO] establishing classpath list (scope = compile)
[INFO] establishing classpath list (scope = compile)
[INFO] establishing classpath list (scope = compile)
[INFO] establishing classpath list (scope = compile)
[INFO] establishing classpath list (scope = compile)
[INFO] establishing classpath list (scope = compile)
[INFO] Compiling module my.company.my.project.widgetset.My_ProjectWidgetset
[INFO] Scanning for additional dependencies: jar:file:/stf/opt/maven/repository/com/vaadin/vaadin/6.2.6/vaadin-6.2.6.jar!/com/vaadin/terminal/gwt/client/DefaultWidgetSet.java
[INFO] Computing all possible rebind results for 'com.vaadin.terminal.gwt.client.WidgetMap'
[INFO] Rebinding com.vaadin.terminal.gwt.client.WidgetMap
[INFO] Invoking
[INFO] Detecting Vaadin components in classpath to generate WidgetMapImpl.java ...
[INFO] Widget set will contain implementations for following components:
[INFO] com.github.wolfie.meteorcursor.MeteorCursor
[INFO] com.vaadin.ui.AbsoluteLayout
[INFO] com.vaadin.ui.Accordion
[INFO] com.vaadin.ui.Button
[INFO] com.vaadin.ui.CheckBox
[INFO] com.vaadin.ui.ComboBox
[INFO] com.vaadin.ui.CssLayout
[INFO] com.vaadin.ui.CustomComponent
[INFO] com.vaadin.ui.CustomLayout
[INFO] com.vaadin.ui.DateField
[INFO] com.vaadin.ui.Embedded
[INFO] com.vaadin.ui.Form
[INFO] com.vaadin.ui.FormLayout
[INFO] com.vaadin.ui.GridLayout
[INFO] com.vaadin.ui.HorizontalLayout
[INFO] com.vaadin.ui.Label
[INFO] com.vaadin.ui.Link
[INFO] com.vaadin.ui.ListSelect
[INFO] com.vaadin.ui.MenuBar
[INFO] com.vaadin.ui.NativeButton
[INFO] com.vaadin.ui.NativeSelect
[INFO] com.vaadin.ui.OptionGroup
[INFO] com.vaadin.ui.OrderedLayout
[INFO] com.vaadin.ui.Panel
[INFO] com.vaadin.ui.PopupView
[INFO] com.vaadin.ui.ProgressIndicator
[INFO] com.vaadin.ui.RichTextArea
[INFO] com.vaadin.ui.Select
[INFO] com.vaadin.ui.Slider
[INFO] com.vaadin.ui.SplitPanel
[INFO] com.vaadin.ui.TabSheet
[INFO] com.vaadin.ui.Table
[INFO] com.vaadin.ui.TextField
[INFO] com.vaadin.ui.Tree
[INFO] com.vaadin.ui.TwinColSelect
[INFO] com.vaadin.ui.Upload
[INFO] com.vaadin.ui.UriFragmentUtility
[INFO] com.vaadin.ui.VerticalLayout
[INFO] com.vaadin.ui.Window
[INFO] org.vaadin.browsercookies.BrowserCookies
[INFO] Done. (2seconds)
[INFO] Compiling 1 permutations
[INFO] Permutation compile succeeded
[INFO] Linking into /stf/prj/My_Project/src/main/webapp/VAADIN/widgetsets
[INFO] Link succeeded
[INFO] Compilation succeeded -- 40.785s


To be able to serve my webapp using tomcat launched from eclipse I need to compile the GWT stuff into src/main/webapp . So unlike the instructions I mention at the top of this post, some key parts of my pom is as follows:
  <properties>
<vaadin-widgets-dir>src/main/webapp/VAADIN/widgetsets</vaadin-widgets-dir>
</properties>
<build>
<plugins>
<!-- Compiles your custom GWT components with the GWT compiler -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.3-SNAPSHOT</version>
<executions>
<execution>
<configuration>
<webappDirectory>${vaadin-widgets-dir}</webappDirectory>
<extraJvmArgs> -Dgwt.style=PRETTY -Xmx512M -Xss1024k</extraJvmArgs>
</configuration>
<goals>
<goal>resources</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Updates Vaadin 6.2 widgetset definitions based on project dependencies -->
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>update-widgetset</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<!-- also delete the generated vaadin web content -->
<directory>${vaadin-widgets-dir}</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>

7 comments:

  1. Works a treat. I changed mine to put these plugins in a Maven profile that I only use if I add a new add-on that has a custom widget set and I SVN-commit the contents of the src/main/webapp/VAADIN/widgetsets folder so my "normal" builds remain very fast.

    ReplyDelete
  2. Great!
    Many thanks for sharing this stuff, it saved me from a lot of headaches.
    Roberto

    ReplyDelete
  3. Hey, thanks very much!

    Changing the webappDirectory like that seems to be the only solution if your project has a widgetset and you want to use tomcat:run -- or your app will complain about missing widget resources on startup (because they get compiled to the target folder)

    I tried setting (inline)true(/true), but then the compiler didn't honour the trailing path on ${project.build.directory}/${project.build.finalName}/VAADIN/widgetsets - so the widgets just ended up in the local webapp folder, and it still failed.

    I'm a little surprised that this doesn't seem to be discussed in the Vaadin forums - so I was truly over the moon when I found your helpful information.

    Cheers

    ReplyDelete
  4. great information. thank you very much. I also spent more than a day gave up trying to fix this before.

    ReplyDelete
  5. I have a similar issue but I was using the vaadin eclipse plugin like you've mentioned above. Do you have a fixed in mind for the ones that are using the vaadin ecplise plugin in building the widgetset? Thanks for giving another angle to look at and hopefully fix this issue.

    ReplyDelete
  6. I am using vaadin eclipse plugin and i still get the error message. Pepe, did you get your problem solved?

    ReplyDelete