Using Vaadin with Maven 2

Hi All,
After spending a bit of time trying to deploy my Vaadin application with custom widgets using Maven 2, I got it working with the codehaus gwt-maven plugin. In case anybody else is coming up against the same problem, I created a Maven archetype that will generate a Maven version of the Vaadin Color Picker Demo application.
To download the Archetype, and for instructions on how to use it, check out the wiki:


http://dev.vaadin.com/wiki/Articles/MavenIntegration

Cheers,
Daniel

Awesome addition to the toolset Daniel! Great work!

/Jonatan

Wow that’s great !

So much easier than using an antrun task ^^

Quentin.

Looks like there is a typo in the maven code you posted on the page http://dev.vaadin.com/wiki/Articles/MavenIntegration

I could get it to work with the following command

mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=org.stephane -DartifactId=vaadin-demo

which reads a trailing s at org.apache.maven.archetypes

The current archetype has a slight isssue when launching jetty using mvn jetty:run.

This is a known bug with jetty and mvn. It has been documented here → http://jira.codehaus.org/browse/JETTY-680

Due to this bug, when running mvn jetty:run from the vaadin project, you get the following error…

[INFO]

[ERROR]
BUILD ERROR
[INFO]

[INFO]
Failed to configure plugin parameters for: org.mortbay.jetty:maven-jetty-plugin:6.1.19

(found static expression: 'src/main/webapp,/Users/dummy/workspace/vaadin.test/target/vaadin.test-0.0.1-SNAPSHOT' which may act as a default value).

Cause: Cannot assign configuration entry ‘resources’ to ‘class [Lorg.mortbay.resource.Resource;’ from ‘src/main/webapp,/Users/dummy/workspace/vaadin.test/target/vaadin.test-0.0.1-SNAPSHOT’, which is of type class java.lang.String

You can resolve this issue by changing the pom file as shown below… I have commented the original entry and changed it to what is shown below:

        <!-- A simple Jetty test server at http://localhost:8080/vaadin.test
             can be launched with the Maven goal jetty:run and stopped with jetty:stop -->
        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>6.1.19</version>
            <configuration>
                <stopPort>9966</stopPort>
                <stopKey>vaadin.test</stopKey>
                <!-- Redeploy every x seconds if changes are detected, 0 for no automatic redeployment -->
                <scanIntervalSeconds>0</scanIntervalSeconds>
                <!-- make sure Jetty also finds the widgetset -->
                <webAppConfig>
                    <contextPath>/vaadin.test</contextPath>
                    <baseResource implementation="org.mortbay.resource.ResourceCollection">
                        <!--<resources>src/main/webapp,${project.build.directory}/${project.build.finalName}</resources> -->
                    	<resourcesAsCSV>src/main/webapp,${project.build.directory}/${project.build.finalName}</resourcesAsCSV>
                    </baseResource>
                </webAppConfig>
            </configuration>
        </plugin>
    </plugins>

Cheers,
Jay

The Jetty issue workaround has been added to vaadin-archetype-sample version 1.0.5, where the dependencies on Vaadin and GWT versions were also updated (http://dev.vaadin.com/ticket/3694).

The typo in the archetype name in http://dev.vaadin.com/wiki/Articles/MavenIntegration has been corrected.

Hello all,

I’m having troubles trying to compile a custom widget with Maven 2 using gwt-maven-plugin (version 1.2) and vaadin-maven-plugin (version 1.0.0).

I configured my maven project just as it says on section “Adding widgetset compilation to an existing Vaadin project” of
MavenIntegration
and after execute the command mvn clean install everything looks fine except for the following messages:

[INFO]
 [gwt:resources {execution: default}]

[INFO]
 auto discovered modules [com.example.widgetset.MyWidgetSet]

[INFO]
 1 source files copied from GWT module com.example.widgetset.MyWidgetSet
[INFO]
 [compiler:compile]

[INFO]
 Compiling 160 source files to /Users/me/example/workspace/my-project/target/classes
[INFO]
 [gwt:compile {execution: default}]

[INFO]
 using GWT jars from project dependencies : 1.7.0
[INFO]
 auto discovered modules [com.example.widgetset.MyWidgetSet]

[INFO]
 establishing classpath list (scope = compile)
[INFO]
 com.example.widgetset.MyWidgetSet is up to date. GWT compilation skipped
[INFO]
 [vaadin:update-widgetset {execution: default}]

[INFO]
 auto discovered modules [com.example.widgetset.MyWidgetSet]

[INFO]
 Updating widgetset com.example.widgetset.MyWidgetSet
[INFO]
 establishing classpath list (scope = compile)
[ERROR]
 Feb 11, 2010 6:51:08 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
[ERROR]
 INFO: Widgetsets found from classpath:
[ERROR]
 	com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:/Users/me/.m2/repository/com/vaadin/vaadin/6.2.2/vaadin-6.2.2.jar!/
[ERROR]
 	com.example.widgetset.MyWidgetSet in file:/Users/me/example/workspace/my-project/src/main/java
[ERROR]

After that, the build is successful but the gwt compiler did not compile my custom widget. The VAADIN/widgetsets folder was created under the target/artifactId-version folder but it is empty, no widget in there.

Any idea or suggestion?

I believe you might have have run into one of two Maven GWT plugin bugs:
MGWT-147
or
MGWT-148
.

You could try the gwt-maven-plugin version 1.3 (or a snapshot) in which both should be fixed.

Thank you very much Henri!!!

I never thought that the last stable release (gwt-maven-plugin 1.2) was completely useless. I think this should be reported in the wiki article “MavenIntegration” don’t you think?

Thanks again.

I have another question:

I inherited my widgetset from com.vaadin.terminal.gwt.DefaultWidgetSet and at the moment of building the project with maven, all the default components were included successfully but I noticed that the default themes were not created on VAADIN/themes.

Is there something missing here or the vaadin-maven-plugin doesn’t consider the themes and I have to do that manually?

One more time thank you!!!

In basic development use, you don’t need copies of the standard themes in VAADIN/themes - they can be served by the Vaadin ApplicationServlet directly from the JAR as long as you have the correct servlet mapping for /VAADIN in your web.xml . In fact, it is usually better not to copy in development environments them unless you need them so that you would not run into mismatching theme versions when upgrading Vaadin. Your own themes should, of course, reside in VAADIN/themes.

In production environments, on the other hand, it does make sense to copy also the basic themes out of the JAR and have the web server serve them statically for improved performance.

Hi, I cant get this archetype to work. I get:

Requested resource [VAADIN/widgetsets/com.skillkash.ge.gm.gwt.ColorPickerWidgetSet/com.skillkash.ge.gm.gwt.ColorPickerWidgetSet.nocache.js]
not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.

Steps to recreate:

  1. have the latest eclipse helios with m2eclipse plugin.
  2. file->new->other->Maven Project-
  3. chose vaadin-archetype-sample
  4. project loads up in eclipse
  5. run as->Maven package
  6. Project properties->Server assign my local tomcat 6 server.
  7. run as-> run on server.
  8. tomcat loads up, and a webpage loads up in clipse with a spinning graphic in the center, and a message pops up:

Requested resource [VAADIN/widgetsets/com.skillkash.ge.gm.gwt.ColorPickerWidgetSet/com.skillkash.ge.gm.gwt.ColorPickerWidgetSet.nocache.js]
not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.

Any documentation on how to get this sample working?

Anyone know where I might find a widgetset and/or theme, and how I can add it to the pom.xml as a dependency?

Is ther eany documentation for how to run these sample apps, e.g. what maven targets are supplied?

As mentioned in a previous post, the GWT compiler Maven plugin had some bugs, and the archetype still used an old version of that plugin.

You could try the latest (1.3.0) version of the archetype, which uses the correct version of the plugin.
At least running “mvn clean package” should then also compile the widgetset correctly. I’m not sure if m2eclipse does this automatically when you select “Run on server” - if it does not seem to work, try Run As → “Maven package” first. If you have problems with this approach, you could also try to see if “mvn clean package jetty:run” works in your environment.

These are somehow listed on
the wiki page
, but the page should be updated with more current information.

Briefly:


  • vaadin:update-widgetset
    updates the widgetset definition if you have added add-ons with client side components to the project

  • jetty:run
    launches an embedded Jetty for testing your servlet

  • gwt:run
    launches the GWT development mode shell for debugging of client side code - note that you also need to change the POM to enable remote debugging, and run the server (e.g. jetty:run) in a separate process

  • gwt:clean
    and
    gwt:compile
    should be run automatically with the current plugin when you change the widgetset definition or client side code - you should not need to call them explicitly anymore

Does anyone else get this error:

[INFO]
 The plugin 'org.apache.maven.plugins:maven-vaadin-plugin' does not exist
or no valid version could be found

The plugin is right there in the m2 directory:

\.m2\repository\com\vaadin\vaadin-maven-plugin\1.0.0

I have no idea what’s going on … :mellow:

Maven seems to be looking for the Vaadin plugin under org.apache.maven.plugins . Check that you are using the groupId com.vaadin for the plugin in your pom.xml .

Well spotted, i should have seen that.

I spent a lot of time the last couple of days trying to get VisualizationsForVaadin to work and i now i finally get it to run update-widgetset without errors. In case someone else is facing the same problems, this is the error i was getting:

[ERROR]
 Exception in thread "main" java.io.IOException: The system cannot find the path specified
[ERROR]
         at java.io.WinNTFileSystem.createFileExclusively(Native Method)
[ERROR]
         at java.io.File.createNewFile(File.java:883)
[ERROR]
         at com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder.updateWidgetSet(WidgetSetBuilder.java:75)
[ERROR]
         at com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder.main(WidgetSetBuilder.java:51)

And the solution is to get the new version of Vaadin. The versions i use now without errors:
Vaadin: 6.4.0
VisualizationsForVaadin: 0.0.5
gwt-user: 2.0.4
gwt-visualization: 1.1.0
vaadin-maven-plugin: 1.0.0
WTP: 2.0
gwt-maven-plugin: 1.3-SNAPSHOT
Java 1.6, tomcat 6 and eclipse Galileo

Having said that - all install does is make an empty gwt folder in my target directory. I still dont have VisualizationsForVaadin running. :frowning:

Did you try running
gwt.compile
explicitly? Does that make any difference? Any messages about widgetset compilation?

Sorry to prolong the agony but I’m sort of new to Vaadin/Maven (I’m revisiting Maven after several years).

I’ve just ran the ‘mvn jetty:run’ command against Vaadin’s clean project archetype:

and Maven (2.2.0, OS X 10.6.4, JDK 1.6.0_20) is complaining about:

which is true as

no

‘SNAPHOT’ folder is created in the ‘target’ output folder.

I visited my pom.xml file, Vaadin is version 6.4.0, the Vaadin archetype
“1.0.5 resourceAsCSV” fix



is


in place, I tried/clutched at ’
mvn gwt:compile
’ but nothing.

Please help, as I’m proposing this technology to my boss at work, and in it’s current state, Maven build errors are not going to sell him the idea of either Maven or Vaadin (I

NEED

to develop with cool bits of technology to remain sane :grin: )

Cheers

Richard

P.S. I tried this with both the clean and sample Maven archetypes.
[u]

[/u][i]

[/i]

Hey, we like to bring solutions sometimes, not just problems :wink:

  1. I upgraded to Maven 2.2.1 (May not be necessary)
  2. After generating/downloading the Vaadin sample archetype, I did a ‘mvn clean package’ as suggested. This built the missing ‘widgetset’ (nb, ‘mvn gwt:compile’ did
    NOT
    do this).
  3. finally, I ran ‘mvn jetty:run’, and was greeted by a colour chart at http://localhost:8080/<my_vaadin_project_artifact_name>
  4. That’s it!

Cheers

Rich