Noob 404 question

Im a trying out Vaadin, but have a hard time getting a Hello World example running consistently.
Sometime it works, sometimes it doesnt.

This is an example of the steps I took:

  1. Start Eclipse
  2. Select the default workspace ~/workspace
  3. File>New>Vaadin 7 project
    set Apache Tomcat v 7.0
    Vaadin 7, Java 6, Servlet 3.0
    Servlet(default)
    Vaadin version 7.2.4
    click on the other defaults
  4. right click on the project, Run As> Run on Server > Tomcat v7.0 on localhost

HTTP status 404: The requested resource is not available

  1. Stop the server
  2. under Servers, rightclick on the Tomcat server. Choose
    Clean Tomcat work directory…
    Rightclick again, choose Clean…
  3. right click on the project, Run As> Run on Server > Tomcat v7.0 on localhost

Same result: 404

Also http://localhost:8080/yetagain/?restartApplication
gives a 404

I looked at the forums and consulted Google, but I’m stilling missing something important.

Any help is appreciated

Looks like you are doing it right, but yet there’s something wrong.

I tried following your steps, and actually also got 404. Looks like it always occurs when I deploy a new project to an already running server in any way. When I restarted the server, it worked just fine, and can’t reproduce it any longer. Deploying to non-running server works just OK when it’s started. I don’t know what problem you might have if it doesn’t work for you. (I’m using TomEE 1.7 snapshot, but Tomcat 7 shouldn’t be different.)

Another reason could be that the URL is wrong or there’s something wrong with the servlet. The Vaadin 7 + Servlet 3.0 projects have the servlet defined with a @WebServlet annotation. The URL context is by default the project name.

Hi Marko,

thanks for the reply. This is all very unfamiliar territory for me, so please bear with me. When you say “When I restarted the server, it worked just fine, and can’t reproduce it any longer.” What did you exactly do? I tried two things

First thing

  1. Create new Vaadin 7 project
  2. close Eclipse and open Eclipse
    Now tomcat was in the [Stopped]
    stat
  3. Right click the project, Run as , Run on Server
    This started tomcat. It showed [Starting, synchronized]
    for a while, but again it resulted in a 404

The other thing

  1. Manually stopped the server
  2. Started the server by rightclicking in the ‘Servers’ view
  3. Right click the project, Run as , Run on Server
    again 404…

About the servlet:
The project name is HelloVaadin inside Java Resources/src/com.example.hellovaadin/HellovaadinUI.java i have the following code:

package com.example.hellovaadin;

import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings(“serial”)
@Theme(“hellovaadin”)
public class HellovaadinUI extends UI {

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

@Override
protected void init(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    setContent(layout);

    Button button = new Button("Click Me");
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            layout.addComponent(new Label("Thank you for clicking"));
        }
    });
    layout.addComponent(button);
}

}

I can tell there is a @WebServlet annotation. I am not familiar enough with servlets to be able to tell whether it makes sense…

The contents of my web.xml is

<?xml version="1.0" encoding="UTF-8"?> HelloVaadin index.html index.htm index.jsp default.html default.htm default.jsp

Again, this is not my home turf. But I would expect some < servlet> here…

Finally I checked my tomcat logfiles. There I find very little activity, but no error messages.

I restarted the server in the Servers tab.

I usually add a project to a server in the Servers tab. The Run As launches the internal browser in Eclipse, but I usually prefer using a regular browser. But using Run As shouldn’t be a problem here.

I really hope that your server really is Tomcat 7, as Tomcat 6 doesn’t support @WebServlet deployment.

The Console tab in Eclipse should show Tomcat’s server log, which is informative if there’s a problem.

Thats helpful, but iḿ not there yet.

My server is Tomcat 7.0.54, I even checked the MD5 :slight_smile:

It seems that my issue is not very Vaadin specific. Since I tried to run a simple Hello World servlet as per
http://www.srccodes.com/p/article/3/Tomcat-Hello-World-Servlet-using-Eclipse-IDE and i get similar behaviour there (404)

I did look at the console tab. There I found a WARNING:

Jul 04, 2014 5:12:59 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386/client:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386::/usr/java/packages/lib/i386:/usr/lib/i386-linux-gnu/jni:/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu:/usr/lib/jni:/lib:/usr/lib
Jul 04, 2014 5:13:00 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]
{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:HelloVaadin2’ did not find a matching property.
Jul 04, 2014 5:13:00 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler [“http-bio-8080”]

Jul 04, 2014 5:13:00 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler [“ajp-bio-8009”]

Jul 04, 2014 5:13:00 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1006 ms
Jul 04, 2014 5:13:00 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 04, 2014 5:13:00 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Jul 04, 2014 5:13:03 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler [“http-bio-8080”]

Jul 04, 2014 5:13:03 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler [“ajp-bio-8009”]

Jul 04, 2014 5:13:03 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3391 ms

Problem solved.

The checkmark next to Project/Build automatically was unchecked.
So Eclipse did not generate .class files :slight_smile:

Thanks again to Marko. Now i can get on with my life (and the Vaadin book)