JBoss error report: HTTP Status 404 - Servlet is not available

Nada Naoushi picture Nada Naoushi · Nov 24, 2011 · Viewed 48k times · Source

I'm trying to create a very basic web project called "web" using MyEclipse and JBoss 5 as an application server. I've created one package called "pages" and inside it one servlet called "UserInterface". The problem is when I deploy the project and run the server I always get the error report: HTTP Status 404 - Servlet is not available.

This is a part of my web.xml:

<servlet>
    <servlet-name>UserInterface</servlet-name>
    <servlet-class>pages.UserInterface</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>UserInterface</servlet-name>
    <url-pattern>/UserInterface</url-pattern>
  </servlet-mapping>

and I'm navigating in the browser to: http://localhost:8080/web/UserInterface

What am I doing wrong here?

Thanks

Answer

Shivan Dragon picture Shivan Dragon · Nov 24, 2011

404 means the URL you're trying to access does not point to an existing resource on your server. Check the address again, maybe the "web" (from http://localhost:8080/web/UserInterface) part is not correct because maybe the app is not deployed with that name. By default the app context name is derrived from the filename of the ".war" file such as if your file is "myApp.war", your app should be available at http://localhost:8080/myApp

Also, if you're actually deploying your war inside an .ear file that that ear file will contain an application.xml aplpication descriptor which can map your app file to a specific context, no-matter what the .war filename is, something like:

<module>
    <web>
      <web-uri>myApp.war</web-uri>
      <context-root>theApp</context-root>
    </web>
  </module>

Finally, if you're autodeploying from Eclipse with the JBoss Eclipse connector, sometimes the thing bugs out and doesn't in fact deploy your app properly (even though the app itself is fine). If that's the case, trying manually deploying the .war to an application server and check it that way.