Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Eclipse/Tomcat7: application context root reloading returns 404
Eclipse/Tomcat7: application context root reloading returns 404 [message #1058129] Sun, 12 May 2013 07:51 Go to next message
Yang Zheng is currently offline Yang ZhengFriend
Messages: 1
Registered: May 2013
Junior Member
I have a servlet which is mapped to application context root using the "" string: So when I hit the url
localhost/myapp/
, I can see "This is ROOT!" in the browser. So far so good.

But if I modify something, say changing the String This is ROOT!! to ROOT!! and save the file in eclipse. Eclipse will take a couple of seconds to reload the context. Now if i hit the same url, a 404 page is displayed while all other pages still work fine. Only the root mapping is broken. So I redeploy (eclipse's "run on server") the app and the root mapping is back again. Any ideas on how can I fix this?

@WebServlet("")
public class Root extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.getWriter().println("This is ROOT!!");
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

}
Re: Eclipse/Tomcat7: application context root reloading returns 404 [message #1058561 is a reply to message #1058129] Tue, 14 May 2013 13:10 Go to previous message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 5/12/2013 7:27 PM, Yang Zheng wrote:
> I have a servlet which is mapped to application context root using the
> "" string: So when I hit the url localhost/myapp/, I can see "This is
> ROOT!" in the browser. So far so good.
>
> But if I modify something, say changing the String This is ROOT!! to
> ROOT!! and save the file in eclipse. Eclipse will take a couple of
> seconds to reload the context. Now if i hit the same url, a 404 page is
> displayed while all other pages still work fine. Only the root mapping
> is broken. So I redeploy (eclipse's "run on server") the app and the
> root mapping is back again. Any ideas on how can I fix this?
>
> @WebServlet("")
> public class Root extends HttpServlet {
> private static final long serialVersionUID = 1L;
>
> protected void doGet(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
> response.getWriter().println("This is ROOT!!");
> }
>
> protected void doPost(HttpServletRequest request,
> HttpServletResponse response) throws ServletException, IOException {
> // TODO Auto-generated method stub
> }
>
> }

Since this is Tomcat behavior, you may have better luck asking on the
tomcat-users mailing list[1], if you haven't already. I'm not sure what
exactly is different about reloading as opposed to restarting, but if
any mapping was going to have a problem with the difference, a mapping
for "" would like be the one. This behavior would seem to be a bug.
I'm not an expert on the Servlet spec, but I'm not sure what it
guarantees with respect to what "" matches as opposed to the default
servlet which is mapped to "/". I can see "" being a tricky mapping to
handle.

Cheers,
Larry

[1] http://tomcat.apache.org/lists.html#tomcat-users
Previous Topic:Exception when accessing JSP/JSF pages
Next Topic:Starting HTTP Preview Java exception
Goto Forum:
  


Current Time: Mon Sep 23 14:37:49 GMT 2024

Powered by FUDForum. Page generated in 0.03220 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top