0
votes

I am running Tomcat from docker:

docker run -it --rm -p 8888:8080 -v /Users/laura/Desktop/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml:ro tomcat:8.0

I can access Tomcat manager just fine. I have copied my .war file to the webapps directory but Tomcat manager gives me a 404 when trying to access it...There are no errors during deploy.

I have also tried running it directly with the .war mounted:

docker run -it --rm -p 8888:8080 -v /Users/laura/Desktop/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml:ro  -v /Users/laura/Desktop/glossary.war:/usr/local/tomcat/webapps/glossary.war tomcat:8.0

With the following output:

    Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /docker-java-home/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
10-Nov-2017 23:49:05.890 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.0.47
10-Nov-2017 23:49:05.893 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Sep 29 2017 13:46:41 UTC
10-Nov-2017 23:49:05.895 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.0.47.0
10-Nov-2017 23:49:05.896 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
10-Nov-2017 23:49:05.897 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            4.9.41-moby
10-Nov-2017 23:49:05.898 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
10-Nov-2017 23:49:05.899 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/lib/jvm/java-7-openjdk-amd64/jre
10-Nov-2017 23:49:05.900 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.7.0_151-b01
10-Nov-2017 23:49:05.900 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
10-Nov-2017 23:49:05.901 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat
10-Nov-2017 23:49:05.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat
10-Nov-2017 23:49:05.904 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
10-Nov-2017 23:49:05.904 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
10-Nov-2017 23:49:05.905 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
10-Nov-2017 23:49:05.906 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
10-Nov-2017 23:49:05.906 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=/usr/local/tomcat/endorsed
10-Nov-2017 23:49:05.907 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
10-Nov-2017 23:49:05.908 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
10-Nov-2017 23:49:05.908 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
10-Nov-2017 23:49:05.909 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.14 using APR version 1.5.1.
10-Nov-2017 23:49:05.910 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
10-Nov-2017 23:49:05.914 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.1.0f  25 May 2017)
10-Nov-2017 23:49:06.058 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
10-Nov-2017 23:49:06.077 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
10-Nov-2017 23:49:06.079 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 779 ms
10-Nov-2017 23:49:06.163 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
10-Nov-2017 23:49:06.164 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.47
10-Nov-2017 23:49:06.232 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /usr/local/tomcat/webapps/glossary.war
10-Nov-2017 23:49:17.411 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars 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.
10-Nov-2017 23:49:17.533 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /usr/local/tomcat/webapps/glossary.war has finished in 11,301 ms
10-Nov-2017 23:49:17.536 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/examples
10-Nov-2017 23:49:18.079 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/examples has finished in 543 ms
10-Nov-2017 23:49:18.080 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/host-manager
10-Nov-2017 23:49:18.120 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/host-manager has finished in 39 ms
10-Nov-2017 23:49:18.120 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/manager
10-Nov-2017 23:49:18.157 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/manager has finished in 37 ms
10-Nov-2017 23:49:18.158 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/docs
10-Nov-2017 23:49:18.183 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/docs has finished in 26 ms
10-Nov-2017 23:49:18.183 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/ROOT
10-Nov-2017 23:49:18.206 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/ROOT has finished in 23 ms
10-Nov-2017 23:49:18.215 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
10-Nov-2017 23:49:18.300 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
10-Nov-2017 23:49:18.407 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 12327 ms

I then try to access it at: http://localhost:8888/glossary/ but it fails with 404.

Here is the contents of the webapp dir:

root@544c1d9f4a88:/usr/local/tomcat# ls -lh webapps/
total 147M
drwxr-xr-x  3 root root 4.0K Nov  4 21:32 ROOT
drwxr-xr-x 14 root root 4.0K Nov  4 21:32 docs
drwxr-xr-x  6 root root 4.0K Nov  4 21:32 examples
drwxr-xr-x  5 root root 4.0K Nov 10 23:05 glossary
-rwxr-xr-x  1 root root 147M Nov 10 23:05 glossary.war
drwxr-xr-x  5 root root 4.0K Nov  4 21:32 host-manager
drwxr-xr-x  5 root root 4.0K Nov  4 21:32 manager

and here is what I see on manager and the 404 error.

any help would be very much appreciated!

ps: I am also running Oracle from docker since my webapp uses it: docker run --name OracleXE --shm-size=1g -p 1521:1521 -p 8080:8080 -v /Users/laura/Desktop/data:/u01/app/oracle/oradata -e ORACLE_ALLOW_REMOTE=true oracle/database:11.2.0.2-xe

1
Maybe the problem comes from the glossary application itself?Ortomala Lokni
I guess you have a problem in glossary app. Does it have root mapping? I suggest you to download sample war from apache and try it out in your tomcat instance tomcat.apache.org/tomcat-8.0-doc/appdev/sampleSasha Shpota
Thanks for your help. I have Tomcat locally and am able to run my app just fine. It is when using it through docker that I am getting issues. I can run the example apps via docker without any error. The only thing I am changing when trying to run my app via docker, is the database connection string (since my app uses oracle from another container) which I am updating to my ip (instead of localhost). [forums.docker.com/t/…...user8840545

1 Answers

0
votes

Well since you have access to your tomcat instance and to the manager app, then you should be able to see what applications are deployed, if they are running and their context paths. So what does it say about glossary? Do you have app that is deployed and running with applicaiton context path /glossary? You can answer these question by accessing the Tomcat Manager App under

http://localhost:8080/manager/html (or your specific host and port)

Hope this helps!

Another thing you may try is rename glossary.war to ROOT.war. This will deploy your glossary app as the ROOT app and it will be accessible under localhost:8080 directly (or whatever port you are running tomcat at).