I am running Tomcat 5.0 and I have problem with getting a resource from tomcats ‘webapps’ from Java. There is a html file that I check if it’s available after server start in
tomcat_folder/webapps/myProject/site.html
In Java I run this code when server is started:
URL url = new URL("http://localhost:8080/myProject/site.html");
URLConnection con = url.openConnection();
Object content = con.getContent();
getContent() throws FileNotFoundException.
But when I put “http://localhost:8080/myProject/site.html” into browser, the site is displayed without problems.
Also I tested that on 4 machines – on 2 everything is fine, on other 2 FileNotFoundException.
I thought it might be some folder security access problem or user rights, but in the end I have no clue. Any suggestions?
I found the solution to my problem.
The cause was a windows service using port 8080, which was also in use by Tomcat. Resource was available through browser, but not from Java code.
After stopping conflicting service everything works as it should now.