1

I'm working in web application. Server used is Apache Tomcat 6. I tried to access resource from mylocalhost http://localhost:8080/examples/README.txt after running the server. But I can't access the resources showing the error message file not found from the Eclipse. But if I press ctrl+left click on the link, the resource was opening in Eclipse work area. The same resources I can access without going through the server, i.e going to path C:\Program Files (x86)\apache-tomcat-6.0.35\bin and clicking Startup.bat. By this way I can open the file. May I know what is reason for not accessing that resources through Eclipse?

url = new URL("http://localhost:8080/examples/README.txt");
con = url.openConnection(); // open the url connection.
dis = new DataInputStream(con.getInputStream()); 
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
RED.Skull
  • 1,696
  • 3
  • 24
  • 49
  • Yeah... normally the link was working.... by running the server external.. if i try to run through eclipse .. its not working. i dont knw what is issue – RED.Skull Sep 17 '12 at 08:53
  • Are you trying to only access the resource or trying to append something to it? – benz Sep 17 '12 at 10:31
  • @ben trying to access resource from servlet... – RED.Skull Sep 17 '12 at 11:06
  • 1
    Are you trying to access the resource from browser? But the the above are you making it in some other context? May be outside context this resource is not available. Accessing from browser and accessing from a separate context of a web-app are entirely two different things. Please confirm. Seems your issue is related to security and permissions. **AFTER EDIT** Please see the link below for similar issue [Tomcat File Not Found Exception](http://stackoverflow.com/questions/11462080/http-status-404-description-the-requested-resource-is-not-available-apache-t) Have a look at this [Tomcat File Not – benz Sep 17 '12 at 10:10

1 Answers1

1

Here is what i am quoting from the blog mentioned previously

Tomcat actually consists of 2 aspects: a sharable codebase (CATALINA_HOME) and a per-instance part (CATALINA_BASE). This allows multiple copies of Tomcat to run on a single server using one codebase. Most of the time, CATALINA_HOME and CATALINA_BASE are the same value, since more often than not, only one copy of a given version of Tomcat is is use – at least on a developer’s machine.

When you create a Tomcat server using the Eclipse Servers facility, however, it clandestinely creates its own CATALINA_BASE, copying selected files – and only those files into a directory owned by the plugin.

I got burned. I was keeping a file of my own in CATALINA_HOME and using a relative reference to it in server.xml. The file didn’t copy and Tomcat didn’t start clean.

The simplest solution was to edit server.xml and replace the relative path to an absolute path, so that the copied configuration would be able to locate the original (and in this case, the only) copy of my file.

Apparently, however, the copying of the CATALINA_BASE data occurs only when you create a new Server definition. I had to delete the old Server definition from Eclipse and create a new one to get the changes to take.

I have believe from this post as eclipse server copying only selected files and there your file is not getting copied. Just have a look at this post and think if this makes sense to your problem. Ben

benz
  • 4,561
  • 7
  • 37
  • 68
  • yeah ur rite... After try this ..."he simplest solution was to edit server.xml and replace the relative path to an absolute path, so that the copied configuration would be able to locate the original (and in this case, the only) copy of my file." i can access the res – RED.Skull Sep 18 '12 at 04:57