1

I have a war file called "app-0.0.1-SNAPSHOT.war". I copied it to my /webapps folder and it explodes perfectly. However, if I rename it to "app.war" it does not explode. If I change the name to anything but "app.war" it explodes perfectly.

Why won't Tomcat explode my war ONLY when it is named "app.war"?

Below is the console output when I try to run in scenario 1.

Jul 14, 2016 9:19:12 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:app' did not find a matching property.
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/8.0.35
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          May 11 2016 21:57:08 UTC
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         8.0.35.0
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Mac OS X
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            10.11.5
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          x86_64
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             /Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_92-b14
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         /Users/alanguo/apache-tomcat-8.0.35
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         /Users/alanguo/apache-tomcat-8.0.35
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/Users/alanguo/apache-tomcat-8.0.35
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/Users/alanguo/apache-tomcat-8.0.35
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=/Users/alanguo/apache-tomcat-8.0.35/wtpwebapps
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/Users/alanguo/apache-tomcat-8.0.35/endorsed
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Jul 14, 2016 9:19:12 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/alanguo/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Jul 14, 2016 9:19:12 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Jul 14, 2016 9:19:12 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jul 14, 2016 9:19:12 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Jul 14, 2016 9:19:12 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jul 14, 2016 9:19:12 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 600 ms
Jul 14, 2016 9:19:12 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 14, 2016 9:19:12 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.35
Jul 14, 2016 9:19:13 AM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jul 14, 2016 9:19:13 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/alanguo/apache-tomcat-8.0.35/webapps/docs
Jul 14, 2016 9:19:13 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /Users/alanguo/apache-tomcat-8.0.35/webapps/docs has finished in 14 ms
Jul 14, 2016 9:19:13 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/alanguo/apache-tomcat-8.0.35/webapps/examples
Jul 14, 2016 9:19:14 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 14, 2016 9:19:14 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 14, 2016 9:19:14 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /Users/alanguo/apache-tomcat-8.0.35/webapps/examples has finished in 490 ms
Jul 14, 2016 9:19:14 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/alanguo/apache-tomcat-8.0.35/webapps/host-manager
Jul 14, 2016 9:19:14 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /Users/alanguo/apache-tomcat-8.0.35/webapps/host-manager has finished in 16 ms
Jul 14, 2016 9:19:14 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/alanguo/apache-tomcat-8.0.35/webapps/manager
Jul 14, 2016 9:19:14 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /Users/alanguo/apache-tomcat-8.0.35/webapps/manager has finished in 14 ms
Jul 14, 2016 9:19:14 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/alanguo/apache-tomcat-8.0.35/webapps/ROOT
Jul 14, 2016 9:19:14 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /Users/alanguo/apache-tomcat-8.0.35/webapps/ROOT has finished in 9 ms
Jul 14, 2016 9:19:14 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Jul 14, 2016 9:19:14 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Jul 14, 2016 9:19:14 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1687 ms
Alan Guo
  • 322
  • 1
  • 2
  • 11
  • What's on the console output for Tomcat, for that web application? – ManoDestra Jul 14 '16 at 00:45
  • Which plug-ins are you using to add the ability to launch Tomcat? – nitind Jul 14 '16 at 03:55
  • You probably have a file called `app.xml` in `$CATALINA_BASE/conf/[service]/host]/` that tells Tomcat to either not expand the WAR file or specifies that the web application is located elsewhere and already expanded. – Christopher Schultz Jul 14 '16 at 13:12
  • @ManoDestra I added the console output in my edit. – Alan Guo Jul 14 '16 at 16:21
  • @nitind I'm not sure what you mean by plug-ins. I don't think I've downloaded any plugins to run it. I just downloaded Tomcat and ran it through Eclipse. I'm using spring boot mvc for my web app as well. – Alan Guo Jul 14 '16 at 16:22
  • @ChristopherSchultz I don't have that file. – Alan Guo Jul 14 '16 at 16:22
  • I'm pretty sure it has to do with the naming. As soon as I change my war file named to app-hi.war, it explodes. I'm trying to figure out why only the name "app.war" won't explode. – Alan Guo Jul 14 '16 at 16:27
  • Firstly, ensure that you don't have an app directory already there. Remove that, if you do. Secondly, there's a line in your console output that looks slightly suspicious to me: `WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:app' did not find a matching property.`. Worth looking into that. You should be able to drop your war in there and, provided one with the same name has not already been expanded, then Tomcat will expand your new war. I just tried taking a war and renaming it to app.war and it worked fine for me. – ManoDestra Jul 14 '16 at 16:29
  • There should be no problem with dropping an app.war file into your webapps directory and have it deployed when you start Tomcat. Unless the deployment via Eclipse has done something to ruin your Tomcat installation. The warning does seem to suggest this to be the case. I never deploy via Eclipse (except to a test server), so I've never encountered this issue. – ManoDestra Jul 14 '16 at 16:36
  • @ManoDestra According to this previous question: http://stackoverflow.com/questions/3566146/setting-property-source-to-org-eclipse-jst-jee-serverjsftut-did-not-find-a there is no issue with that warning. It is just a product of Eclipse. – Alan Guo Jul 14 '16 at 16:38
  • @ManoDestra Also, I've checked that there is no expanded file in there already. The war is not expanding ONLY when the file name is "app.war". – Alan Guo Jul 14 '16 at 16:40
  • No idea why that's happening then, as it doesn't happen for me. Try reinstalling Tomcat from scratch and try it again. Or install it alongside your existing installation in a separate folder without doing anything with Eclipse and try it again using app.war, in order to test it. And if it works, then you can do a diff check on the two Tomcat folders, to see what configuration file is different. – ManoDestra Jul 14 '16 at 16:51
  • It works now. It was in this line .... I had to change the docBase directory to /Users/alanguo/apache-tomcat-8.0.35/webapps/app.war – Alan Guo Jul 14 '16 at 16:57
  • However, I don't understand why that would fix it. – Alan Guo Jul 14 '16 at 16:57
  • Was that in server.xml? That's an odd context. I don't have anything that specific in mine. You could probably just lose that entire context and restart. – ManoDestra Jul 14 '16 at 18:31
  • 1
    @ManoDestra It seems like there is a name conflict with that context. It works after I remove the context. However, every time I start Tomcat using Eclipse, that context is placed in the context.xml again. So, the problem is definitely stemming from Eclipse – Alan Guo Jul 14 '16 at 18:40
  • Yep. Thought so. Eclipse is reserving that application name for itself i.e. 'app'. It's so generic and it's a good choice TBH, as no one would tend to be so stupid as to call their application, 'app' deliberately, except as a test. – ManoDestra Jul 14 '16 at 18:52
  • 1
    Yep, `` in `conf/server.xml` will do it, just like a separate file in `conf/[service]/[host]/[app].xml` would have, except that putting it in `server.xml` means that you need to bounce the whole server to change the configuration. Eclipse shouldn't be doing it that way for a number of reasons. – Christopher Schultz Jul 14 '16 at 18:57

0 Answers0