Home > database >  Running TomEE API in Docker container successful, but reverse proxy returns a 404
Running TomEE API in Docker container successful, but reverse proxy returns a 404

Time:07-04

So what I am trying to do is to have multiple Tomcat (TomEE) instances running in Docker containers. Then to reverse proxy into one of these containers to return the correct data. It tells me that the TomEE instance has started, but on the browser it still returns a 404 error.

Using CATALINA_BASE:   /workspace/tomee
Using CATALINA_HOME:   /workspace/tomee
Using CATALINA_TMPDIR: /workspace/tomee/temp
Using JRE_HOME:        /opt/java/openjdk
Using CLASSPATH:       /workspace/tomee/bin/bootstrap.jar:/workspace/tomee/bin/tomcat-juli.jar
Using CATALINA_OPTS:
NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.tomee.catalina.ServerListener (file:/workspace/tomee/lib/tomee-catalina-8.0.12.jar) to field java.lang.reflect.Field.modifiers
WARNING: Please consider reporting this to the maintainers of org.apache.tomee.catalina.ServerListener
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
29-Jun-2022 22:48:40.387 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke Server version name:   Apache Tomcat (TomEE)/9.0.63 (8.0.12)
29-Jun-2022 22:48:40.387 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke Server built:          May 11 2022 07:52:11 UTC
29-Jun-2022 22:48:40.387 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke Server version number: 9.0.63.0
29-Jun-2022 22:48:40.387 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke OS Name:               Linux
29-Jun-2022 22:48:40.387 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke OS Version:            4.19.0-16-amd64
29-Jun-2022 22:48:40.388 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke Architecture:          amd64
29-Jun-2022 22:48:40.388 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke Java Home:             /opt/java/openjdk
29-Jun-2022 22:48:40.388 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke JVM Version:           11.0.15 10
29-Jun-2022 22:48:40.388 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke JVM Vendor:            Eclipse OpenJ9
29-Jun-2022 22:48:40.388 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke CATALINA_BASE:         /workspace/tomee
29-Jun-2022 22:48:40.388 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke CATALINA_HOME:         /workspace/tomee
29-Jun-2022 22:48:40.416 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke Command line argument: -Xjcl:jclse29
29-Jun-2022 22:48:40.416 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke Command line argument: -Dcom.ibm.oti.vm.bootstrap.library.path=/opt/java/openjdk/lib/default:/opt/java/openjdk/lib
29-Jun-2022 22:48:40.417 INFO [main] jdk.internal.reflect.NativeMethodAccessorImpl.invoke Command line argument: -Dsun.boot.library.path=/opt/java/openjdk/lib/default:/opt/java/openjdk/lib
29-Jun-2022 22:48:40.417 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Djava.library.path=/opt/java/openjdk/lib/default:/opt/java/openjdk/lib:/usr/lib64:/usr/lib
29-Jun-2022 22:48:40.417 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Djava.home=/opt/java/openjdk
29-Jun-2022 22:48:40.417 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Duser.dir=/workspace
29-Jun-2022 22:48:40.417 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -XX: IgnoreUnrecognizedVMOptions
29-Jun-2022 22:48:40.418 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -XX: PortableSharedCache
29-Jun-2022 22:48:40.418 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -XX: IdleTuningGcOnIdle
29-Jun-2022 22:48:40.418 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Xshareclasses:name=openj9_system_scc,cacheDir=/opt/java/.scc,readonly,nonFatal
29-Jun-2022 22:48:40.418 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
29-Jun-2022 22:48:40.418 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
29-Jun-2022 22:48:40.420 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
29-Jun-2022 22:48:40.420 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
29-Jun-2022 22:48:40.420 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
29-Jun-2022 22:48:40.421 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Djava.util.logging.config.file=/workspace/tomee/conf/logging.properties
29-Jun-2022 22:48:40.421 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
29-Jun-2022 22:48:40.421 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -javaagent:/workspace/tomee/lib/openejb-javaagent.jar
29-Jun-2022 22:48:40.421 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
29-Jun-2022 22:48:40.421 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
29-Jun-2022 22:48:40.421 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
29-Jun-2022 22:48:40.421 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Dignore.endorsed.dirs=
29-Jun-2022 22:48:40.421 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Djava.class.path=/workspace/tomee/bin/bootstrap.jar:/workspace/tomee/bin/tomcat-juli.jar
29-Jun-2022 22:48:40.421 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Dcatalina.base=/workspace/tomee
29-Jun-2022 22:48:40.422 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Dcatalina.home=/workspace/tomee
29-Jun-2022 22:48:40.422 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Djava.io.tmpdir=/workspace/tomee/temp
29-Jun-2022 22:48:40.422 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Dsun.java.command=org.apache.catalina.startup.Bootstrap start
29-Jun-2022 22:48:40.422 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Dsun.java.launcher=SUN_STANDARD
29-Jun-2022 22:48:40.422 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Command line argument: -Dsun.java.launcher.pid=1
29-Jun-2022 22:48:40.424 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [/opt/java/openjdk/lib/default:/opt/java/openjdk/lib:/usr/lib64:/usr/lib]
29-Jun-2022 22:48:40.891 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Initializing ProtocolHandler ["http-nio-8080"]
29-Jun-2022 22:48:41.183 INFO [main] org.apache.openejb.util.OptionsLog.info Using 'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator'
29-Jun-2022 22:48:41.261 INFO [main] org.apache.openejb.OpenEJB$Instance.<init> ********************************************************************************
29-Jun-2022 22:48:41.261 INFO [main] org.apache.openejb.OpenEJB$Instance.<init> OpenEJB http://tomee.apache.org/
29-Jun-2022 22:48:41.262 INFO [main] org.apache.openejb.OpenEJB$Instance.<init> Startup: Wed Jun 29 22:48:41 UTC 2022
29-Jun-2022 22:48:41.262 INFO [main] org.apache.openejb.OpenEJB$Instance.<init> Copyright 1999-2021 (C) Apache TomEE Project, All Rights Reserved.
29-Jun-2022 22:48:41.262 INFO [main] org.apache.openejb.OpenEJB$Instance.<init> Version: 8.0.12
29-Jun-2022 22:48:41.262 INFO [main] org.apache.openejb.OpenEJB$Instance.<init> Build date: 20220607
29-Jun-2022 22:48:41.262 INFO [main] org.apache.openejb.OpenEJB$Instance.<init> Build time: 09:58
29-Jun-2022 22:48:41.262 INFO [main] org.apache.openejb.OpenEJB$Instance.<init> ********************************************************************************
29-Jun-2022 22:48:41.262 INFO [main] org.apache.openejb.OpenEJB$Instance.<init> openejb.home = /workspace/tomee
29-Jun-2022 22:48:41.262 INFO [main] org.apache.openejb.OpenEJB$Instance.<init> openejb.base = /workspace/tomee
29-Jun-2022 22:48:41.263 INFO [main] org.apache.openejb.cdi.CdiBuilder.initializeOWB Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@ad02bcfc
29-Jun-2022 22:48:41.265 INFO [main] org.apache.openejb.cdi.CdiBuilder.initializeOWB Succeeded in installing singleton service
29-Jun-2022 22:48:41.325 INFO [main] org.apache.openejb.config.ConfigurationFactory.init TomEE configuration file is '/workspace/tomee/conf/tomee.xml'
29-Jun-2022 22:48:41.355 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureService Configuring Service(id=Tomcat Security Service, type=SecurityService, provider-id=Tomcat Security Service)
29-Jun-2022 22:48:41.356 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureService Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
29-Jun-2022 22:48:41.357 INFO [main] org.apache.openejb.util.OptionsLog.info Using 'openejb.deployments.classpath=false'29-Jun-2022 22:48:41.373 INFO [main] org.apache.openejb.assembler.classic.Assembler.createRecipe Creating TransactionManager(id=Default Transaction Manager)
29-Jun-2022 22:48:41.421 INFO [main] org.apache.openejb.assembler.classic.Assembler.createRecipe Creating SecurityService(id=Tomcat Security Service)
29-Jun-2022 22:48:41.479 INFO [main] org.apache.openejb.server.ServiceManager.initServer Creating ServerService(id=cxf)
29-Jun-2022 22:48:41.742 INFO [main] org.apache.openejb.server.ServiceManager.initServer Creating ServerService(id=cxf-rs)
29-Jun-2022 22:48:41.765 INFO [main] org.apache.openejb.server.SimpleServiceManager.start   ** Bound Services **
29-Jun-2022 22:48:41.766 INFO [main] org.apache.openejb.server.SimpleServiceManager.printRow   NAME                 IP              PORT
29-Jun-2022 22:48:41.766 INFO [main] org.apache.openejb.server.SimpleServiceManager.start -------
29-Jun-2022 22:48:41.765 INFO [main] org.apache.openejb.server.SimpleServiceManager.start   ** Bound Services **
29-Jun-2022 22:48:41.766 INFO [main] org.apache.openejb.server.SimpleServiceManager.printRow   NAME                 IP              PORT
29-Jun-2022 22:48:41.766 INFO [main] org.apache.openejb.server.SimpleServiceManager.start -------
29-Jun-2022 22:48:41.766 INFO [main] org.apache.openejb.server.SimpleServiceManager.start Ready!
29-Jun-2022 22:48:41.766 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Server initialization in [1598] milliseconds
29-Jun-2022 22:48:41.789 INFO [main] org.apache.tomee.catalina.OpenEJBNamingContextListener.bindResource Importing a Tomcat Resource with id 'UserDatabase' of type 'org.apache.catalina.UserDatabase'.
29-Jun-2022 22:48:41.790 INFO [main] org.apache.openejb.assembler.classic.Assembler.createRecipe Creating Resource(id=UserDatabase)
29-Jun-2022 22:48:41.813 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Starting service [Catalina]
29-Jun-2022 22:48:41.814 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Starting Servlet engine: [Apache Tomcat (TomEE)/9.0.63 (8.0.12)]
29-Jun-2022 22:48:42.251 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Deploying web application archive [/workspace/tomee/webapps/example.war]
29-Jun-2022 22:48:42.256 INFO [main] org.apache.tomee.catalina.TomcatWebAppBuilder.init ------------------------- localhost -> /example
29-Jun-2022 22:48:42.321 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureApplication Configuring enterprise application: /workspace/tomee/webapps/example
29-Jun-2022 22:48:42.374 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureService Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
29-Jun-2022 22:48:42.375 INFO [main] org.apache.openejb.config.AutoConfig.createContainer Auto-creating a container for bean example.Comp-1180264842: Container(type=MANAGED, id=Default Managed Container)
29-Jun-2022 22:48:42.375 INFO [main] org.apache.openejb.assembler.classic.Assembler.createRecipe Creating Container(id=Default Managed Container)
29-Jun-2022 22:48:42.380 INFO [main] org.apache.openejb.core.managed.SimplePassivater.init Using directory /workspace/tomee/temp for stateful session passivation
29-Jun-2022 22:48:42.409 INFO [main] org.apache.openejb.config.AppInfoBuilder.build Enterprise application "/workspace/tomee/webapps/example" loaded.
29-Jun-2022 22:48:42.413 INFO [main] org.apache.openejb.assembler.classic.Assembler.createApplication Assembling app: /workspace/tomee/webapps/example
29-Jun-2022 22:48:42.546 WARNING [main] org.apache.batchee.container.services.ServicesManager.init You didn't specify org.apache.batchee.jmx.application and JMX is already registered, skipping
29-Jun-2022 22:48:42.549 INFO [main] org.apache.openejb.assembler.classic.Assembler.createApplication Deployed Application(path=/workspace/tomee/webapps/example)
29-Jun-2022 22:48:42.694 INFO [main] org.apache.myfaces.ee.MyFacesContainerInitializer.onStartup Using org.apache.myfaces.ee.MyFacesContainerInitializer
29-Jun-2022 22:48:42.754 INFO [main] 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.
29-Jun-2022 22:48:42.818 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Deployment of web application archive [/workspace/tomee/webapps/example.war] has finished in [567] ms
29-Jun-2022 22:48:42.819 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Deploying web application directory [/workspace/tomee/webapps/ROOT]
29-Jun-2022 22:48:42.819 INFO [main] org.apache.tomee.catalina.TomcatWebAppBuilder.init ------------------------- localhost -> /
29-Jun-2022 22:48:42.857 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureApplication Configuring enterprise application: /workspace/tomee/webapps/ROOT
29-Jun-2022 22:48:42.860 INFO [main] org.apache.openejb.config.AppInfoBuilder.build Enterprise application "/workspace/tomee/webapps/ROOT" loaded.
29-Jun-2022 22:48:42.861 INFO [main] org.apache.openejb.assembler.classic.Assembler.createApplication Assembling app: /workspace/tomee/webapps/ROOT
29-Jun-2022 22:48:42.866 WARNING [main] org.apache.batchee.container.services.ServicesManager.init You didn't specify org.apache.batchee.jmx.application and JMX is already registered, skipping
29-Jun-2022 22:48:42.867 INFO [main] org.apache.openejb.assembler.classic.Assembler.createApplication Deployed Application(path=/workspace/tomee/webapps/ROOT)
29-Jun-2022 22:48:42.895 INFO [main] org.apache.myfaces.ee.MyFacesContainerInitializer.onStartup Using org.apache.myfaces.ee.MyFacesContainerInitializer
29-Jun-2022 22:48:42.925 INFO [main] 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.
29-Jun-2022 22:48:42.935 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Deployment of web application directory [/workspace/tomee/webapps/ROOT] has finished in [116] ms
29-Jun-2022 22:48:42.935 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Deploying web application directory [/workspace/tomee/webapps/manager]
29-Jun-2022 22:48:42.937 INFO [main] org.apache.tomee.catalina.TomcatWebAppBuilder.init ------------------------- localhost -> /manager
29-Jun-2022 22:48:42.961 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureApplication Configuring enterprise application: /workspace/tomee/webapps/manager
29-Jun-2022 22:48:42.971 INFO [main] org.apache.openejb.config.AppInfoBuilder.build Enterprise application "/workspace/tomee/webapps/manager" loaded.
29-Jun-2022 22:48:42.971 INFO [main] org.apache.openejb.assembler.classic.Assembler.createApplication Assembling app: /workspace/tomee/webapps/manager
29-Jun-2022 22:48:42.977 INFO [main] org.apache.tomee.catalina.TomcatWebAppBuilder.deployWebApps using context file /workspace/tomee/webapps/manager/META-INF/context.xml
29-Jun-2022 22:48:42.977 WARNING [main] org.apache.batchee.container.services.ServicesManager.init You didn't specify org.apache.batchee.jmx.application and JMX is already registered, skipping
29-Jun-2022 22:48:42.977 INFO [main] org.apache.openejb.assembler.classic.Assembler.createApplication Deployed Application(path=/workspace/tomee/webapps/manager)
29-Jun-2022 22:48:43.029 INFO [main] org.apache.myfaces.ee.MyFacesContainerInitializer.onStartup Using org.apache.myfaces.ee.MyFacesContainerInitializer
29-Jun-2022 22:48:43.044 INFO [main] 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.
29-Jun-2022 22:48:43.062 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Deployment of web application directory [/workspace/tomee/webapps/manager] has finished in [126] ms
29-Jun-2022 22:48:43.062 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Deploying web application directory [/workspace/tomee/webapps/host-manager]
29-Jun-2022 22:48:43.063 INFO [main] org.apache.tomee.catalina.TomcatWebAppBuilder.init ------------------------- localhost -> /host-manager
29-Jun-2022 22:48:43.078 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureApplication Configuring enterprise application: /workspace/tomee/webapps/host-manager
29-Jun-2022 22:48:43.084 INFO [main] org.apache.openejb.config.AppInfoBuilder.build Enterprise application "/workspace/tomee/webapps/host-manager" loaded.
29-Jun-2022 22:48:43.084 INFO [main] org.apache.openejb.assembler.classic.Assembler.createApplication Assembling app: /workspace/tomee/webapps/host-manager
29-Jun-2022 22:48:43.090 INFO [main] org.apache.tomee.catalina.TomcatWebAppBuilder.deployWebApps using context file /workspace/tomee/webapps/host-manager/META-INF/context.xml
29-Jun-2022 22:48:43.091 WARNING [main] org.apache.batchee.container.services.ServicesManager.init You didn't specify org.apache.batchee.jmx.application and JMX is already registered, skipping
29-Jun-2022 22:48:43.091 INFO [main] org.apache.openejb.assembler.classic.Assembler.createApplication Deployed Application(path=/workspace/tomee/webapps/host-manager)
29-Jun-2022 22:48:43.133 INFO [main] org.apache.myfaces.ee.MyFacesContainerInitializer.onStartup Using org.apache.myfaces.ee.MyFacesContainerInitializer
29-Jun-2022 22:48:43.147 INFO [main] 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.
29-Jun-2022 22:48:43.178 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Deployment of web application directory [/workspace/tomee/webapps/host-manager] has finished in [116] ms
29-Jun-2022 22:48:43.179 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Deploying web application directory [/workspace/tomee/webapps/docs]
29-Jun-2022 22:48:43.179 INFO [main] org.apache.tomee.catalina.TomcatWebAppBuilder.init ------------------------- localhost -> /docs
29-Jun-2022 22:48:43.190 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureApplication Configuring enterprise application: /workspace/tomee/webapps/docs
29-Jun-2022 22:48:43.194 INFO [main] org.apache.openejb.config.AppInfoBuilder.build Enterprise application "/workspace/tomee/webapps/docs" loaded.
29-Jun-2022 22:48:43.194 INFO [main] org.apache.openejb.assembler.classic.Assembler.createApplication Assembling app: /workspace/tomee/webapps/docs
29-Jun-2022 22:48:43.213 WARNING [main] org.apache.batchee.container.services.ServicesManager.init You didn't specify org.apache.batchee.jmx.application and JMX is already registered, skipping
29-Jun-2022 22:48:43.214 INFO [main] org.apache.openejb.assembler.classic.Assembler.createApplication Deployed Application(path=/workspace/tomee/webapps/docs)
29-Jun-2022 22:48:43.249 INFO [main] org.apache.myfaces.ee.MyFacesContainerInitializer.onStartup Using org.apache.myfaces.ee.MyFacesContainerInitializer
29-Jun-2022 22:48:43.265 INFO [main] 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.
29-Jun-2022 22:48:43.278 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Deployment of web application directory [/workspace/tomee/webapps/docs] has finished in [99] ms
29-Jun-2022 22:48:43.281 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Starting ProtocolHandler ["http-nio-8080"]
29-Jun-2022 22:48:43.292 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Server startup in [1525] milliseconds

As shown above it says that the server startup was a success, but as shown below enter image description here

The browser returns me a 404 error instead.

I have tried several options

However none of these solutions have worked so far for me. I personally do not use docker-compose.

Dockerfile

FROM maven:3.8.3-jdk-11-slim AS build
RUN mkdir -p /workspace
WORKDIR /workspace
COPY pom.xml /workspace
COPY src /workspace/src
RUN mvn -B -f pom.xml clean package -DskipTests

FROM ibm-semeru-runtimes:open-11-jre-focal
ENV PATH /workspace/tomee/bin:$PATH
RUN mkdir -p /workspace/tomee

WORKDIR /workspace/tomee

RUN apt-get update \
  && apt-get install -y curl gpg \
  && rm -rf /var/lib/apt/lists/*

RUN set -xe; \
  for key in \
  # Matt Hogstrom <[email protected]>
  9056B710F1E332780DE7AF34CBAEBE39A46C4CA1 \
  # Jeremy Whitlock <[email protected]>
  F067B8140F5DD80E1D3B5D92318242FE9A0B1183 \
  # Richard Kenneth McGuire (CODE SIGNING KEY) <[email protected]>
  223D3A74B068ECA354DC385CE126833F9CF64915 \
  # Jonathan Gallimore <[email protected]>
  DBCCD103B8B24F86FFAAB025C8BB472CD297D428 \
  # Jarek Gawor (CODE SIGNING KEY) <[email protected]>
  7A2744A8A9AAF063C23EB7868EBE7DBE8D050EEF \
  # Jarek Gawor <[email protected]>
  B8B301E6105DF628076BD92C5483E55897ABD9B9 \
  # Andy Gumbrecht (TomEE Code Signing) <[email protected]>
  FAA603D58B1BA4EDF65896D0ED340E0E6D545F97 \
  # Romain Manni-Bucau <[email protected]>
  A57DAF81C1B69921F4BA8723A8DE0A4DB863A7C1 \
  # Mark Struberg (Apache) <[email protected]>
  82D8419BA697F0E7FB85916EE91287822FDB81B1 \
  # David Blevins <[email protected]>
  B7574789F5018690043E6DD9C212662E12F3E1DD \
  # Xu Hai Hong (Ivan Xu @ Geronimo) <[email protected]>
  C23A3F6F595EBD0F960270CC997C8F1A5BE6E4C1 \
  # Jean-Louis Monteiro (CODE SIGNING KEY) <[email protected]>
  678F2D98F1FD9643811639FB622B8F2D043F71D8 \
  # Romain Manni-Bucau <[email protected]>
  BDD0BBEB753192957EFC5F896A62FC8EF17D8FEF \
  # Romain Manni-Bucau <[email protected]>
  D11DF12CC2CA4894BDE638B967C1227A2678363C \
  # Roberto Cortez (Apache Signing Key) <[email protected]>
  C92604B0DEC5C62CFF5801E73D4683C24EDC64D1 \
  # David Blevins <[email protected]>
  626C542EDA7C113814B77AF09C04914D63645D20 \
  # Jean-Louis Monteiro (CODE SIGNING KEY) <[email protected]>
  3948829384B269D333CC5B98358807C52B4B0E23 \
  # Richard Zowalla (Code Signing Key) <[email protected]>
  B83D15E72253ED1104EB4FBBDAB472F0E5B8A431 \
  ; do \
    gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "$key" || \
    gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
  done

ENV TOMEE_VER 8.0.12
ENV TOMEE_BUILD plus

RUN set -x \
  && curl -fSL https://dist.apache.org/repos/dist/release/tomee/tomee-${TOMEE_VER}/apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz.asc -o tomee.tar.gz.asc \
  && curl -fSL https://dist.apache.org/repos/dist/release/tomee/tomee-${TOMEE_VER}/apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz.sha512 -o tomee.tar.gz.sha512 \
  && curl -fSL https://dist.apache.org/repos/dist/release/tomee/tomee-${TOMEE_VER}/apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz -o apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && gpg --batch --verify tomee.tar.gz.asc apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && echo `cat tomee.tar.gz.sha512` | sha512sum -c - \
  && tar -zxf apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && mv apache-tomee-${TOMEE_BUILD}-${TOMEE_VER}/* /workspace/tomee \
  && rm apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && rm -Rf apache-tomee-${TOMEE_BUILD}-${TOMEE_VER} \
  && rm bin/*.bat \
  && rm bin/*.exe \
  && rm bin/*.tar.gz* \
  && rm tomee.tar.gz.asc \
  && rm tomee.tar.gz*

EXPOSE 8080
WORKDIR /workspace
COPY --from=build /workspace/target/*.war /workspace/tomee/webapps/example.war
CMD ["catalina.sh", "run"]

nginx.conf

upstream docker-backend {
    server example-backend:8080;
}

server {
    location /example {
        proxy_pass http://docker-backend;
    }
}

I cannot seem to find the solution to this problem and am inexperienced with running a TomEE API inside a Docker container. Has anyone had this problem before and how did you solve it?

EDIT: whenever I send a curl request to the docker container

curl -X GET 0.0.0.0:8080/example/home

I get the following

<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr  /><p><b>Type</b> Status Report</p><p><b>Message</b> The requested resource [&#47;example&#47;home] is not available</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr  /><h3>Apache Tomcat (TomEE)/9.0.63 (8.0.12)</h3></body></html>

EDIT: Servlet example of home

@WebServlet
@Path("/home")
public class HomeResource {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response getServers(@Context HttpServletRequest req) {
        return example response with cors headers
    }
}

CodePudding user response:

I prepared a very simple war file, with an index.html and a web.xml file like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
id="WebApp_ID" version="2.5">
 
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
 
</web-app>

and packaged it as a war file with name example.war.

Then, I used the Dockerfile you provided in your answer with minimal modifications, basically I changed the COPY line at the end of the file:

FROM ibm-semeru-runtimes:open-11-jre-focal
ENV PATH /workspace/tomee/bin:$PATH
RUN mkdir -p /workspace/tomee

WORKDIR /workspace/tomee

RUN apt-get update \
  && apt-get install -y curl gpg \
  && rm -rf /var/lib/apt/lists/*

RUN set -xe; \
  for key in \
  # Matt Hogstrom <[email protected]>
  9056B710F1E332780DE7AF34CBAEBE39A46C4CA1 \
  # Jeremy Whitlock <[email protected]>
  F067B8140F5DD80E1D3B5D92318242FE9A0B1183 \
  # Richard Kenneth McGuire (CODE SIGNING KEY) <[email protected]>
  223D3A74B068ECA354DC385CE126833F9CF64915 \
  # Jonathan Gallimore <[email protected]>
  DBCCD103B8B24F86FFAAB025C8BB472CD297D428 \
  # Jarek Gawor (CODE SIGNING KEY) <[email protected]>
  7A2744A8A9AAF063C23EB7868EBE7DBE8D050EEF \
  # Jarek Gawor <[email protected]>
  B8B301E6105DF628076BD92C5483E55897ABD9B9 \
  # Andy Gumbrecht (TomEE Code Signing) <[email protected]>
  FAA603D58B1BA4EDF65896D0ED340E0E6D545F97 \
  # Romain Manni-Bucau <[email protected]>
  A57DAF81C1B69921F4BA8723A8DE0A4DB863A7C1 \
  # Mark Struberg (Apache) <[email protected]>
  82D8419BA697F0E7FB85916EE91287822FDB81B1 \
  # David Blevins <[email protected]>
  B7574789F5018690043E6DD9C212662E12F3E1DD \
  # Xu Hai Hong (Ivan Xu @ Geronimo) <[email protected]>
  C23A3F6F595EBD0F960270CC997C8F1A5BE6E4C1 \
  # Jean-Louis Monteiro (CODE SIGNING KEY) <[email protected]>
  678F2D98F1FD9643811639FB622B8F2D043F71D8 \
  # Romain Manni-Bucau <[email protected]>
  BDD0BBEB753192957EFC5F896A62FC8EF17D8FEF \
  # Romain Manni-Bucau <[email protected]>
  D11DF12CC2CA4894BDE638B967C1227A2678363C \
  # Roberto Cortez (Apache Signing Key) <[email protected]>
  C92604B0DEC5C62CFF5801E73D4683C24EDC64D1 \
  # David Blevins <[email protected]>
  626C542EDA7C113814B77AF09C04914D63645D20 \
  # Jean-Louis Monteiro (CODE SIGNING KEY) <[email protected]>
  3948829384B269D333CC5B98358807C52B4B0E23 \
  # Richard Zowalla (Code Signing Key) <[email protected]>
  B83D15E72253ED1104EB4FBBDAB472F0E5B8A431 \
  ; do \
    gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "$key" || \
    gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
  done

ENV TOMEE_VER 8.0.12
ENV TOMEE_BUILD plus

RUN set -x \
  && curl -fSL https://dist.apache.org/repos/dist/release/tomee/tomee-${TOMEE_VER}/apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz.asc -o tomee.tar.gz.asc \
  && curl -fSL https://dist.apache.org/repos/dist/release/tomee/tomee-${TOMEE_VER}/apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz.sha512 -o tomee.tar.gz.sha512 \
  && curl -fSL https://dist.apache.org/repos/dist/release/tomee/tomee-${TOMEE_VER}/apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz -o apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && gpg --batch --verify tomee.tar.gz.asc apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && echo `cat tomee.tar.gz.sha512` | sha512sum -c - \
  && tar -zxf apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && mv apache-tomee-${TOMEE_BUILD}-${TOMEE_VER}/* /workspace/tomee \
  && rm apache-tomee-${TOMEE_VER}-${TOMEE_BUILD}.tar.gz \
  && rm -Rf apache-tomee-${TOMEE_BUILD}-${TOMEE_VER} \
  && rm bin/*.bat \
  && rm bin/*.exe \
  && rm bin/*.tar.gz* \
  && rm tomee.tar.gz.asc \
  && rm tomee.tar.gz*

EXPOSE 8080
WORKDIR /workspace
COPY example.war /workspace/tomee/webapps/example.war
CMD ["catalina.sh", "run"]

With this Dockerfile, I created a docker image and run a container with it:

docker run --rm -p 8080:8080 local/tomee

and everything seems to work properly.

As we review in our conversation, the problem then seems to be related to the application you are trying to deploy.

The problem seems to be related to the connectivity with the database, the application is unable to start properly because it cannot connect to it.

Initially, in this specific use case, the reason was that you were trying to mount a volume in the TomEE container with the database configuration properties in a path that will not actually be available, trying to make it visible to your classpath.

To solve the issue, you can either use environment variables when running your container:

docker run -e DATABASE_PASSWORD=<your password> ...

and read it later with Java:

String password = System.getenv("DATABASE_PASSWORD");

or trying mounting a volume with your properties file, assume example/database.properties:

docker run -v ${PWD}/example:/a/local/path/accesible/by/your/app

and creating your configuration properties from that file:

try (InputStream input = new FileInputStream("/a/local/path/accesible/by/your/app/database.properties")) {

  Properties prop = new Properties();
  prop.load(input);

  // get the property value
  String password = prop.getProperty("db.password");
  //...

} catch (IOException ex) {
  ex.printStackTrace();
}

The second problem, more general, has to do with the ability to connect from a docker container to a database installed in the host that is running the container.

In your setup you run separately nginx and tomee containers, in a network called example.

One option you could try is using the host network when running your containers. You will need to adapt your nginx upstream in consequence, but your database should be accesible as localhost.

Another possibility could be to keep the containers in the mentioned example network and configure the connection url in your app to point to the IP address of the host in the docker network. There are several ways to do that. You are using linux so a simple one could be executing ifconfig and annotating the address corresponding to the docker network, docker0. Typically it will be 172.17.0.1.

You are using Mysql and, by default, it will only listen in the 127.0.0.1 address, so you probably you will need to make the database listen to multiple network interfaces. For that purpose you can use the bind-address configuration property, setting it to 0.0.0.0, which will make the database listening into every existing network interface:

bind-address = 0.0.0.0

Please, consider review the oficial MySQL documentation and this related question or this post to obtain more information regarding this configuration.

  • Related