Назад | Перейти на главную страницу

Автоматическая распаковка WAR не работает

У меня проблемы с автоматической распаковкой WAR-файлов в Tomcat. Мой Host дескриптор в server.xml (defaultHost="mp.org"):

  <Host name="mp.org"  appBase="/var/www/mp/target/web/"
        unpackWARs="true" autoDeploy="true" deployOnStartup="true">

    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log" suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />
  </Host>

Мой mp.xml в /opt/tomcat/conf/Catalina/mp.org:

<Context>
    path=""
    docBase="/var/www/mp/target/web/"
    debug="1"
    reloadable="true"
    distributable="true"
    crossContext="false"
    swallowOutput="true"
</Context>

Catalina.out после запуска Tomcat:

15-Aug-2018 12:23:48.155 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/9.0.10
15-Aug-2018 12:23:48.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jun 20 2018 17:32:21 UTC
15-Aug-2018 12:23:48.158 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         9.0.10.0
15-Aug-2018 12:23:48.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
15-Aug-2018 12:23:48.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            4.15.0-29-generic
15-Aug-2018 12:23:48.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
15-Aug-2018 12:23:48.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/lib/jvm/java-8-oracle/jre
15-Aug-2018 12:23:48.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_181-b13
15-Aug-2018 12:23:48.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
15-Aug-2018 12:23:48.159 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /opt/tomcat
15-Aug-2018 12:23:48.160 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /opt/tomcat
15-Aug-2018 12:23:48.160 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties
15-Aug-2018 12:23:48.160 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
15-Aug-2018 12:23:48.160 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.awt.headless=true
15-Aug-2018 12:23:48.160 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.security.egd=file:/dev/./urandom
15-Aug-2018 12:23:48.160 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
15-Aug-2018 12:23:48.161 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
15-Aug-2018 12:23:48.161 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
15-Aug-2018 12:23:48.161 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms512M
15-Aug-2018 12:23:48.161 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx1024M
15-Aug-2018 12:23:48.161 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:+UseParallelGC
15-Aug-2018 12:23:48.161 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
15-Aug-2018 12:23:48.161 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/opt/tomcat
15-Aug-2018 12:23:48.162 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/opt/tomcat
15-Aug-2018 12:23:48.162 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/opt/tomcat/temp
15-Aug-2018 12:23:48.162 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
15-Aug-2018 12:23:48.464 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
15-Aug-2018 12:23:48.508 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
15-Aug-2018 12:23:48.555 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
15-Aug-2018 12:23:48.559 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
15-Aug-2018 12:23:48.560 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1133 ms
15-Aug-2018 12:23:48.620 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
15-Aug-2018 12:23:48.620 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.10
15-Aug-2018 12:23:49.116 SEVERE [main] org.apache.catalina.valves.AccessLogValve.getLogFile Failed to create directory [/var/www/tui.org/tomcat_logs] for access logs
15-Aug-2018 12:23:49.117 SEVERE [main] org.apache.catalina.valves.AccessLogValve.getLogFile Failed to create directory [/var/www/tui.org/tomcat_logs] for access logs
15-Aug-2018 12:23:49.118 SEVERE [main] org.apache.catalina.valves.AccessLogValve.open Failed to open access log file [/var/www/tui.org/tomcat_logs/localhost_access_log.2018-08-15.txt]
 java.io.FileNotFoundException: /var/www/tui.org/tomcat_logs/localhost_access_log.2018-08-15.txt (Нет такого файла или каталога)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at org.apache.catalina.valves.AccessLogValve.open(AccessLogValve.java:651)
    at org.apache.catalina.valves.AccessLogValve.startInternal(AccessLogValve.java:685)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:179)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:963)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)

15-Aug-2018 12:23:49.121 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/var/www/tui.org/servlet]
15-Aug-2018 12:23:49.153 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/var/www/tui.org/servlet] has finished in [31] ms
15-Aug-2018 12:23:49.156 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [/opt/tomcat/conf/Catalina/mp.org/mp.xml]
15-Aug-2018 12:23:49.167 SEVERE [main] org.apache.catalina.startup.ContextConfig.beforeStart Exception fixing docBase for context [/mp]
 java.io.IOException: Unable to create the directory [/var/www/mp/target/web/mp]
    at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:115)
    at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:632)
    at org.apache.catalina.startup.ContextConfig.beforeStart(ContextConfig.java:738)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:301)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:182)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:742)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:718)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:703)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1840)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:525)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:424)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1585)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:308)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:966)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)

15-Aug-2018 12:23:49.232 INFO [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of deployment descriptor [/opt/tomcat/conf/Catalina/mp.org/mp.xml] has finished in [76] ms
15-Aug-2018 12:23:49.237 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
15-Aug-2018 12:23:49.306 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
15-Aug-2018 12:23:49.318 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 757 ms

В этом журнале tui.org хозяин тоже. Это не имеет отношения к вопросу.

Структура среды и проекта:

Дом Tomcat: /opt/tomcat/

Каталог с WAR: /var/www/mp/target/web/

Версия Tomcat: 9.0.10

ОПЕРАЦИОННЫЕ СИСТЕМЫ: Ubuntu 18.04

Проблема: когда я останавливаю Tomcat, переупаковываю WAR и запускаю tomcat, ничего не происходит и в /var/www/mp/target/web/ Сохраняется только WAR-файл, новой папки нет. Что я делаю не так? Я подумал о разрешениях. Также я прочитал, что мне не следует устанавливать Context дескриптор, когда я хочу автоматически распаковывать WAR (зачем?).

Есть разрешения:

/opt/tomcat/conf/Catalina/mp.org/ drwxr-xr-x 2 wcobalt wcobalt

/opt/tomcat/conf/Catalina/mp.org/mp.xml -rw-r--r-- 1 wcobalt wcobalt

/var/www/mp/target/web/ drwxrwxr-x 2 wcobalt wcobalt

/var/www/mp/target/web/mp.war -rw-rw-r-- 1 wcobalt wcobalt

Заранее спасибо.

P.S. Извините за мой английский.

Согласно журналу, это проблема с разрешением, Java-процесс не может создать /var/www/mp/target/web/mp каталог. Обратите внимание, что для создания этого каталога процессу необходимо получить доступ к каждому каталогу на пути, поэтому недостаточно иметь разрешение на запись для последней записи в пути: вам нужно как минимум разрешение на выполнение для всех каталогов. ведущий туда.

Попробуй зайти в /var/www/mp/target/web/ каталог по одному шагу за раз (так cd /var, cd webи т. д.) с помощью wcobalt пользователь. Подозреваю, что один из каталогов для вас недоступен.