Where is the "work" directory located for a Tomcat instance running in Eclipse?

58,613

Solution 1

You will find it in

projectworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0

This is the default place where Eclipse 3.4 publishes the project. However, this can be changed by changing the settings in your 'Server' view.

Solution 2

Go to "Servers" window -> double click on your tomcat instance -> clik "Open launch configuration" -> go to "Arguments" tab.

Look for variable definition like this:

-Dcatalina.base="/Users/dirtyaffairs/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0"

Solution 3

The easiest way is most likely to ask a compiled JSP page about the source of the byte code.

From http://www.exampledepot.com/egs/java.lang/ClassOrigin.html:

// Get the location of this class
Class cls = this.getClass();
ProtectionDomain pDomain = cls.getProtectionDomain();
CodeSource cSource = pDomain.getCodeSource();
URL loc = cSource.getLocation();  // file:/c:/almanac14/examples/

Hopefully this helps. What is it you want to do?

Solution 4

  1. On Windows, the easiest way to go to your Eclipse's Tomcat deployment location is to just right-click on the Tomcat instance in the Servers view and click "Browse Deployment Location..."

    You should see Eclipse neatly opening a Windows explorer taking you to the exact location. In my case it takes me to:

    C:\eclipse4.3.2-jee-kepler-SR2-win32\workspaces\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps

    From there, you can easily browse to the "work" directory as shown below.

    If you follow this, you never have to remember the location!

    Eclipse Servers View:

    enter image description here

    Windows Explorer Opens:

    enter image description here

    Windows Explorer (click on address bar to reveal full path):

    enter image description here

  2. On Amazon EC2 Linux (this has nothing to do with Eclipse however), the Tomcat work directory is at /var/cache/tomcat7/work

    [ec2-user@ip-172-31-xx-xx ~]$ uname -a
    Linux ip-172-31-xx-xx 4.1.10-17.31.amzn1.x86_64 #1 SMP Sat Oct 24 01:31:37 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
    
    [root@ip-172-31-xx-xx] /usr/share/tomcat7 $ ls -l
    total 4
    drwxr-xr-x 2 root root   4096 Jan  5 15:18 bin
    lrwxrwxrwx 1 root tomcat   12 Jan  5 15:18 conf -> /etc/tomcat7
    lrwxrwxrwx 1 root tomcat   23 Jan  5 15:18 lib -> /usr/share/java/tomcat7
    lrwxrwxrwx 1 root tomcat   16 Jan  5 15:18 logs -> /var/log/tomcat7
    lrwxrwxrwx 1 root tomcat   23 Jan  5 15:18 temp -> /var/cache/tomcat7/temp
    lrwxrwxrwx 1 root tomcat   24 Jan  5 15:18 webapps -> /var/lib/tomcat7/webapps
    lrwxrwxrwx 1 root tomcat   23 Jan  5 15:18 work -> /var/cache/tomcat7/work
    
    [root@ip-172-31-xx-xx] /var/cache/tomcat7/work/Catalina/localhost/init/org/apache/jsp $ ls -la
    total 180
    drwxr-xr-x 2 tomcat tomcat  4096 Jan  6 06:37 .
    drwxr-xr-x 3 tomcat tomcat  4096 Jan  6 06:37 ..
    -rw-r--r-- 1 tomcat tomcat 54172 Aug 17  2012 index_jsp.class
    -rw-r--r-- 1 tomcat tomcat  2106 Jan  6 06:37 index_jsp$FileComp.class
    -rw-r--r-- 1 tomcat tomcat  1034 Jan  6 06:37 index_jsp$FileInfo.class
    -rw-r--r-- 1 tomcat tomcat  6460 Jan  6 06:37 index_jsp$HttpMultiPartParser.class
    -rw-r--r-- 1 tomcat tomcat 89445 Aug 17  2012 index_jsp.java
    -rw-r--r-- 1 tomcat tomcat  2210 Jan  6 06:37 index_jsp$UplInfo.class
    -rw-r--r-- 1 tomcat tomcat  1208 Jan  6 06:37 index_jsp$UploadMonitor.class
    -rw-r--r-- 1 tomcat tomcat  1184 Jan  6 06:37 index_jsp$Writer2Stream.class
    

Solution 5

You can change it by setting scratchDir parameter in web.xml configuration of your server (in Servers project, not in your application web.xml!).

Share:
58,613
Robert Campbell
Author by

Robert Campbell

Updated on July 09, 2022

Comments

  • Robert Campbell
    Robert Campbell almost 2 years

    In Eclipse you can configure numerous servers to run inside the IDE, including Tomcat. Depending on your Tomcat configuration, at some point in the life cycle of a webapp your JSP files will get compiled into servlets. These new servlet .class files are stored in the %TOMCAT_HOME%/work directory along with the .java intermediate file created from the JSP. This .java file is very helpful when your JSPs throw exceptions and cite a line number corresponding to the .java and not the .jsp

    Update: On my environment (Windows), it is located here:

    C:/Documents and Settings/%USER%/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work

    Perhaps to answer more completely somebody could post the location for *nix environments.