Results 1 to 2 of 2
  1. #1
    nyg is offline Member
    Join Date
    Nov 2015
    Rep Power

    Default TomEE: 404 with a simple HttpServlet


    I have created a simple class extending HttpServlet with the following code:

    Java Code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.annotation.*;
    public class SimpleHttpServlet extends HttpServlet {
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
            PrintWriter out = response.getWriter();
            out.println("<h1>Hello Servlet Get</h1>");
    I then compiled the class using the following command:

    Java Code:
    javac -cp "/path/to/tomee/lib/*"
    I only get the following warning:

    Java Code:
    warning: Supported source version 'RELEASE_6' from annotation processor 'org.apache.openjpa.persistence.meta.AnnotationProcessor6' less than -source '1.8'
    1 warning
    I package the application into a war with the following command:

    Java Code:
    jar cf simple_http_server.war SimpleHttpServlet.class
    After starting TomEE with bin/ I deploy the war with

    Java Code:
    bin/ deploy path/to/my/simple_http_server.war
    All looks good as I get the following output:

    Java Code:
    deploying /Users/nyg/Desktop/simple_http_server.war
    Nov 01, 2015 5:39:50 PM org.apache.openejb.client.EventLogger log
    INFO: RemoteInitialContextCreated{providerUri=http://localhost:8080/tomee/ejb}
    Application deployed successfully at "/Users/nyg/Desktop/simple_http_server.war"
        EjbJar(id=simple_http_server, path=/Users/nyg/Downloads/apache-tomee-plus-1.7.2/apps/simple_http_server)
        WebApp(context-root=/simple_http_server, id=simple_http_server, path=/Users/nyg/Downloads/apache-tomee-plus-1.7.2/apps/simple_http_server)
    When going to http://localhost:8080/manager/html I can see my war and everything looks okay. However, when I go to http://localhost:8080/simple_http_server/HttpServer I get a nice 404:

    Java Code:
    HTTP Status 404 - /simple_http_servlet/HttpServlet/
    type Status report
    message /simple_http_servlet/HttpServlet/
    description The requested resource is not available.
    Apache Tomcat (TomEE)/7.0.62 (1.7.2)
    From what I understand, the web.xml is not mandatory. What have I missed?

    Thanks a lot!

  2. #2
    nyg is offline Member
    Join Date
    Nov 2015
    Rep Power

    Default Re: TomEE: 404 with a simple HttpServlet

    Okay, found out .class files must be in WEB-INF/classes...

Similar Threads

  1. TomEE and MySql - query don't returns any results
    By beginner_user in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 09-13-2013, 10:24 AM
  2. ejb implementation in eclipse and tomee
    By rushtosenthil2004 in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 07-06-2013, 02:28 PM
  3. HttpServlet
    By paul21 in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 11-07-2009, 05:20 AM
  4. HTTPServlet library
    By Robert_85 in forum Advanced Java
    Replies: 1
    Last Post: 04-10-2009, 09:28 PM
  5. HttpServlet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-17-2007, 08:46 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts