简体   繁体   English

Eclipse 中运行的 Tomcat 实例的“work”目录在哪里?

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

In Eclipse you can configure numerous servers to run inside the IDE, including Tomcat.在 Eclipse 中,您可以配置许多服务器以在 IDE 内运行,包括 Tomcat。 Depending on your Tomcat configuration, at some point in the life cycle of a webapp your JSP files will get compiled into servlets.根据您的 Tomcat 配置,在 web 应用程序生命周期的某个时刻,您的 JSP 文件将被编译为 servlet。 These new servlet .class files are stored in the %TOMCAT_HOME%/work directory along with the .java intermediate file created from the JSP.这些新的 servlet .class文件与从 JSP 创建的.java中间文件一起存储在%TOMCAT_HOME%/work目录中。 This .java file is very helpful when your JSPs throw exceptions and cite a line number corresponding to the .java and not the .jsp当您的 JSP 抛出异常并引用对应于.java而不是.jsp的行号时,此.java文件非常有用

Update: On my environment (Windows), it is located here:更新:在我的环境 (Windows) 中,它位于:

C:/Documents and Settings/ %USER% /workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work 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.也许为了更完整地回答,有人可以发布 *nix 环境的位置。

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.这是 Eclipse 3.4 发布项目的默认位置。 However, this can be changed by changing the settings in your 'Server' view.但是,这可以通过更改“服务器”视图中的设置来更改。

Go to "Servers" window -> double click on your tomcat instance -> clik "Open launch configuration" -> go to "Arguments" tab.转至“服务器”窗口 -> 双击您的 tomcat 实例 -> 单击“打开启动配置”-> 转至“参数”选项卡。

Look for variable definition like this:寻找这样的变量定义:

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

The easiest way is most likely to ask a compiled JSP page about the source of the byte code.最简单的方法是向编译后的 JSP 页面询问字节码的来源。

From http://www.exampledepot.com/egs/java.lang/ClassOrigin.html :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?你想做什么?

  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... "Windows 上,转到 Eclipse 的 Tomcat 部署位置的最简单方法是在“服务器”视图中右键单击 Tomcat 实例,然后单击“浏览部署位置...

    You should see Eclipse neatly opening a Windows explorer taking you to the exact location.您应该会看到 Eclipse 整齐地打开一个 Windows 资源管理器,将您带到确切的位置。 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: Eclipse 服务器视图:

    在此处输入图片说明

    Windows Explorer Opens: Windows 资源管理器打开:

    在此处输入图片说明

    Windows Explorer (click on address bar to reveal full path): Windows 资源管理器(单击地址栏以显示完整路径):

    在此处输入图片说明

  2. On Amazon EC2 Linux (this has nothing to do with Eclipse however), the Tomcat work directory is at /var/cache/tomcat7/workAmazon EC2 Linux 上(但这与 Eclipse 无关),Tomcat工作目录位于/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

您可以通过在服务器的 web.xml 配置中设置 scratchDir 参数来更改它(在服务器项目中,而不是在您的应用程序 web.xml 中!)。

If you're using the Tomcat Maven Plugin in Eclipse, then your Tomcat related files would be in <project folder>/target/tomcat instead, including the tomcat work folder at <project folder>/target/tomcat/work , and you can descend from there to find your jsp .java files, etc.如果您在 Eclipse 中使用 Tomcat Maven 插件,那么您的 Tomcat 相关文件将位于<project folder>/target/tomcat ,包括位于<project folder>/target/tomcat/work的 tomcat 工作文件<project folder>/target/tomcat/work ,您可以从那里下降以找到您的 jsp .java 文件等。

(I know this may not apply to everyone, but since Tomcat Maven Plugin is a popular way to develop with tomcat and using maven to manage dependencies and help with the build process, I hope this info may be helpful for some people). (我知道这可能并不适用于所有人,但由于 Tomcat Maven 插件是一种使用 tomcat 进行开发并使用 maven 管理依赖项并帮助构建过程的流行方式,我希望这些信息可能对某些人有所帮助)。

我假设它相对于您的工作区是相同的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM