11

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.

Spiritis
  • 111
  • 1
  • 4
  • Have you attempted deleting generated class file manually while logged in as a user with which tomcat is running? – Rajesh May 28 '15 at 14:08
  • I just tried doing this manually. It worked as long as I did it with administrative privileges - either opening cmd with admin privs or answering the pop-up when deleting through Windows Explorer. – Spiritis May 28 '15 at 14:29
  • Disabling virus scan did not help. Further testing revealed that this issue only occurs when the servlet is forwarding to the JSP. Accessing the JSP directly works fine. I just changed the work directory to make the tomcat service account have full control explicitly. That is allowing me to delete the files with that id without having to authorize admin access. – Spiritis Jun 05 '15 at 11:24

3 Answers3

6

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

Ruks
  • 61
  • 1
  • 1
4

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.

MikeT
  • 51,415
  • 16
  • 49
  • 68
MFJ
  • 51
  • 2
2

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

Xiaokun
  • 814
  • 2
  • 10
  • 26