Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my Tomcat server throwing intermittent 404's when compiling JSP's?

I need help figuring out why a couple of my web applications are intermittently throwing 404 errors when trying to bring up a JSP. One of them has the JSP accessed directly and the other has a servlet that is forwarding to a JSP. The pages work most of the time, but occasionally will throw a 404. If the user refreshes their browser 1-3 times, the page starts working again without any changes required.

Here is a sample of the error as seen in the web browser (Chrome): type: Status report message: /app_root/my_page.jsp description: The requested resource is not available

The problem seems to be related to recompiling the JSP pages. The .war file and expanded directory haven't changed. There are always three errors in the logs that correspond to each 404 error: WARNING: Failed to delete generated class file [D:\Apache Software Foundation\Tomcat 7.0\work\Catalina\localhost\app_root\org\apache\jsp\my_005fpage_jsp.class] May 19, 2015 6:32:24 AM org.apache.jasper.compiler.Compiler removeGeneratedFiles WARNING: Failed to delete generated Java file [D:\Apache Software Foundation\Tomcat 7.0\work\Catalina\localhost\app_root\org\apache\jsp\my_005fpage_jsp.java] May 19, 2015 6:32:24 AM org.apache.jasper.compiler.Compiler generateJava WARNING: Failed to delete generated Java file [D:\Apache Software Foundation\Tomcat 7.0\work\Catalina\localhost\app_root\org\apache\jsp\my_005fpage_jsp.java]

I'm running Java 1.7 on Tomcat 7.0.53. Tomcat is running on a Windows 2008 R2 server.

Here is what I've tried so far, based on the information I've found from google. However, the 404's continue.

  1. Disabled Windows indexing on the entire Tomcat directory
  2. Turned off development mode in my production environment
  3. Increased modificationTestInterval in my QA environment from the default (4 seconds) to 3600 (1 hour) [Note: it is currently set to 0 to try to help me reproduce the issue]
  4. Changed the owner on the Tomcat work directory to be the same id as the id that the service is running as.

I am in the process of getting anti-virus turned off on the work directory to see if that helps.

While this issue is occurring on my prod and QA servers, it doesn't occur for me on my local Tomcat instance. In fact, I have yet to see the problem from my workstation even when running the QA and Prod applications. The issue has only been seen by other people.

like image 557
Spiritis Avatar asked May 28 '15 13:05

Spiritis


People also ask

How do I fix error 404 in Tomcat?

This error indicates that the server could not find the desired resource. This resource can be any file such as JSP, HTML, or image resource. Usually, the resource is present, but it is referenced incorrectly. In most cases, you can fix this by correcting the URL.

What is Apache Tomcat error report?

The Error report valve is an error handler which handles the error status codes and redirects users accordingly on error page with the information of error status code or exceptions and server info. The Error report valve is used with tomcat server to write custom error report handling functionality.

How do you fix the origin server did not find a current representation for the target resource or is not willing to disclose that one exists?

To Solve The origin server did not find a current representation for the target resource or is not willing to disclose that one exists Error From eclipse, you right click the project. Run As. Run on Server. And then it worked for me.


3 Answers

The Tomcat container caches .java and .class files generated by the JSP parser, which are used by the web application. Sometimes these get corrupted or cannot be found. This may occur after a patch or upgrade that contains modifications to JSPs.

Solution is to just simply delete the work directory and restart the tomcat

like image 152
Ruks Avatar answered Oct 05 '22 21:10

Ruks


Check the authority of this file or folder. Generally this problem is caused by lack of access to folders.

like image 39
Xiaokun Avatar answered Oct 05 '22 19:10

Xiaokun


I had the same problem after deploying a .war on our live server. These are the steps that I followed to solve the problem:

1) Shut down the tomcat server

2) Go to <your tomcat directory> -> work -> Catalina -> localhost -> <your project> -> org -> apache -> jsp ->

3) Manually delete both .class and .java

4) Delete the .war file and the deployed folder from the website that is having the issue on the webapps folder.

5) Export a new .war, and put it into the webapps folder.

6) Start up the tomcat service again.

Once the server is finished deploying, it will auto re-generate the deleted files in the "work" directory and the website should be available again without the intermittent 404 error.

I hope it works for you too.

like image 45
MFJ Avatar answered Oct 05 '22 19:10

MFJ