Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » [404] Resource Not Found Error(Tomcat7 inside of Eclipse Helios on top of Ubuntu 10.04)
[404] Resource Not Found Error [message #676618] Sun, 05 June 2011 18:01 Go to next message
No real name is currently offline No real nameFriend
Messages: 8
Registered: November 2010
Location: Boston, MA
Junior Member
Hello,

NOTE: I have another Dynamic Web Project runnable on the same Tomcat 7 server in the same instance of Eclipse Helios in the same workspace.

I'm running Tomcat7 inside of Eclipse Helios on top of Ubuntu Lucid Lynx. I have successfully started Tomcat7 inside of the IDE before invoking the following URL from the browser bar in FireFox,

http:--localhost:8080/HearingImpaired/InvokingTest.do

The name of my Dynamic Web Project is HearingImpaired. The name of the Servlet called for in the Deployment Descriptor is /InvokingTest.do

Although this should not make any difference, Eclipse Helios - Tomcat7 - Ubuntu are all running in an Oracle VirtualBox on top of Windows 7 64-bit Professional.

I have been able to create a standalone project outside of Eclipse Helios in
/var/lib/tomcat7/webapps/HearingImpaired, and I have been able to successfully launch my web application. After successfully launching my web app, I deleted /HearingImpaired from /var/lib/tomcat7/webapps/.

I don't believe that there are any errors in my web.xml file. I have attached the file for your examination. I used the web.xml file supplied with Tomcat7 as a starter file. All the files in my application build without any errors in Eclipse Helios.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

   http:--www.apache.org/licenses/LICENSE-2.0    

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<web-app xmlns:xsi="http:--www.w3.org/2001/XMLSchema-instance" xmlns="http:--java.sun.com/xml/ns/javaee" xmlns:web="http:--java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http:--java.sun.com/xml/ns/javaee http:--java.sun.com/xml/ns/javaee/web-app_3_0.xsd" metadata-complete="true" version="3.0">
  <servlet>
    <servlet-name>Tester</servlet-name>
    <servlet-class>com.example.ListenerTester</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Tester</servlet-name>
    <url-pattern>/InvokingTest.do</url-pattern>
  </servlet-mapping>
  <context-param>
    <param-name>breed</param-name>
    <param-value>Great Dane</param-value>
  </context-param>
  <listener>
    <listener-class>com.example.MyServletContextListener</listener-class>
  </listener>
</web-app>


package com.example;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class ListenerTester extends HttpServlet {
	
	public void doGet(HttpServletRequest request,
			          HttpServletResponse response) 
	throws IOException, ServletException {
		
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out.println("This is my second attempt<br>");
		
		out.println("<br>");
		
		Dog dog = (Dog)this.getServletContext().getAttribute("dog");
		
		out.println("The Dog's breed is" + dog.getBreed());
		
	}
}


package com.example;

public class Dog {
	
	private String breed;
	
	public Dog(String breed) {
		this.breed = breed;
	}
	
	public String getBreed() {
		return breed;
	}

}


package com.example;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * Application Lifecycle Listener implementation class MyServletContextListener
 *
 */
@WebListener
public class MyServletContextListener implements ServletContextListener {

    /**
     * Default constructor. 
     */
    public MyServletContextListener() {
        // TODO Auto-generated constructor stub
    }

    /**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent event) {
        ServletContext sc = event.getServletContext();
        String dogBreed = sc.getInitParameter("breed");
        Dog d = new Dog(dogBreed);
        sc.setAttribute("dog", d);
    }

    /**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent arg0) {
        // TODO Auto-generated method stub
    }
	
}


Any idea why I'm getting a Resource Not Found 404 error in my Browser?

Any help will be appreciated.

Thanks,
Harry

[Updated on: Sun, 05 June 2011 19:59]

Report message to a moderator

Re: [404] Resource Not Found Error [message #676654 is a reply to message #676618] Sun, 05 June 2011 22:57 Go to previous message
No real name is currently offline No real nameFriend
Messages: 8
Registered: November 2010
Location: Boston, MA
Junior Member

Posts: 192

[Post New]posted Today 06:53:59 PM
0
Quote Edit
[SOLVED]

http:--greatwebguy.com/programming/eclipse/make-eclipse-and-tomcat-play-nice-together/
Setup Eclipse and Tomcat to play nice together


This is nice to do, but not necessarily the solution to my problem.

CHANGE THE BUILD PATH IN ECLIPSE HELIOS

1. Right click on the Project and choose Properties

2. Choose Java Build Path in the Left Panel. Click the Source Tab in the Right Panel.

3. Change the Default Output Folder in the textbox at the bottom of the page: YourProjectName/WebContent/WEB-INF/classes

4. Click OK.

THIS IS WHAT SOLVED MY PROBLEM - Configure Tomcat 7

1. Open the Server View, if it's not displayed already, then Window -> Show View -> Other -> Server -> Servers

2. In Server View, right click on: Tomcat v7.0 at localhost [Stopped]

3. Choose Add and Remove ... from ListView

4. Choose the project that was created (i.e. HearingImpaired) from Available projects and ADD the project to Configured projects. Click OK.

5. Restart/Start Tomcat 7 container.

STEP 4 OF PART 2 DID THE TRICK !
Previous Topic:Eclipse and OpenOCD and STM32
Next Topic:create both CDT and JDT projects
Goto Forum:
  


Current Time: Thu Apr 18 20:16:48 GMT 2024

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

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

Back to the top