Running Vaadin Maven project with Tomcat

Hi!

First of all thanks for an amazing framework! It is really a pleasure to develop web application like it would be a desktop application!!

I hope my problem is quite small. I have installed vaadin eclipse plugin and I also use tomcat as mentioned in the book of vaadin. Everything work fine until I try to create a maven project using vaadin-archetype-clean archetype. It creates project just as I think it should but I can’t find any way to run it with tomcat like normal vaadin application.

I’ve been reading some posts but haven’t find the solution. Am I just missing something?

Thanks for any help!!

Hi Klaus,

Just add this to your pom and do a mvn tomcat:run on your project.
You should also install m2Eclipse to be able to run Maven with your IDE.

<plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>tomcat-maven-plugin</artifactId>
	<version>1.0-beta-1</version>
</plugin>

It worked…

I had the feeling that I was just missing something and I was… -_-

Thanks Anthony!!

You are welcome. I’m quite a noob @ vaadin but i’m using Maven since severals months.

I’m glad to help some people here :slight_smile:

(warning: likely a FAQ, sorry).

I am new to maven. I am now able to run my project successfully with jetty:run, and hot-reloading works fine.

But my final deployment platform is tomcat. So I would like to be able to do a first round of tests using tomcat without taking the time to build a war.

I would have thought that it was simply a matter of running maven with “tomcat:run” as per the documentation, but when I do, I get the dreaded “widget set not found on file system or through class loader” error. The VAADIN directory is present in my “target” directory, and the files created in my target/tomcat directory look normal.

What am I missing ?

As far as I know before running a tomcat:run, you need to package your application in order to let gwt-maven plugin to compile widgets sources but it depends on how u’hve configured it.
theses files will be placed into src/main/webapp/VAADIN/widgetsets folder

Normally, if you don’t modify your widget u’ll only have to do this once and hot deploy will run.

Try this !

The widgetset needs to be built once before publishing the project to Tomcat. Thereafter, full widgetset compilation should not be necessary unless you make client side changes.

First make sure your GWT plugin section in your pom.xml matches the Vaadin archetype 1.3.2 - with the configuration moved out of the execution section. That allows you to control where the widgetset is built.

When I need fast re-deployment without building a package, I usually use jetty. To do that with tomcat, you should take a look at the “exploded” or “inplace” deployment options of the tomcat maven plugin. Take a look at the “Context Goals”, “Deployment” and “Goals” sections of the
plugin documentation
.

I cannot give full instructions as I don’t have an example at hand at the moment - if you get this to work, please share the tomcat plugin configuration with others.

I have found what my problem was. When building the widget set, by defaut it ends up in the target webapps directory, which is as it should. jetty is able to find it there when running in place, but apparently not tomcat.

For tomcat:run to work without creating a war, the quick hack I have found is to change the pom.xml. In the gwt-maven-plugin section, using <webappDirectory>src/main/webapp/VAADIN/widgetsets</webappDirectory> allows tomcat:run to find the widgetset. I just told my version control to ignore the widgetsets directory so it does not get committed.

I have no clue how to compare my poms with the archetypes as they evolve. What is the easiest way to get to an archetype to look at it (I guess they lurk somewhere in the repository and http is fine ?)


https://vaadin.com/wiki/-/wiki/Main/Creating+an+Eclipse+Project

You have to add a configuration setting called: vaadin:compile (as shown in screenshot)
This will eradicate the warning.