2014-03-07 8 views
13

würde Ich mag JSP Symlink Verzeichnisse unter Tomcat 8.
Es funktionierte auch in Tomcat 7 auf diese Weise:symbolische Links tomcat 8 Verzeichnisressourcen

<Context allowLinking="true"> 


aber scheint die Tomcat 8 fiel diese Funktion, und Es begann die Ressourcen

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

Mein Beispiel Nutzung:

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

Eine schlechte Konfiguration:

ROOT/META-INF /context.xml:

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

Es ist für mich fiel th Ausnahme ist:

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 [[email protected]] 
      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) 



ich die "internalPath" hier zu sehen:
http://tomcat.apache.org/tomcat-8.0-doc/config/resources.html

Antwort

1

Es scheint, dass Sie eine separate "webAppMount" Eigenschaft benötigen.

<?xml version="1.0" encoding="UTF-8"?> 
<Context path="/"> 
    <Resources> 
     <PreResources 
      className="org.apache.catalina.webresources.DirResourceSet" 
      base="/FilePath/.../Resources" 
      webAppMount="/resources" 
      internalPath="/"/> 
    </Resources> 
</Context> 

Das funktionierte für mich. Es ist in meiner Web-App META-INF/context.xml

+1

Und dann können Sie erhalten zu '/ FilePath /.../ Resources/home.jsp' über' getContext(). GetResource ("/ resources/home.jsp"). GetPath (); ' – acdhirr

21

Tomcat aktivieren symbolische Links für den Zugriff auf die folgenden Schritte aus:

$CATALINA_HOME/conf/context.xml 

Tomcat 7:

<Context allowLinking="true"> 
... 

Tomcat 8:

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

NICHT UNTER WINDOWS (oder einem anderen Dateisystem, bei dem die Groß-/Kleinschreibung nicht berücksichtigt wird), , da es die Überprüfung der Groß- und Kleinschreibung deaktiviert, so dass neben anderen Sicherheitsproblemen der JSP-Quellcode offengelegt werden kann.

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

+0

Wenn ich Ihre Tomcat 8 Lösung versuche, funktioniert meine Datenquelle nicht mehr. – Dave

+0

@Dave einen automatisch schließenden Knoten versuchen '' anstelle von ''. Ich habe gerade meine Antwort aktualisiert, wie ich es jetzt mache. Das heißt, ich verwende keine Tomcat-Datenquellen, von denen ich weiß, dass sie Ihnen wahrscheinlich nicht helfen können. – GlenPeterson

+0

Großartig! Dies erlaubte mir, einen Symlink für 'WEB-INF/lib' zu verwenden, wie ich es in Tomcat 7 gewohnt war. Ich habe kein Problem mit meinen Datenquellen.Ich habe '' als ** Geschwister ** der vorhandenen '', nicht innerhalb oder in der Umgebung platziert. – Tobia