Newbie question - configuring Eclipse and Tomcat


I’m new to vaadin and am having some trouble setting up a development environment. I’m using Eclipse and Tomcat under Ubuntu Linux. I followed the instructions in the Book of Vaadin under “Your First Project with Vaadin”. This all works – more or less. The problems I’m having are:

  1. “Run on Server” sometimes starts the application properly, but sometimes I get an error from Tomcat: “HTTP Status 404-” “The requested resource() is not available”

  2. If I make changes to the code, they are usually not reflected in the application. This is true even if I manually save the source file and tell Eclipse to clean the project. I would like the source file to be saved automatically and the application rebuilt using the new source, if I select “Run on Server” while a source file is open in the editor. I’ve been able to configure this behavior when using Eclipse to build java or C++ programs for other platforms.

Thanks in advance for your assistance.

Matthew Fleming, MD
Fleming Dermatopathology
Milwaukee, WI

On my system 404 usually means the Eclipse is still deploying the project, make sure Eclipse has finished deploying the project before you run it again. Have you tried running the application with ?restartApplication parameter like
that will restart the application with the latest changes.

Thanks very much.

Running http://localhost:8080/myapp/?restartApplication instead of http://localhost:8080/myapp in an external browser allows me to see my code changes, ie runs the latest version of the application. However, can I configure Eclipse to use this parameter when running the application within its built-in browser?

Also, with respect to the “HTTP Status 404-” error, I’ve noticed that I get this if I select “Run on Server” from Eclipse’s top menu, but not if I select "Run on Server’’ from the pop-up menu produced by right-clicking on the application in the Project Explorer. This seems to be some kind of bug, because the two should do exactly the same thing.

Thanks again,

Matthew Fleming


I will start with introducing myself so that you know what to expect. I have programming experience in PHP, Javascript, HTML, Pascal, VB, little bit C#, etc. (not to write a complete CV here :slight_smile: ) Never done anything with Java. Also - have seen Eclipse only for a little moment and not more. Now I have read a dozen of glorifying articles about Vaadin and decided to give me a try on it…

I have tried to follow the tutorial on the Vaadin’s site to create some “hello world” (or address book) application and I have strange results. To be more precise - my results are the same as described by Matthew G Fleming: sometimes I get the resource not available error, sometimes the application runs. Also - sometimes the code changes are reflected on the page, but sometimes not. Also - the buttons on the eclipse toolbar are doing something obviously different than right-clicking on the project and selecting debug or run on server. In fact, I have followed the tip on the tutorial and recreated the project for several times with no apparent benefit.

Since I am so new to all of this, I expect this to be my mistake and something very easy to solve, therefore I would appreciate if someone would just point me out to the right direction. The tutorial seems to be made for some older version of Eclipse and/or Vaadin and/or Tomcat, therefore something might have changed since that and this could probably be the reason of my failure (just a guess). Also I suspect that somewhere in the manual or tutorial someone has mentioned that everything works best with version X of Eclipse and version Y of Tomcat, which I haven’t read and maybe I just need to download older and more compatible versions of everything. Again - this is just my guess.

I will describe what I have done so far (I have Windows 7 x64):

  1. unzipped Eclipse (Build id: 20100617-1415) to desktop\eclipse folder
  2. unzipped Vaadin to desktop\eclipse\vaadin-6.4.2 folder
  3. unzipped Tomcat to desktop\eclipse\apache-tomcat-7.0.2 folder
    I have put them all in desktop\eclipse folder intentionally just not to make mess on my PC. Surely would put in other places for production or serious development, so please don’t make fun of this.
  4. installed everything that Eclipse offered when I entered the link provided in tutorial (
  5. in preferences added server->runtime environment of type Tomcat v7.0 and specified Program Files\Java\jdk1.6.0_21 as the JRE and the location of Tomcat (Desktop\eclipse\apache-tomcat-7.0.2)
  6. created a new Vaadin project, specified everything as similar to tutorial as possible. Tried several times, hence with different options, but got the same results all the time (as described above).

I would really appreciate a link to some article where only the most important things are described that should be configured in Eclipse in general and in the project settings. There are so many properties in Eclipse and I guess that only some of them need to be configured for Vaadin to work. I would like to know which properties are important to get Vaadin running without spending week on studying the entire Eclipse. Also - if there is some very basic and very short intro (15 minute intro) to Java as much as I would need it in relationship to Vaadin, then I would like to read it. Since I am comfortable with programming in other languages, I would mostly need to understand the main idea of how things work (the idea of .war files and other conceptual things e.g. what happens when I launch the project in Eclipse - in brief), rather than total step-by-step tutorial for complete newbies.

Finally, one more thing. By playing with the run/debug buttons and configurations - sometimes the project runs in internal browser, but sometimes only the server (or something alike) is running on background without opening the browser. I really can’t understand which setting controls that and which buttons are for what purpose. Not to mention that those run/debug configurations are totally incomprehensible. Seems that “running the application” should be the central and the easiest button in every IDE, but Eclipse has made the things more difficult than that (at least for newbies).

Any help will be appreciated.
Thank you in advance!

Ok, I have downloaded and installed NetBeans with integrated GlassFish together with Vaadin plugin, but there is still a problem. Sometimes the changes in the code are reflected in the application, but sometimes - they’re not. [color=#FF0000]


[/color] The parameter
really helps in this situation, but
isn’t there any easier way of doing that instead of manually altering the URL every time?


This was the same with Eclipse and now it is with NetBeans too. Probably there is something very general that I don’t understand about Java Web application development. Of course, I can not read all the manuals in a snap and learn the technology from A to Z, but someone could just tell the essential things that I should read or just understand about Java Web development and Vaadin in this same context.

I have been in PHP world and I see that Java is really different. The code is organized in different way, also it is compiled or something alike… These things are probably very important to understand, but I am just in the beginning of the long way to Java and I am quite desperate of the thought that I must read a zillion of tutorials before I can even start producing my own “Hello Vaadin user” application. :frowning:

The real question here would be:
what happens between the source code changes and the refresh in web browser?
When I save the source code in an IDE - something parses the code, something compiles or does whatever, then something even executes it, and so on… Then I refresh the page in browser and see the results, which are not always what I expect. If someone could just describe all these steps, then I could probably understand a very important part of the technology.

The missing piece is called “deployment” in J2EE jargon, and Eclipse calls that “Publishing”. The files you see in your Eclipse directory are not the ones run by Tomcat. The plugin for tomcat copies them to the Tomcat directory. Normally, when you change a Java file, the plugin will copy it to the Tomcat directory, and the Tomcat server will restart. For Java files, this is pretty reliable. For other files (CSS, for instance), it is hit and miss (at least on Windows).

In the Servers tab you can tell Eclipse to clean up the files it has copied to Tomcat and re-publish.
See – look at the screenshots for “Publish Clean” and for “Manage Tomcat Work Directories”

Thank you very much for your explanation! This helped me a lot to understand how things work.

I have tried the several “clean” options, but as far as I understand, they all are trying to restart the Tomcat, which is quite slow.

What is the real way how developers actually work in this environment? Do they always use the
parameter? I don’t believe that people are restarting their servers all the time. If the URL parameter is the only fast solution (isn’t it?), then - is there a way to tell Eclipse to automatically add this parameter to the URL it loads? Or… Are the real programmers typing this
?restartApplication ?restartApplication ?restartApplication
five hundred times a day?

The only reason I am putting up with this is that my production environment is Tomcat.

There is an alternate way of running a web application. A Servlet container is in fact a Java program like any other.
You can actually run it as a Java application that calls your classes and vaadin as a regular Java application. In that mode, most modifications do NOT require you to restart the application, using a feature called “Hot Code Replacement” which Java provides.

A “rainy day” project of mine is to understand how to run Jetty under Eclipse in the manner I have just described while keeping the ability to test under [edit]
as well. I keep getting the impression that Eclipse supports Jetty out of the box [edit]
but I haven’t found the time to confirm this and if so, to make sure it runs things in hot replace mode.[edit]

Does the Vaadin plugin support running with Jetty and hot code replacement ? I tried Tomcat running in place (no deployment) with hot code replacement (tweaking the server settings) and wasn’t successful.

Eclipse does indeed come bundled with Jetty, as long as you download the JEE version of Eclipse, which contains all the web development stuff. Jetty is called
J2EE Preview
inside Eclipse, which is bound to mislead people, but it’s Jetty alright.

Most of us here at Vaadin use the Jetty that comes with Eclipse, the hot code replacement works very well most of the time, for all types of resources, not just Java classes. I personally still use ?restartApplication most of the time, typing that has become second nature by now for us working with Vaadin day to day (not a terribly good thing, I guess).

The Vaadin plugin in my opinion doesn’t take any preference with servlet containers, it should work with all of the supported ones, and it shouldn’t affect hot code replacement in any way.

Thank you for your answers!

Now I know what to look for and what to learn about. As I see from this point, I need to read about “Hot Code Replacement” and “J2EE Preview” to understand more clearly everything you said.



Is there any tutorial or manual that guides the beginners how to set up the tings this way? Sorry for asking, if it is mentioned in the Book of Vaadin - I just haven’t read all of the book, yet. Just a couple of pages of this and that…

I think I just managed how to set up things this way. See the next post.[color=#FF0000]


I just checked what version of Eclipse am I using and - yes, I have the right version that contains Jetty. Just browsed through various settings and found what you were talking about and managed to enable it. For somebody who’s also interested - I’ll explain in more detail:

  1. in eclipse I opened window->preferences
  2. server->runtime environments
  3. add->basic/J2EE preview + “create a new local server” = checked

Now I have the “thing” enabled and it looks like it is really working. So…to get the code changes visible in the browser…

  1. it really requires no restart of anything, BUT…
  2. …it really requires the ?restartApplication appended to the URL in the internal browser where application is loaded

As I understand, there is no workaround to get rid of the ?restartApplication. No way how to automate this thing, really. Or is there something we still don’t know?

Another thing, a little bit unrelated, but still a problem:
Sometimes when I click the Debug button, it just starts something (probably the Jetty or Tomcat) in the background without opening any browser. No internal browser, no external… Looks strange, and I solve it by trying it again and in worse case I need to right click the project in the tree and select Debug as->Debug on server. Probably I just don’t understand some small thing about the UI of the Eclipse IDE. How do I know if the browser will be loaded or no? Or…can it be a bug??? I assume it isn’t a bug, because I’m too new to these things and can’t blame software I don’t know how to properly use. Anyway - some explanation about the difference between right-clicking in the tree and shortcuts in toolbar would be really helpful. I mean both Run and Debug actions.

This is because the application state is in/linked to the session. As long as the application server does not clear the sessions on hot code replace, the old state is used. Therefore, some changes (related e.g. to the bodies of methods or opening new parts of the UI) are immediately “visible” upon reload, while others (e.g. the structure of the open view) are not as long as the old session is preserved.

The behavior of the debug buttons etc. depends on your Eclipse configuration and on what is selected when you click the button - Window → Preferences → Run/Debug → Launching. Personally, I configure the button to always launch the previously launched application (never what is selected), especially when developing web applications. Furthermore, I never let Eclipse open a browser for me but always manage browser windows myself.