Tomcat context.xml wo ablegen im Projekt?

DefconDev

Bekanntes Mitglied
Hallo zusammen,

ich habe leider so selten mit Tomcat zu tun, dass es mir gerade etwas schwer fällt, herauszufinden wo ich die context.xml im Java Projekt abzulegen habe, damit die beim Starten des Tomcats meine Änderungen übernimmt.

Bitte keine Anleitungen, wie ich die Datei auf dem Server verändere, das ganze läuft in einem K8-Cluster. Und da würde bei jedem Deployment die Datei wieder überschrieben werden.

Die Rede ist von Tomcat 9

die Anwendung liegt auf dem Server in /usr/local/tomcat/webapps/meineApp ich denke das ist der Standard-Pfad.

Die context.xml im Projekt einfach in /META-INF/ ablegen?

Ich müsste Testweise nur folgende Zeile hinzufügen:
allowLinking="true"

Java:
<?xml version="1.0" encoding="UTF-8"?>
<Context >
</Context>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at
      http://www.apache.org/licenses/LICENSE-2.0
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context path="/usr/local/tomcat/webapps/meineApp" allowLinking="true">
    <!-- Default set of monitored resources. If one of these changes, the    -->
    <!-- web application will be reloaded.                                   -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->
</Context>

Als Alternative könnte ich die Contextfile irgendwo ablegen im Projekt und dann im Dockerfile definieren, dass diese die default-context.xml überschreiben soll. Aber die Lösung finde ich weniger elegant, weil ich wahrscheinlich dem Befehl zum Kopieren der Dateien Root-Rechte zuweisen muss.


Vielen Dank im Voraus.
 
Mal sehen, was Google meint:
https://doc.cuba-platform.com/manual-latest/context.xml.html hat gesagt.:
context.xml file is the application deployment descriptor for the Apache Tomcat server. In a deployed application, this file is located in the META-INF folder of the web application directory or the WAR file, for example, tomcat/webapps/app-core/META-INF/context.xml.
 
Mal sehen, was Google meint:
Ja, das habe ich natürlich auch gelesen 😛

Die Sache ist die, ich war mir nicht sicher ob damit gemeint ist, dass beim Starten des Tomcats die Datei komplett neu erzeugt wird und dort dann liegt und meine aus dem Projekt ignoriert wird, sofern ich diese zuvor im Projekt angelegt habe genau unter diesem Pfad. Oder ob meine Context Datei genommen wird.

Ich wollte sicher gehen, weil ich keine Lust hatte das ganze erst zu deployen auf unserem System um dann wieder festzustellen, meine Annahme war falsch.
 

Zurück
Oben