3

I have created a vaadin web application using maven in eclipse. In particular I have used the archetype vaadin-archetype-touchkit as described in the book of vaadin (20.3.4). Without making any change on the default generated code I have run it with maven with goals clean package. Then I compiled the Widgetset. When I try to run it on Tomcat 7, I receive the strange message from the webpage:

Failed to load the WidgetSet:
<WidgetSet Path>.DefaultWidgetSet.nocache.js 

On the console I see also the error messages:

INFO: Requested resource [/VAADIN/themes/reindeer/styles.css] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.

INFO: Requested resource [/VAADIN/widgetsets/com.vaadin.DefaultWidgetSet/com.vaadin.DefaultWidgetSet.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.

INFO: Requested resource [/VAADIN/themes/reindeer/styles.css] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.

It has struck me maven has not created a web.xml file, although I have read in the tutorial that it is no more necessary in vaadin 7. I have read the similar question where it is proposed that an adjustment in web.xml file should be done. Should I infer that I have also to create a web.xml file manually?

I find strange as well, that when I tried the same procedure with the archetype for a typical vaadin 7 application, it runs properly. Since I have to develop a touchkit-application I would appreciate any suggestion-idea abut what could be missing on my original attempt.

Community
  • 1
  • 1
arjacsoh
  • 8,932
  • 28
  • 106
  • 166

3 Answers3

4

The web.xml is no longer needed only if you use servlet 3.0 configuration (annotating your servlet as described 4.8.3. WEB Servlet Class)

Usually you'd configure your Vaadin 3.0 Servlet Config in this way:

public class MyUI extends UI {

      @WebServlet(value = "/*", asyncSupported = true)
      @VaadinServletConfiguration(productionMode = false, ui = MyUI.class)
      public static class Servlet extends VaadinServlet {
      }

      @Override
      protected void init(VaadinRequest request) {
            //your init stuff here
      }
}

Where using the @VaadinServletConfiguration as shortcut for setting vaadin-related params.

Now, if you have no vaadin addon in your project (so you're using the default widgetset), that's it, no more work is required.

Instead, if you're using custom addons, you must specify which widgetset to use in the @VaadinServletConfiguration simply by adding the widgetset parameter in this way

public class MyUI extends UI {

      @WebServlet(value = "/*", asyncSupported = true)
      @VaadinServletConfiguration(widgetset="com.bla.bla.MyWidgetSet",productionMode = false, ui = MyUI.class)
      public static class Servlet extends VaadinServlet {
      }

      @Override
      protected void init(VaadinRequest request) {
            //your init stuff here
      }
}

Otherwise you must create the web.xml manually as usual...

When it comes to maven, I think you've just to run mvn clean package and on the package phase the maven-vaadin-plugin will compile you're widgetset automatically.

Yngwie89
  • 1,217
  • 9
  • 17
  • Thank you for your help. The annotions are generated automatically in a maven project. I tried to change it as you described, it is namely the case when one creates a vaadin project without maven but it cannot fin the annotation @VaadinServletConfiguration. Which jar should be imported in pom.xml? I tried the javax.servlet.api 3.0.1 and it did not work. – arjacsoh Sep 16 '13 at 10:21
  • Ok, I have updated the vaadin version from 7.0.4 (default) created by maven with 7.1.3 and now it finds the annotations and it works! The widgetset must be anyway defined in @ VaadinServletConfiguration as you suggest in your answer. In @ WidgetSet it stll does not work. – arjacsoh Sep 16 '13 at 10:38
3

For me, adding the following to pom.xml helped:

    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-client-compiled</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
geert3
  • 7,086
  • 1
  • 33
  • 49
  • This was the needed hint for me. I have a dependency to a project with the vaadin-client-compiled dependency. But that dependency was marked optional. I could have add the dependency in the main project but removing the optional element also worked for me. – Bruno Eberhard Oct 17 '16 at 10:15
0

here is the readme in the root of the project

To compile the entire project, run "mvn install". To run the application, run "mvn jetty:run" and open http://localhost:8080/ .

To develop the theme, simply update the relevant theme files and reload the application. Pre-compiling a theme eliminates automatic theme updates at runtime - see below for more information.

Debugging client side code - run "mvn vaadin:run-codeserver" on a separate console while the application is running - activate Super Dev Mode in the debug window of the application

To produce a deployable production mode WAR: - change productionMode to true in the servlet class configuration (nested in the UI class) - run "mvn clean vaadin:compile-theme package" - See below for more information. Running "mvn clean" removes the pre-compiled theme. - test with "mvn jetty:run-war

follow the instruction and you will get the correct page : )