0
votes

Setup: Tomcat 7 Server, Eclipse Mars Milestone 3

The problem: When attempting to run Servlet files or connect to them the files 404. Although I can connect perfectly fine to JSP files it is just all servlet files which 404. Picture below. enter image description here

Also should mention this effects all Servlets, not just one or two ALL.

I believe this is a local problem as a colleague is running the next same setup on another machine, although the servlet is successfully found.

This is the log from startup although no apparent error is show either on startup or on the load of a servlets url.

I'm using servlet mapping within the servlets to define the URL IE @WebServlet("/Sterling")

Question: What could be causing this and how can I fix it? Thank you.

Sep 30, 2015 10:21:29 AM 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 (x86)\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files (x86)/Java/jre6/bin/client;C:/Program Files (x86)/Java/jre6/bin;C:/Program Files (x86)/Java/jre6/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Micro Focus\RUMBA\;C:\Program Files (x86)\Micro Focus\RUMBA\System;C:\Eclipse;
Sep 30, 2015 10:21:30 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:{redacted}' did not find a matching property.
Sep 30, 2015 10:21:30 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-80"]
Sep 30, 2015 10:21:30 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Sep 30, 2015 10:21:30 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1879 ms
Sep 30, 2015 10:21:30 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 30, 2015 10:21:30 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.34
Sep 30, 2015 10:21:37 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-80"]
Sep 30, 2015 10:21:37 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Sep 30, 2015 10:21:37 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 6704 ms

Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>*****DataManagementTool</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

Deployment Assembly Setup

enter image description here

1
Please post your web.xml. - James Jithin
Case-sensitive, would have expected urlPatterns={"/sterling"} - Joop Eggen
That case is working fine on the live environment as well as my colleagues environment. - Jack
@BalusC Yeah they all say that, I was just attempting to keep it private but that's gone now. To clarify where it says redacted it says what you called it. - Jack
/ArgosDataManagementTool/Sterling - Jack

1 Answers

-1
votes

This is a not found error. Your log shows no error so it is quite simple, your deploy does not reach desired servlets.

There is no enough info to determine the cause, but due to you can reach JSP files, I would check if you have configured correctly servlets into WEB-INF/web.xml descriptor.

EDIT

As you have just edited your question, I can tell you what is your problem. You have not configured servlets ... Configure the servlets you want as following:

    <servlet>
            <servlet-name>Servlet Name</servlet-name>
            <servlet-class>path.to.ServletClass</servlet-class>
            <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
            <servlet-name>Servlet Name</servlet-name>
            <url-pattern>URL-PATTERN</url-pattern>
    </servlet-mapping>

EDIT 2

After your edition, I didn't see that you have used annotations, obviously if you have servlet annotated you don't need this configuration.

EDIT 3

Make sure your web.xml has the right schema version, other way it could make your app to ignore annotations.

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
     version="3.0">

I suppose your servlet class inherits from HttpServlet, right?