title: Eclipse Java EE and Tomcat 7: Error 404, requested resource not available
body: <p>Tomcat 7 on Eclipse Java EE is displaying HTTP STATUS 404, and THE REQUESTED RESOURCE IS NOT AVAILABLE.
  1) i dont know what i am not doing right? I have read loads of post on the sight and attempted to do what was possible to do, yet nothing has change. In some cases i got back my source code as a downloadable text file.</p>
  
  <p>This is my servlet program below:</p>
  
  <pre><code>package dbservlet;
  
   //all imports here
  
  public class TennisdbaseServlet extends HttpServlet {
  private static final long serialVersionUID = 1L;
  public TennisdbaseServlet() {}
  
  public void doGet(HttpServletRequest request,
     HttpServletResponse response)
     throws ServletException, IOException {
  
     Context envContext = null;
     try {
  
         Context envContext = new InitialContext(); 
         DataSource ds = (DataSource)envContext.lookup("java:/comp/env/jdbc/postgres"); 
         Connection con = ds.getConnection();
  
         Statement stmt = con.createStatement();
         String query = "select * from tennis_teams";
         ResultSet rs = stmt.executeQuery(query);
  
         PrintWriter out = response.getWriter();
         response.setContentType("text/html");
         out.print("&lt;center&gt;&lt;h1&gt;Tennis Teams Info&lt;/h1&gt;&lt;/center&gt;");
         out.print("&lt;html&gt;&lt;body&gt;&lt;table border=\"1\" cellspacing=10 cellpadding=5&gt;");
         out.print("&lt;th&gt;TEAM NUMBER&lt;/th&gt;");
         out.print("&lt;th&gt;PLAYER NO&lt;/th&gt;");
         out.print("&lt;th&gt;DIVISION&lt;/th&gt;");
  
         while(rs.next())
         {
             out.print("&lt;tr&gt;");
             out.print("&lt;td&gt;" + rs.getInt("teamno") + "&lt;/td&gt;");
             out.print("&lt;td&gt;" + rs.getString("playerno") + "&lt;/td&gt;");
             out.print("&lt;td&gt;" + rs.getDouble("division") + "&lt;/td&gt;");
             out.print("&lt;/tr&gt;");
         }
         out.print("&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;");
     }  catch (SQLException e) {
         e.printStackTrace();
     } catch (NamingException e) {
         e.printStackTrace();
     }
    }
  </code></pre>
  
  <p>}</p>
  
  <p>And following is my /META-INF/Context.xml code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;!-- The contents of this file will be loaded for web application --&gt;
  
  &lt;Context crossContext="true" docBase="TennisdbaseServlet" path="" reloadable="true" &gt;
    &lt;!-- Default set of monitored resources --&gt;
     &lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;
     &lt;Resource name="jdbc/postgres" auth="Container"
        type="javax.sql.DataSource" 
        driverClassName="org.postgresql.Driver"
        url="jdbc:postgresql://localhost:5432/tennisDB"
        username="ssssss" 
        password="ssssss" 
        maxActive="20" 
        maxIdle="10"
        maxWait="-1"/&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <p>And also below is my /Web_INF/web.xml :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app id="WebApp_ID" version="2.4"
  xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns   /j2ee/web-app_2_4.xsd"&gt;
  
  &lt;resource-ref&gt;
  &lt;description&gt;postgreSQL DataSource for Tennis Database Application&lt;/description&gt;
  &lt;res-ref-name&gt;jdbc/postgres&lt;/res-ref-name&gt;
  &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
  &lt;res-auth&gt;Container&lt;/res-auth&gt;
  &lt;/resource-ref&gt;
  
  &lt;display-name&gt;TennisDatabasePool&lt;/display-name&gt;
  
  &lt;servlet&gt;
  &lt;servlet-name&gt;TennisdbaseServlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;dbservlet.TennisdbaseServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;TennisdbaseServlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/TennisdbaseServlet.do&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>The console output is:</p>
  
  <pre><code>Nov 28, 2013 1:42:29 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: C:\Program Files\Java   \jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Common  Files\Microsoft Shared\Microsoft Online Services;C:\Program Files (x86)\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static\;C:\Program Files (x86)\Java\jre6\bin;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;PATH=C:\Program Files\Java\jdk1.7.0_45\bin;C:\Program Files\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program Files (x86)\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static\;C:\Program Files (x86)\Java\jre6\bin;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;PATH=C:\Program Files\Java\jdk1.7.0_45\bin;%PATH%;C:\Program Files\System Center Operations Manager 2007\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\System Center Operations Manager 2007\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Graphviz2.30\bin;C:\Program Files (x86)\MySQL\MySQL Utilities 1.3.4\;C:\Program Files\Java\jdk1.7.0_45\bin;C:\Program Files\Java\jre7\bin;.
  Nov 28, 2013 1:42:33 PM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["http-bio-8010"]
  Nov 28, 2013 1:42:33 PM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
  Nov 28, 2013 1:42:33 PM org.apache.catalina.startup.Catalina load
  INFO: Initialization processed in 5546 ms
  Nov 28, 2013 1:42:33 PM org.apache.catalina.core.StandardService startInternal
  INFO: Starting service Catalina
  Nov 28, 2013 1:42:33 PM org.apache.catalina.core.StandardEngine startInternal
  INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
  Nov 28, 2013 1:42:39 PM org.apache.catalina.startup.HostConfig deployDescriptor
  INFO: Deploying configuration descriptor C:\Users\Windows\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\conf\Catalina\localhost\TennisDatabasePool.xml
  Nov 28, 2013 1:42:40 PM org.apache.catalina.startup.SetContextPropertiesRule begin
  WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:TennisDatabasePool' did not find a matching property.
  Nov 28, 2013 1:42:43 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-bio-8010"]
  Nov 28, 2013 1:42:43 PM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["ajp-bio-8009"]
  Nov 28, 2013 1:42:43 PM org.apache.catalina.startup.Catalina start
  INFO: Server startup in 10091 ms
  </code></pre>
  
  <p>Your help is highly appreciated.</p>