如果scratchdir是只读的,Tomcat是否在内存中缓存已编译的JSP页面? [英] Does Tomcat cache compiled JSP pages in memory if scratchdir is read-only?

查看:144
本文介绍了如果scratchdir是只读的,Tomcat是否在内存中缓存已编译的JSP页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在只读文件系统上存在的Tomcat容器中安装了一个Webapp.结果,我在启动时看到以下消息(更改实际名称以保护罪恶感):

I've got a webapp installed in a Tomcat container that exists on a read-only file system. As a result, I'm seeing this message (actual names changed to protect the guilty) on startup:

严重:您指定的scratchDir:/readonlyfs/tomcat/work/Catalina/localhost/myApp无法使用.

SEVERE: The scratchDir you specified: /readonlyfs/tomcat/work/Catalina/localhost/myApp is unusable.

尽管显示了此消息,但该应用程序似乎正在运行,并且很难确定,但似乎并非针对每次访问都在编译JSP页面.因此,我的问题是,编译后的JSP页面会发生什么?它们是否缓存在内存中?它们是否无限期缓存?它们根本没有被缓存吗?

Despite this message, the app seems to run, and it's difficult to tell for certain, but it appears that JSP pages are not being compiled for every access. So, my question is, what happens to the compiled JSP pages? Are they cached in memory? Are they cached indefinitely? Are they cached at all?

我需要确切地知道,因为该应用程序几乎总是部署到一个只读文件系统中,如果这将导致性能问题,那么我将不得不更改scratchdir指向另一个文件系统.但是,这给我要避免的部署过程带来了额外的复杂性.因此,如果性能不受影响,即页面被缓存在内存中,那么我很乐意将事情搁置一旁.我意识到序列化的会话数据将在只读文件系统上丢失,但这与我无关,实际上是一个加分.只是我关心的已编译页面的处理.

I need to know definitively because the application will almost always be deployed to a read-only file system, and if this will cause performance problems then I'll have to change scratchdir to point to another filesystem. However, this brings additional complexity to the deployment process that I'd like to avoid. So, if performance doesn't suffer, i.e., pages are cached in memory, then I am happy to leave things alone. I realize that serialized session data will be lost on a read-only file system, but that does not concern me, and is actually a plus. It's only the handling of compiled pages that concerns me.

推荐答案

JSP似乎已经被编译(.class和.java文件是否存在于$ CATALINA_BASE/work下吗?).这就是为什么看起来一切正常的原因.

It looks like the JSPs have already been compiled (do the .class and .java files exist under $CATALINA_BASE/work ?). That is why it appears things are working.

如果使用一个空的只读工作目录(JSP引擎用于其scratchDir)启动Tomcat,则尝试访问JSP时将看到以下内容:

If you start Tomcat with an empty, read-only work directory (which the JSP engines uses for its scratchDir) you will see the following if you try to access a JSP:

HTTP状态500-java.lang.IllegalStateException:没有输出文件夹

HTTP Status 500 - java.lang.IllegalStateException: No output folder

您有两种选择:a)触摸每个JSP以确保它们都已在工作目录中进行了编译,然后将完整的工作目录包括在您的发行版中b)预编译JSP

You have a couple of options: a) touch every JSP to make sure they have all been compiled in the work directory and then included the complete work directory in your distribution b) pre-compile the JSPs

我会说b)是更好的选择.

I would say b) is the better option.

这篇关于如果scratchdir是只读的,Tomcat是否在内存中缓存已编译的JSP页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆