0

I have trouble with auto-unpacking WAR-files in Tomcat. My Host descriptor at 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>

My mp.xml at /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 after starting 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

In this log is tui.org host too. It has no relation to the question.

Structure of environment and project:

Tomcat home: /opt/tomcat/

Directory with WAR: /var/www/mp/target/web/

Tomcat version: 9.0.10

OS: Ubuntu 18.04

Trouble: when I stop Tomcat, repackage WAR, and start tomcat nothing happen and in /var/www/mp/target/web/ WAR-file stills only, does no new folder. What am I doing wrong? I have thought about permissions. Also I have read that I should not set Context descriptor when I want to auto unpack WARs (Why?).

There are permissions:

/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

Thank you in advance.

P.S. Sorry for my english.

1

According to the log, it is a permission problem, the java process cannot create the /var/www/mp/target/web/mp directory. Note that in order to be able to create that directory, the process needs to access every directory on the path, so it isn't enough to have write permission on the last entry in the path: you need at least execute permission on all directories leading there.

Try to go to the /var/www/mp/target/web/ directory one step at a time (so cd /var, cd web, etc.) using the wcobalt user. I suspect one of the directories to be inaccessible to you.

  • Thank you. Which should I set user to these directories. tomcat or wcobalt (me)? I add wcobalt group for tomcat user and war has extracted. But permissions of created mp folder is drwxr-x--- 4 tomcat tomcat and I can't access to it. – wcobalt Aug 16 '18 at 7:32
  • You should set permission for the user who runs the Tomcat process. It is usually the user who ran the catalina.sh command, but if you're unsure, you can check it with the ps auxw|grep tomcat command after the Tomcat process has started. – Lacek Aug 16 '18 at 8:24
  • I setted user which starts tomcat as wcobalt (me) and the same group then it's started work. – wcobalt Aug 16 '18 at 17:26

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.