How to run most basic Vaadin applications

I am trying to build a Vaadin out-of-the-box app and have had no success so far.

Using IntelliJ IDEA 14 added the correct Vaadin maven archetype and created the application.
I end up with three project folders (production, ui and widgetset) where, according to the tutorials, I would expect just a few files under src

. Anyway.

So now when I try to deploy under Tomcat I get the infamous

The requested resource [/VAADIN/widgetsets/com.vaadin.DefaultWidgetSet/com.vaadin.DefaultWidgetSet.nocache.js] was not found from the file system or through a classloader.

mistake. Enough articles on how to modify the web.xml file to fix this issue. However , I don't have a web.xml file to change.

I also don't need to add any client-side js, so I don't really need any stuff, I just need a Vaadin server.

Can I get rid of all the WidgetSet dependency, thereby getting rid of this error and just running the most basic Vaadin server applications without any fancy stuff?

I have tried commenting out all the links to the client compiler, widgetset and everything else that my little Java knowledge allows me and lost days in the process.

Some ingenious insight would be amazing. Thanks in advance.

+3


source to share


1 answer


So, you have a basic understanding of how Vaadin works. Here is some background information to clarify some things and perhaps provide relevant information to other interested users.

The idea behind GWT is that you use a Java application and run it through the GWT compiler. The output is javascript, which can be run in the browser directly. The compiler itself is a big part of what GWT is. The options for out-of-the-box functionality are pretty subtle in terms of widgets or components. It's more of a do-it-yourself mentality where they let GWT users or other framework developers fill the widget / graphics gap.

Vaadin uses GWT, but differs slightly from most GWT frameworks. Like other GWT extensions, Vaadin includes a set of widgets that gives you the ability to build most of your applications without having to change widgets. The point is that Vaadin in different ways is that it precompiles the widgets and on top of it and provides a link manager that allows you to manage the widgets from the server. This key difference is that while on almost all other GWT systems you have to run the GWT compiler after every UI change, in Vaadin you don't need to because the server manages layouts and widgets with JSON messages. In Vaadin, you compile when you change the behavior of the widget, not when you use it.

Since Vaadin does not require you to "GWT compile" the application all the time, it can provide you with a precompiled widget for your basic needs. This is called the DefaultWidgetSet. This is sufficient if you are not making client side changes or using any add-ons found in the root directory.

And then to the real problem. The archetype you are using came out a week ago. I don't know which tutorial you mean, but my bet is that it still references the old archetype and it needs to be updated. Usually, you should be able to launch the application with the following steps:

  • create project with archetype
  • run mvn install

    in root folder
  • run mvn jetty:run

    in ui folder (or alternatively deploy ui to another servlet container like tomcat via your IDE)

Since you are getting the error message you posted, it indicates that the application is actually trying to use the precompiled version, which is good, but for some reason it cannot find it. It should come from the widgetset module, from the vaadin-client-compiled dependencies in it:

<dependency>
  <groupId>com.vaadin</groupId>
  <artifactId>vaadin-client-compiled</artifactId>
  <version>${vaadin.version}</version>  
</dependency>

      



$ {vaadin.version} can be defined globally (as it should be there), or you can enter a version number there, for example 7.3.7

. For some reason it doesn't seem to find it. If it's not there, add it to the widgetset pom.xml and run it mvn install

on the widgetset (or parent, both are fine). Then go to ui and start the server again with mvn jetty:run

.

I'm not sure, but I am assuming that the archetype has its own widget and is independent of the pre-compiled widget. After that, you need the default widget instead of the custom one and remove the annotation for the widget in the UI class, but you haven't added the dependencies for the default widget.

As your use case is very simple, the archetype in question might be a little over the top. You have no reason to split your project into ui and widgetset unless you are developing client-side, and a module for creating a ready-to-deploy deployment package (production module) is definitely outside the scope of this area. Therefore, in this sense, widgets, production and parent modules are completely irrelevant for you.

If you want a simpler project structure, you can clone my git repository found here: https://github.com/Peppe-/hello-world . It has the old default base archetype for Vaadin as a base, but I've ripped out everything I don't need to develop a pure server side without fuss. pom.xml has dropped from about 200 lines of declarations to about 80, but that also means you have to add stuff back if you want to use additional features. As a compiler, or if you want to add css (change theme). You can get it and run it with this command:

git clone https://github.com/Peppe-/hello-world.git
cd hello-world
mvn jetty:run

      

Or after the first step, you can import it into IDEA and run it from there. Also, rename the package (by renaming the folders to src) if you want to use your own package name.

Sorry, I got carried away a little and rushed. Please ask any questions if I missed something.

+3


source







All Articles