Link to home
Start Free TrialLog in
Avatar of Mark
Mark

asked on

Linux Apache Tomcat doesn't run if WEB-INF is listable

I have a bizarre problem. I'm running apache-tomcat-8.0.23 and Apache 2.4.16 on Linux Slackware 14.1. I run tomcat as its own user (tomcat), not root. I have a webapps directory webapps/horeb, and all files in that folder are owned by horeb.horeb, example:
> ls -l
drwxrws--- 4 horeb  horeb  4096 Jun 14 18:51 WEB-INF
-rw-rw---- 1 mfoley horeb  1713 Jun  5 15:16 findMember.jsp
-rw-rw---- 1 mfoley horeb  8826 Jun 11 12:10 gallery.jsp

Open in new window

tomcat has permission in the horeb group (/etc/group):

tomcat:x:200:mfoley
horeb:x:1000:tomcat,mfoley,daemon

I'd like to utilize WEB-INF/web.xml, but if I set WEB-INF to group executable, as shown above, tomcat fails to run giving initially "One or more listeners failed to start" as the first SEVERE error in the attached catalina.out log. If I do `chmod g-x WEB-INF`, tomcat start up just fine. I'm clueless as to the problem and don't know where to look.

My not-very-helpfu theory is there is something misconfigured in my WEB-INF folder and, if not listable, tomcat skips looking there, but if listable, it fails to find something it needs. Here is my WEB-INF folder:
> ls -lR WEB-INF/
WEB-INF/:
total 28
drwxrws--- 2 horeb horeb  4096 Jun 14 18:50 classes
drwxrws--- 2 horeb horeb  4096 Jun 14 18:32 lib
-rw-rw---- 1 horeb horeb 14554 Nov  2  2014 web.xml

WEB-INF/classes:
total 0

WEB-INF/lib:
total 0

Open in new window

I have this same version of Tomcat, Apache and Linux running on other servers with no such problems. I've tried stripping WEB-INF down to the same as the running versions. Nothing I've tried for over a week works.
catalina.txt
Avatar of gheist
gheist
Flag of Belgium image

Clean WORK and TEMP subdirectories. Probably there are files from older or newer jdk or with bad permissions
Avatar of Mark
Mark

ASKER

In fact, I did that. I upgraded from tomcat 8.0.15 to 8.0.23, so those folders were originally clean. But I went ahead and did so again just now.

Still getting the "One or more listeners failed to start. Full details will be found in the appropriate container log file" message.

Where might this "appropriate container log file" be found? Pretty cryptic, that.

The manifestation currently is that tomcat is running (ps ax), but when I browse to the site I get nothing on the screen. There are no new messages in catalina.out -- probably makes sense if there are no listeners. No additional messages in Apache access_log or error_log. I have:

<Logger className="org.apache.catalina.logger.FileLogger" directory="logs/" prefix="horeb_access_log" suffix=".log" timestamp="true"/>

configured in $CATALINA_HOME/server.xml, but I find no such file in the $CATALINA_HOME hierarchy.

$CATALINA_HOME/work subdirectories are recreated, including with a subdirectory ROOT, not sure why, but no contents in any folders:
drwxrwsr-x 3 root tomcat 4096 Jun 15 12:49 ../work
drwxr-s--- 4 tomcat tomcat 4096 Jun 15 12:49 ../work/Catalina
drwxr-s--- 4 tomcat tomcat 4096 Jun 15 12:54 ../work/Catalina/www.horeb-wright3.org
drwxr-s--- 2 tomcat tomcat 4096 Jun 15 12:49 ../work/Catalina/www.horeb-wright3.org/ROOT
drwxr-s--- 2 tomcat tomcat 4096 Jun 15 12:49 ../work/Catalina/www.horeb-wright3.org/horeb-wright3
drwxr-s--- 3 tomcat tomcat 4096 Jun 15 12:54 ../work/Catalina/localhost
drwxr-s--- 2 tomcat tomcat 4096 Jun 15 12:49 ../work/Catalina/localhost/horeb-wright3

Open in new window

Nothing created under $CATALINA_HOME/temp.
Avatar of mrcoffee365
You keep asking questions about this installation of tomcat.  The questions reveal behavior I've never seen and we've been using it for more than 10 years.

When I hit weirdness on the installation on a developer's machine,  usually the fix is a complete start-over.  Take the full release from the working machine and make it work on your developer machine.  Then start changing what you want, such as  tomcat or java releases.
Avatar of Mark

ASKER

I've been working with Tomcat for more than 10 years as well and have deployed on half-a-dozen hosts and have also never come across this behavior.

In fact, i did what you are saying. I cleaned out the $CATALINA_HOME directory and got the Tomcat 8.0.23 tarball from the working host and installed it from scratch. I've checked the $CATALINA_HOME/conf files and they are identical except for what I would think are trivial difference. None of that helped.

There are some differences, of course. The <Host> section of server.xml has a different host configuration. The new server uses mysql rather than MS sqljdbc (but failure happens on startup, no querying ever done).

However, I can try that again, this time with the webapp folder empty except for a test .jsp and with the exact same contents of the WEB-INF folder.

I don't think I'm interested in wiping the whole system and reinstalling everything from scratch. Seems like the error log should give some tomcat guru a clue. The startup failure happens if my app WEB-INF folder is group executable and does not fail otherwise. 100% repeatable and tied to a single condition.

If this is unsolvable, it's not the end of the world. All I wanted WEB-INF for was to use env.lookup(), but that can be worked around with my own 30 lines of replacement code. Nevertheless, I really would like to know why the permissions on the WEB-INF directory cause tomcat to fail to start!
SOLUTION
Avatar of gheist
gheist
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
both files pass xml validation just fine.
surprised that none of you have run into the same problem after a clean installation

I think the reason why us (and indeed why you haven't found anything on the web) have not run into something like this is that I believe you have a fairly unique use case. And I think this stems from maybe a difference in understanding what the role/purpose of web.xml is. I think perhaps that the web.xml is in an "example" webapp could be a hint but I guess what wouldn't be clear is that the intention of the tomcat devs (I believe) is for this to be an example of file syntax only and NOT to be a working example that you can just take as is and add your details. The reason is that web.xml is really tied to the webapp that is installed into tomcat and not tied to the tomcat installation itself. ie. when I develop a web application that could be installed into any number of containers (tomcat being one), the web.xml is an integral part of my code, and it gets installed into the container when the code gets installed. Each web app within the tomcat container has a separate web.xml and most of the time the content of this will be vastly different between webapps.

Hopefully, this sheds some light on you thinking about all of this. Let me know if any of the above is not so clear.
Avatar of Mark

ASKER

mccarl:
I guess what wouldn't be clear is that the intention of the tomcat devs (I believe) is for this to be an example of file syntax only and NOT to be a working example that you can just take as is and add your details.
Clearly, I see now that it is intended as an example, but there are also many example entries in $CATALINA_HOME/server.xml|web.xml, many commented out, none of which prevent tomcat from firing up. Likewise with httpd/extras and numerous other utilities -- none have initial settings that prevent the utility from running. In the vast majority of my experience, config files with examples have the examples commented out and only settings needed are enabled. I suppose the tomcat examples app is not intended to be a starting template, but that wasn't very clear to me. And I suppose, it must be clearer to others or there'd be more chatter on the net about it.

Thanks for your feedback.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark

ASKER

rrz:
Your question title ... was misleading.
Yes, but only after figuring out the problem. When I posted, tomcat would start properly if the WEB-INF was g-x, but not when g+x. That's all I knew when I posted. It took quite a lot of experimentation to figure out the problem was the example web.xml file. For reasons stated in my previous post, that as-shipped file was not my initial suspect.
Tomcat didn't deploy your web app because it couldn't find the class files for the listeners that you had registered in your web app's web.xml file. That threw the ClassNotFoundExceptions.
Yes, I figured that out. Hence my previous post.
Actually, Tomcat will deploy a web app with no web.xml file. In fact, it will deploy one without a WEB-INF  folder.
Please elaborate a bit on this. As far as I know, tomcat deploys nothing. The tarball has a few initial webapp folders: ROOT, docs, examples, host-manager and manager. I "deploy" tomcat by untarring the tarball. I then create my own webapp directory and put my files jsp files, jars, etc. there.

What do you mean? Perhaps there is some procedure I'm unfamiliar with.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark

ASKER

OK, I think I'm good on this. Yes, tomcat itself started and a `ps ax` would show that, I agree. However, I didn't have any other webapps deployed, so my first-pass take of the problem was that tomcat wasn't starting. Only later, after the initial post and further debugging did I track it to the contents of the web.xml file. I get all this. Unfortunately, there's no way I know of to change a question title to reflect the actual, discovered problem.

Thanks all for your help.
You're welcome!
You're right about common practices for tomcat upgrades: we rarely change the web.xml file.  Frankly, we rarely change the server.xml file.  Listeners in tomcat are especially problematic.  It has been surprisingly difficult to get them to work correctly in the cases when I wanted to configure them with a new upgrade.
Avatar of Mark

ASKER

mrcoffee365:
Listeners in tomcat are especially problematic.
All the more reason the example should have listeners commented out!

Thanks for the feedback. Despite my grumblings in this question. I really do like java/jsp/tomcat. It's been my main bread and butter for may years now.
Avatar of Mark

ASKER

I figured out my problem.