Search code examples
gwtgwt2

404 error in gwt project- servlet is correctly defined in web.xml but still getting 404 error


I am working to create a web app using GWT+Java backend. The host page is "App.html" The app also has a RPC, and the host page when initially loaded, makes an RPC call.

However this is the message I am getting from Javascript console in Google Chrome browser-

POST http://app.sparkcrawler.com/com.arvindikchari.auth.App/AuthenticationService 404(Not Found) 

Given below are the contents of my web.xml--

<?xml version................................>
    <servlet>
    <servlet-name>AuthenticationService</servlet-name>
    <servlet-class>com.arvindikchari.auth.server.AuthenticationServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>AuthenticationService</servlet-name>
    <url-pattern>/com.arvindikchari.auth.App/AuthenticationService</url-pattern>
</servlet-mapping>

What am I doing wrong here? How do I resolve this error?


Solution

  • The problem is with your servlet mapping.

    Basically, you have two things in web.xml (regarding servlets):

    • the <servlet> tag, which defines the alias for the servlet, and its fully-qualified name (In your case AuthenticationService and com.arvindikchari.auth.server.AuthenticationServiceImpl)

      the <servlet-mapping> which specifies a url-pattern for a given alias (taken from the <servlet> definitions).

    It should be like

    <servlet-mapping>
        <servlet-name>AuthenticationService</servlet-name>
        <url-pattern>/authenticationService</url-pattern>
    </servlet-mapping>