符号链接 tomcat 8 目录资源 [英] symlinking tomcat 8 directory resources

查看:117
本文介绍了符号链接 tomcat 8 目录资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Tomcat 8 下对 JSP 目录进行符号链接.
它以这种方式在 Tomcat 7 中也能正常工作:

 <上下文 allowLinking="true">


但是Tomcat 8好像去掉了这个功能,开始使用资源

( http://tomcat.apache.org/migration-8.html#Web_application_resources).

我的示例用法:

<块引用>

ROOT/jsp目录-->链接-->/var/tmp/realplaceofjspfiles/

错误的配置:

ROOT/META-INF/context.xml:

<资源 allowLinking="true"><PreResources className="org.apache.catalina.webresources.DirResourceSet" base="/var/tmp/realplaceofjspfiles" internalPath="jspdirectory"/></资源>

它为我删除了这个异常:

 07-Mar-2014 04:09:12.113 WARNING [localhost-startStop-1] org.apache.tomcat.util.digester.SetPropertiesRule.begin [SetPropertiesRule]{Context/Resources/PreResources} 设置属性 'internalPath' to 'jspdirectory' 没有找到匹配的财产.2014 年 3 月 7 日 04:09:12.114 严重 [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild:开始:org.apache.catalina.LifecycleException:无法启动组件 [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)在 org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)在 org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)在 org.apache.catalina.core.StandardHost.addChild(StandardHost.java:697)在 org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1134)在 org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1780)在 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)在 java.util.concurrent.FutureTask.run(FutureTask.java:266)在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)在 java.lang.Thread.run(Thread.java:744)引起:org.apache.catalina.LifecycleException:无法启动组件[org.apache.catalina.webresources.StandardRoot@4756d5a0]在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)在 org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4841)在 org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4966)在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)……还有 10 个引起:java.lang.NullPointerException在 java.lang.String.startsWith(String.java:1392)在 java.lang.String.startsWith(String.java:1421)在 org.apache.catalina.webresources.DirResourceSet.list(DirResourceSet.java:115)在 org.apache.catalina.webresources.StandardRoot.list(StandardRoot.java:129)在 org.apache.catalina.webresources.StandardRoot.listResources(StandardRoot.java:313)在 org.apache.catalina.webresources.StandardRoot.processWebInfLib(StandardRoot.java:523)在 org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:643)在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)……还有 13 个2014 年 3 月 7 日 04:09:12.115 严重 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory 部署 Web 应用程序目录/PATH/apache-tomcat-8.0.3/webapps/ROOT 时出错java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: 无法启动组件 [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]在 org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)在 org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)在 org.apache.catalina.core.StandardHost.addChild(StandardHost.java:697)在 org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1134)在 org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1780)在 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)在 java.util.concurrent.FutureTask.run(FutureTask.java:266)在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)在 java.lang.Thread.run(Thread.java:744)



我在这里看到了internalPath":
http://tomcat.apache.org/tomcat-8.0-doc/config/resources.html

解决方案

要使 Tomcat 能够访问符号链接,请执行以下操作:

$CATALINA_HOME/conf/context.xml

Tomcat 7:

...

Tomcat 8:

<资源 allowLinking="true"/>...

<块引用>

请勿在 WINDOWS(或任何其他不区分大小写的文件系统)上执行此操作,因为它将禁用区分大小写检查,允许 JSP 源代码披露,以及其他安全问题.

http://tomcat.apache.org/tomcat-8.0-doc/config/resources.html

I would like to symlink JSP directories under Tomcat 8.
It worked as well in Tomcat 7 on this way:

    <Context allowLinking="true">


but seems the Tomcat 8 dropped this feature, and it started to use the Resources

( http://tomcat.apache.org/migration-8.html#Web_application_resources ).

My example usage:

ROOT/jspdirectory -->linksto--> /var/tmp/realplaceofjspfiles/

A bad configuration:

ROOT/META-INF/context.xml:

<Context>
   <Resources allowLinking="true">
         <PreResources className="org.apache.catalina.webresources.DirResourceSet"   base="/var/tmp/realplaceofjspfiles" internalPath="jspdirectory"/>
    </Resources>
</Context>

It dropped for me this exception:

    07-Mar-2014 04:09:12.113 WARNING [localhost-startStop-1] org.apache.tomcat.util.digester.SetPropertiesRule.begin [SetPropertiesRule]{Context/Resources/PreResources} Setting property 'internalPath' to 'jspdirectory' did not find a matching
     property.
    07-Mar-2014 04:09:12.114 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
     org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:697)
            at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1134)
            at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1780)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:744)
    Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@4756d5a0]
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
            at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4841)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4966)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
            ... 10 more
    Caused by: java.lang.NullPointerException
            at java.lang.String.startsWith(String.java:1392)
            at java.lang.String.startsWith(String.java:1421)
            at org.apache.catalina.webresources.DirResourceSet.list(DirResourceSet.java:115)
            at org.apache.catalina.webresources.StandardRoot.list(StandardRoot.java:129)
            at org.apache.catalina.webresources.StandardRoot.listResources(StandardRoot.java:313)
            at org.apache.catalina.webresources.StandardRoot.processWebInfLib(StandardRoot.java:523)
            at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:643)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
            ... 13 more

    07-Mar-2014 04:09:12.115 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Error deploying web application directory /PATH/apache-tomcat-8.0.3/webapps/ROOT
     java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:729)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:697)
            at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1134)
            at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1780)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
            at java.lang.Thread.run(Thread.java:744)



I seen the "internalPath" here:
http://tomcat.apache.org/tomcat-8.0-doc/config/resources.html

解决方案

To enable Tomcat to access symbolic links do the following:

$CATALINA_HOME/conf/context.xml

Tomcat 7:

<Context allowLinking="true">
...

Tomcat 8:

<Context>
    <Resources allowLinking="true" />
...

DO NOT DO THIS ON WINDOWS (or any other case-insensitive filesystem), as it will disable case sensitivity checks, allowing JSP source code disclosure, among other security problems.

http://tomcat.apache.org/tomcat-8.0-doc/config/resources.html

这篇关于符号链接 tomcat 8 目录资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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