Erro 404 usando a anotação @@WebServlet

2 respostas
fred_cbranco

Ola pessoal estou seguindo a apostila da k19 instalei o tomcat 7.0, mais quando uso a anotação @WebServlet para criar um servelet ele da erro 404, não aparece o Olá mundo que deveria aparecer.
Alguem ai poderia me ajudar?

Segue o codigo

package br.com.caelum.hibernate.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/OlaMundo")
public class OlaMundo extends HttpServlet{
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
PrintWriter writer = resp.getWriter();
writer.println("<html><body><h1>Olá Mundo</h1></body></html>");
}
}

Obrigado

2 Respostas

fred_cbranco

no console aparece este erro.

25/03/2011 23:33:13 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: C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Toshiba\Bluetooth Toshiba Stack\sys;C:\Users\Fred\Desktop\eclipse;
25/03/2011 23:33:13 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source’ to ‘org.eclipse.jst.jee.server:hibernat1’ did not find a matching property.
25/03/2011 23:33:13 org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler [“http-bio-8081”]
25/03/2011 23:33:13 org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler [“ajp-bio-8009”]
25/03/2011 23:33:13 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 529 ms
25/03/2011 23:33:13 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
25/03/2011 23:33:13 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.11
25/03/2011 23:33:14 org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler [“http-bio-8081”]
25/03/2011 23:33:14 org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler [“ajp-bio-8009”]
25/03/2011 23:33:14 org.apache.catalina.startup.Catalina start
INFO: Server startup in 671 ms

fred_cbranco

lembrando que usando o xml funciona perfeito

Criado 25 de março de 2011
Ultima resposta 25 de mar. de 2011
Respostas 2
Participantes 1