On 21/12/2020 00:50, Marc Chamberlin wrote:
> Hello - I am encountering a problem, on OpenSuSE15.0 and on
> OpenSuSE15.2, which suddenly appeared, possibly via an update or
> possibly from me working on Tomcat and doing something that I can't find
> a way to resolve. I am now getting a rather obtuse set of error messages
> for all my webapps, which is coming from a series of stack walk-back
> traces (shown without the actual program trace messages) from the
> Tomcat/Catalina logfile -
> 
> 9-Dec-2020 13:47:22.732 SEVERE [main]
> org.apache.catalina.startup.HostConfig.beforeStart Unable to create
> directory for deployment: [/usr/share/tomcat/webapps]

That indicates that that directory does not exist (or Tomcat can't see
it) and that Tomcat could not create it. Given that, the subsequent
errors are expected.

> 19-Dec-2020 13:47:22.734 SEVERE [main]
> org.apache.catalina.core.ContainerBase.startInternal A child container
> failed during start
>         java.util.concurrent.ExecutionException:
> org.apache.catalina.LifecycleException: Failed to start component
> [org.apache.catalina.webresources.StandardRoot@704921a5]
>         Caused by: org.apache.catalina.LifecycleException: Failed to
> start component [org.apache.catalina.webresources.StandardRoot@704921a5]
>        Caused by: java.lang.IllegalArgumentException: The main resource
> set specified [/usr/share/tomcat/webapps] is not valid
> 
> The last error message - java.lang.IllegalArgumentException seems to the
> the pertinent one telling me the path /usr/share/tomcat/webapps is not
> valid.

That looks like an appBase rather than a docBase.

Stack traces are often extremely helpful in tracking down the cause of
an error. If you do trim them then:
- the last one (the root cause) is likely to be the most important (as
  you have correctly identified)
- keep at least the class, method and line number where the exception
  was thrown to save time figuring out where the error occurred
- provide the full stack trace ideally at the end of the email but
  pastebin or similar is also an option
> Doesn't tell me why it is invalid, sigh, when will programmers
> write decent user friendly error messages which can actually help?

That tone is far more likely to antagonise the very people who can help
rather than encourage them to be helpful. Remember that the people here
are all volunteers providing their time to help you for free.

Since the source code is freely available, you have the ability to look
at the source code where the exception was thrown to see if that
provides any additional hints as to what might have gone wrong.

> Anywise, on my system I am guessing that the problem is that this app
> path is actually a double soft link i.e.

Symlinks can be problematic. Tomcat checks that the absolute and
canonical file names are the same and that the canonical file name is
below the canonical docBase. That check can fail when symlinks are used
within a web application. The checks have a security significance on
case sensitive file systems. Linux is nearly always case sensitive so
you can use allowLinking on the Context to permit the use of symlinks.

> quasar:/usr/share/tomcat # ll -d /usr/share/tomcat/webapps
> lrwxrwxrwx 1 root tomcat 19 Jul 12  2019 /usr/share/tomcat/webapps ->
> /srv/tomcat/webapps
> 
> quasar:/usr/share/tomcat # ll -d /srv/tomcat/webapps
> lrwxrwxrwx 1 root tomcat 38 Nov 23 14:58 /srv/tomcat/webapps ->
> /websites/home/marc/domain.com
> 
> quasar:/usr/share/tomcat # ll -d /websites/home/marc/domain.com/
> drwxrwxr-x 39 marc users 4096 Aug 13 23:52 /websites/home/marc/domain.com/
> 
> I did try shortening this to a single soft link but that didn't change
> anything.  The only other possibility I can think of is that Tomcat may
> have troubles reaching a file system on a different mount point??? 
> /webapps/... is on a different disk drive and is a mount point.

That shouldn't matter.

> These two environment variables are defined in tomcat.conf -
> 
> CATALINA_HOME="/usr/share/tomcat"
> CATALINA_BASE="/usr/share/tomcat"
> 
> The host declaration for this application, in server.xml, is -
> 
>      <Host name="localhost"  appBase="webapps"
>             unpackWARs="true" autoDeploy="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" />
>           
>         <Context path="" docBase="">
>            <Resources allowLinking="true" />
>         </Context>
>       </Host>

You have allowLinking there so the symlinks shouldn't be an issue.

The docBase looks wrong. I'd expect that to be "ROOT", the name of a
directory or possibly a WAR file.

> The context.xml file is -
> 
> <Context>
>     <WatchedResource>WEB-INF/web.xml</WatchedResource>
>     <WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
>     <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
> 
>     <Resources allowLinking="true" />
> </Context>

That looks OK.

> Sure would appreciate any help offered and thanks in advance. I been
> spending lots of hours trying to noodle this problem out and just not
> getting anywhere! A puzzler is that I had Tomcat working on OpenSuSE
> 15.0 at one time and this error message surfaced when I was trying to
> port Tomcat to OpenSuSE 15.2. I may have done something bad that broke
> Tomcat on OpenSuSE 15.0 but can't remember what I might had done that
> might have broken Tomcat. A couple other tidbits of information that
> might prove helpful -
> 
> # tomcat version
> 
> Server version: Apache Tomcat/9.0.21
> Server built:   Jul 4 2019 12:00:00 UTC
> Server number:  9.0.21.0
> OS Name:        Linux
> OS Version:     4.12.14-lp150.12.82-default
> Architecture:   amd64
> JVM Version:    1.8.0_222-b10
> JVM Vendor:     IcedTea

It is a long short but historically I have seen strange issues with the
IcedTea JVM. I haven't used it for a long time so they may have been
resolved but one of the things I'd try would be switching to an OpenJDK JVM.

> java -version
> openjdk version "1.8.0_222"
> OpenJDK Runtime Environment (IcedTea 3.13.0) (build 1.8.0_222-b10
> suse-lp150.2.19.1-x86_64)
> OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

The primary issue is that Tomcat doesn't appear to be able to see
/usr/share/tomcat/webapps

I don't immediately see why that is the case as the permissions appear
to be sufficient but I recommend focussing on that. Once that issue is
resolved, the remaining issues should disappear.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to