Solved

$CATALINA_TMPDIR No such file or directory error

Posted on 2007-03-28
15
678 Views
Last Modified: 2013-11-24
I have a problem that is occuring in a production environment but the problem does not occur in a development and test environment.  The problem in production happens when uploading a file.  The error is:

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Processing of multipart/form-data request failed. $CATALINA_TMPDIR/upload_00000546.tmp (No such file or directory)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)
      at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:309)
      at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:387)
      at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:673)
      at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:615)
      at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:786)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
      at java.lang.Thread.run(Thread.java:534)


root cause

javax.servlet.ServletException: Processing of multipart/form-data request failed. $CATALINA_TMPDIR/upload_00000546.tmp (No such file or directory)
      at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
      at org.apache.jsp.voicemail_jsp._jspService(voicemail_jsp.java:1888)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)
      at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:309)
      at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:387)
      at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:673)
      at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:615)
      at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:786)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
      at java.lang.Thread.run(Thread.java:534)



--------------------------------------------------------------------------------

Apache Tomcat/4.1.29-LE-jdk14

The JSP code used to upload the file is:

boolean bIsMultipart = FileUpload.isMultipartContent(request);
if (bIsMultipart) {
      DiskFileUpload upload = new DiskFileUpload();

      // Parse the request
      java.util.List /* FileItem */ items = upload.parseRequest(request);
      psCollection formFields = new psCollection();

      Iterator iter = items.iterator();

      while (iter.hasNext() && !bErrorFlag) {
            boolean bFileExists = false;
            FileItem item = (FileItem) iter.next();
            if (item.isFormField()) {
                  //first get the all the data entered.  Process the data after the while loop
                  formFields.add(new String(item.getString()), new String(item.getFieldName()));
            } else {
                  sName = item.getFieldName();
                  sFileName = item.getName().substring(item.getName().lastIndexOf("\\") + 1);
                  sContentType = item.getContentType();
                  bInMemory = item.isInMemory();
                  lSizeInBytes = item.getSize();
                  
                  // Process the file upload in memory
                  try {
                        data = item.get();
                  } catch (Exception e) {
                        bErrorFlag = true;
                        sDisplayMessage = "We were unable to access the uploaded file.";
                        logger.debug("unable to get the data from the file.");
                  }



The main difference between the development/test environment and the production environment is that the development/test environment have Apache and Tomcat on the same server while the production environment has one server running Apache and another server running Tomcat.
0
Comment
Question by:david_m_jacobson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 3
  • +1
15 Comments
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 500 total points
ID: 18813627
check if there is write access to CATALINA_TMPDIR folder
0
 

Author Comment

by:david_m_jacobson
ID: 18813679
I did that.  The permissions were set to 744.  I changed it to 777 and recreated the bug but I did not restart Tomcat because it's a production box.  Do you know if I need to restart Tomcat before the permission change will take effect?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18813686
Maybe - I would say try that on a test instance first and verify - then bring down the production
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:david_m_jacobson
ID: 18813726
I don't have the authority to restart the production environment.  I will ask someone to do this tomorrow.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18813730
Test it first for verification
0
 
LVL 27

Expert Comment

by:rrz
ID: 18817793
If you can use commons-fileupload-1.2 , then you can stream the files. Please try the following(create the folder "fileUploads" in your web app's root folder manually prior to testing).
<%@ page import="java.util.*,
                 java.io.*,
                 org.apache.commons.fileupload.*,
                 org.apache.commons.fileupload.servlet.*,
                 org.apache.commons.fileupload.disk.*,
                 org.apache.commons.fileupload.util.*"%>
<%
  boolean isMultipart = ServletFileUpload.isMultipartContent(request);
  if(isMultipart){
                  ServletFileUpload upload = new ServletFileUpload();
                  FileItemIterator iter = upload.getItemIterator(request);
                  FileItemStream item = null;
                  String name = "";
                  InputStream stream = null;
                  while (iter.hasNext()){
                                         item = iter.next();
                                         name = item.getFieldName();
                                         stream = item.openStream();
                    if(item.isFormField()){out.println("Form field " + name + " with value " 
                                               + Streams.asString(stream) + " detected.<br/>");}
                    else {
                          name = item.getName();
                          if(name != null && !"".equals(name)){
                             out.println("File field " + name + " with file name "
                                                        + item.getName() + " detected.<br/>");
                             String fileName = new File(item.getName()).getName();
                             File file = new File(application.getRealPath("/fileUploads/"
                                                       + fileName));
                             FileOutputStream fos = new FileOutputStream(file);
                             int c;
                             while( ( c=stream.read() ) != -1 ) fos.write( c );
                             out.print(fileName
                                + " was uploaded to the fileUploads folder.<br/>");
                          }
                       }
                  }
  }
0
 
LVL 27

Expert Comment

by:rrz
ID: 18821658
I thought of another idea. What about going into catalina.bat and changing  $CATALINA_TMPDIR  to something that will work for you.
0
 

Author Comment

by:david_m_jacobson
ID: 18823067
OK, I tested changing the permissions of the temp directory.  That did not work.  I still get the same error.

I think the error has something to do with the fact that the Apache server is separate from the Tomcat server.  Is it possible that the code is somehow trying to find $CATALINA_TMPDIR on the Apache server and cannot find it since Tomcat isn't loaded on the Apache server?

Also, I connected to the Tomcat server and confirmed that the variable CATALINA_TMPDIR exists but is it possible that the connection from the Apache server to the Tomcat server is using a different username and that username does not have CATALINA_TMPDIR defined?

We are using the mod_jk2 connector and I could not find where the connection is defined.

Also, note that the existing code works fine in our development and test environments but we have both environments set up on a single server.  A customer implmented Apache and Tomcat on separate servers and that is where it is bombing.
0
 
LVL 27

Expert Comment

by:rrz
ID: 18823327
Please try this page.
<%@ page import="java.io.*" %>
<%
  File testFile = new File(application.getRealPath("/testFile.txt"));
  FileWriter fw = new FileWriter(testFile);
  fw.write("This is a test to see if testFile was created..");
  fw.close();
  out.print("File creation test. Please look in your web app's root folder.");
%>
0
 
LVL 27

Expert Comment

by:rrz
ID: 18825811
If you are able to create a test file within your web app, then try streaming the files to the server(see my first post).       rrz
0
 

Author Comment

by:david_m_jacobson
ID: 18825890
I haven't tested out using streaming but I am reluctant to change the code since it works in the development environment and the test environment.  Can anyone explain why it doesn't work in this production environment?
0
 
LVL 27

Expert Comment

by:rrz
ID: 18826836
0
 

Author Comment

by:david_m_jacobson
ID: 19476321
I found the problem.  $CATALINA_TMPDIR was misspelled as $CATALINA_TEMPDIR (with an extra "E") and as a result the server couldn't find the directory.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 19477928
Points to Ajay-Singh, he gave the right spelling in his first comment
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question