Unable to launch springboot application without setting datasource - java

I'm trying to launch my SpringBoot application without configuring DataSource prior to compilation. If I do this, indicating the parameters, the application works normally, but I want to pass them through the JAVA_OPTS parameter when I run a docker container. Like that:
docker run --network public --link pg --name tm -e JAVA_OPTS="-Ddatasource.jdbcUrl=jdbc:postgresql://pg:5432/ggal1701 -Ddatasource.user=postgres -Ddatasource.password=postgres" -p 9000:8080 worker
I've tried many of the options I've seen on Stackoverflow, but none of them worked for me.
My build.gradle:
buildscript {
repositories {
mavenLocal()
jcenter()
maven { url 'http://repo.spring.io/plugins-release' }
maven { url 'http://repo.spring.io/milestone' }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath group: 'net.ltgt.gradle', name: 'gradle-apt-plugin', version: '0.6'
classpath group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: spring_boot_version
classpath group: 'org.springframework.build.gradle', name: 'propdeps-plugin', version: '0.0.7'
}
}
plugins {
id "org.sonarqube" version "2.6.2"
}
apply plugin: "org.sonarqube"
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
apply plugin: 'maven'
apply plugin: 'spring-boot'
apply plugin: 'war'
apply plugin: 'propdeps'
defaultTasks 'bootRun'
bootRepackage {
mainClass = 'es.asd.GGAL1701.Application'
}
war {
rootSpec.exclude("**/tomcat-*.jar")
exclude("**/client")
exclude("**/tmp")
exclude("**/upload")
from "dist"
}
springBoot {
mainClass = 'es.asd.GGAL1701.Application'
executable = true
}
bootRun {
addResources = false
}
if (project.hasProperty('prod')) {
apply from: 'gradle/profile_prod.gradle'
} else {
apply from: 'gradle/profile_dev.gradle'
}
apply from: 'gradle/process_resources.gradle'
group = 'es.asd.GGAL1701'
version = '0.0.1-SNAPSHOT'
description = ''
configurations {
providedRuntime
}
repositories {
maven {
url "http://asd-nexus.com/repository/maven-central/"
credentials {
username "asd"
password "asd./"
}
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "${nexusUrl}/repository/maven-releases/") {
authentication(userName: nexusUsername, password: nexusPassword)
}
snapshotRepository(url: "${nexusUrl}/repository/maven-snapshots") {
authentication(userName: nexusUsername, password: nexusPassword)
}
}
}
}
repositories {
mavenLocal()
maven { url 'http://repo.spring.io/milestone' }
maven { url 'http://repo.spring.io/snapshot' }
maven { url 'https://repository.jboss.org/nexus/content/repositories/releases' }
maven { url 'https://oss.sonatype.org/content/repositories/releases' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'http://repo.maven.apache.org/maven2' }
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-logging'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
//
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile group: 'javax.el', name: 'javax.el-api', version: '3.0.0'
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
compile group: 'javax.transaction', name: 'javax.transaction-api', version: '1.2'
compile group: 'javax.annotation', name: 'jsr250-api', version: '1.0'
compile(group: 'com.zaxxer', name: 'HikariCP', version: '2.6.3') {
exclude(module: 'tools')
}
compile group: 'org.postgresql', name: 'postgresql', version: postgresql_version
compile group: 'org.springframework', name: 'spring-aspects', version: spring_framework_version
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: spring_framework_data_version
compile group: 'org.springframework.security', name: 'spring-security-core', version: spring_security_version
compile group: 'org.springframework.security', name: 'spring-security-config', version: spring_security_version
compile group: 'org.springframework.security', name: 'spring-security-data', version: spring_security_version
compile group: 'org.springframework.security', name: 'spring-security-web', version: spring_security_version
compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: spring_boot_version
compile group: 'org.hibernate', name: 'hibernate-core', version: hibernate_version
compile group: 'org.hibernate', name: 'hibernate-java8', version: hibernate_version
compile group: 'org.hibernate', name: 'hibernate-entitymanager', version: hibernate_version
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.7.0'
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: jackson_version
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jackson_version
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: jackson_version
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate5', version: jackson_version
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: jackson_version
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
compile group: 'net.bull.javamelody', name: 'javamelody-core', version: '1.68.0'
compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.2'
// Envío de emails
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
// Generación de PDFs
compile group: 'com.itextpdf', name: 'itextpdf', version: '5.5.10'
}
compileJava.dependsOn(processResources)
clean {
delete "target"
}
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
task stage(dependsOn: 'bootRepackage') {
}
My gradle.properties:
rootProject.name=application
profile=dev
##
## Versiones de las dependencias comunes del proyecto
postgresql_version=9.4-1203-jdbc42
jackson_version=2.7.9
hibernate_version=5.2.10.Final
spring_boot_version=1.4.7.RELEASE
spring_framework_version=4.3.9.RELEASE
spring_framework_data_version=1.10.11.RELEASE
spring_security_version=4.1.4.RELEASE
systemProp.sonar.host.url=https://asd-sonarqube.ga
systemProp.sonar.login=asd
systemProp.sonar.password=asd./
systemProp.sonar.sources=src/main
nexusUrl=http://asd-nexus.ga
nexusUsername=asd
nexusPassword=asd./
#Para solucionar problema de lanzar sonarqube desde jenkins
org.gradle.daemon=false
#systemProp.sonar.jdbc.url=jdbc:postgresql://localhost/sonar
#systemProp.sonar.jdbc.username=sonar
#systemProp.sonar.jdbc.password=sonar
##
## Configuraciones de GRADLE
##
## Below are some of the gradle performance improvement settings that can be used as required, these are not enabled by default
##
## The Gradle daemon aims to improve the startup and execution time of Gradle.
## When set to true the Gradle daemon is to run the build.
## TODO: disable daemon on CI, since builds should be clean and reliable on servers
## un comment the below line to enable the daemon
#org.gradle.daemon=true
## Specifies the JVM arguments used for the daemon process.
## The setting is particularly useful for tweaking memory settings.
## Default value: -Xmx1024m -XX:MaxPermSize=256m
## un comment the below line to override the daemon defaults
#org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
## When configured, Gradle will run in incubating parallel mode.
## This option should only be used with decoupled projects. More details, visit
## http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
## un comment the below line to enable parellel mode
#org.gradle.parallel=true
## Enables new incubating mode that makes Gradle selective when configuring projects.
## Only relevant projects are configured which results in faster builds for large multi-projects.
## http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand
## un comment the below line to enable the selective mode
#org.gradle.configureondemand=true
My application.yml:
# ===================================================================
# Spring Boot configuration.
#
# This configuracion will be overriden by the Spring profile you use,
# for example application-dev.yml if you use the "dev" profile.
# ===================================================================
locale:
default: es
server:
port: 8080
spring:
jpa:
database-platform: org.hibernate.dialect.PostgreSQL94Dialect
database: POSTGRESQL
openInView: false
show_sql: false
generate-ddl: false
hibernate:
ddl-auto: none
naming-strategy: org.hibernate.cfg.EJB3NamingStrategy
properties:
hibernate.cache.use_second_level_cache: false
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: true
hibernate.id.new_generator_mappings: true
hibernate.current_session_context_class: org.springframework.orm.hibernate5.SpringSessionContext
http:
multipart:
max-file-size: 20Mb
max-request-size: 20Mb
messages:
basename: i18n/messages
thymeleaf:
mode: XHTML
properties:
async:
corePoolSize: 2
maxPoolSize: 50
queueCapacity: 10000
security:
authentication:
jwt:
secret: c2t3f0c5dXF6bV9tOV45X2RpdmlzYQ==
# Token is valid 24 hours
tokenValidityInSeconds: 86400
tokenValidityInSecondsForRememberMe: 2592000
My application-prod.yml:
# ===================================================================
# Spring Boot configuration for the "prod" profile.
#
# This configuracion overrides the application.yml file.
# ===================================================================
spring:
# Configuración de la BASE DE DATOS
datasource:
dataSourceClassName: org.postgresql.ds.PGSimpleDataSource
url: jdbc:postgresql://pg:5432/ggal1701
username: asd
password: asd
maximum-pool-size: 5
application:
url: http://localhost:8080
profiles:
active: prod
devtools:
restart:
enabled: false
livereload:
enabled: false
server:
compression:
enabled: true
mime-types: text/html,text/xml,text/plain,text/css, application/javascript, application/json
As I mentioned at the beginning, I have tried many of the alternatives that appear in StackOverflow, but when I don't configure spring.datasource in my application-prod.yml, I always get a bug similar to the following one:
mrnobody#mrnobody-UX301LAA:~/Escritorio/tfg/appserver$ sudo docker run --network public --link pg --name tm -e JAVA_OPTS="-Ddatasource.jdbcUrl=jdbc:postgresql://pg:5432/ggal1701 -Ddatasource.user=postgres -Ddatasource.password=postgres" -p 9000:8080 worker
02-May-2018 20:56:17.864 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.51
02-May-2018 20:56:17.867 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Apr 9 2018 21:20:15 UTC
02-May-2018 20:56:17.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.51.0
02-May-2018 20:56:17.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
02-May-2018 20:56:17.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 4.13.0-39-generic
02-May-2018 20:56:17.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
02-May-2018 20:56:17.868 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/lib/jvm/java-8-openjdk-amd64/jre
02-May-2018 20:56:17.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_162-8u162-b12-1~deb9u1-b12
02-May-2018 20:56:17.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
02-May-2018 20:56:17.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat
02-May-2018 20:56:17.869 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat
02-May-2018 20:56:17.870 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
02-May-2018 20:56:17.870 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
02-May-2018 20:56:17.870 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Ddatasource.jdbcUrl=jdbc:postgresql://pg:5432/ggal1701
02-May-2018 20:56:17.870 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Ddatasource.user=postgres
02-May-2018 20:56:17.871 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Ddatasource.password=postgres
02-May-2018 20:56:17.871 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
02-May-2018 20:56:17.871 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
02-May-2018 20:56:17.871 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
02-May-2018 20:56:17.871 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
02-May-2018 20:56:17.872 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
02-May-2018 20:56:17.872 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
02-May-2018 20:56:17.872 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.16 using APR version 1.5.2.
02-May-2018 20:56:17.872 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
02-May-2018 20:56:17.882 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.1.0f 25 May 2017)
02-May-2018 20:56:18.001 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
02-May-2018 20:56:18.010 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
02-May-2018 20:56:18.011 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 614 ms
02-May-2018 20:56:18.040 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
02-May-2018 20:56:18.041 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.51
02-May-2018 20:56:18.066 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /usr/local/tomcat/webapps/ROOT.war
02-May-2018 20:56:21.589 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.
20:56:21.802 [localhost-startStop-1] WARN es.enxenio.GGAL1701.ApplicationWebXml - No Spring profile configured, running with default configuracion
20:56:22.446 [localhost-startStop-1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/logging.exception-conversion-word]
name [LOGGING_EXCEPTIONCONVERSIONWORD]. javax.naming.NameNotFoundException: Name [LOGGING_EXCEPTIONCONVERSIONWORD] is not bound in this Context. Unable to find [LOGGING_EXCEPTIONCONVERSIONWORD].
20:56:22.456 [localhost-startStop-1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [LOGGING_EXCEPTIONCONVERSIONWORD]
20:56:22.456 [localhost-startStop-1] DEBUG org.springframework.jndi.JndiPropertySource - JNDI lookup for name [LOGGING_EXCEPTIONCONVERSIONWORD] threw NamingException with message: Name [LOGGING_EXCEPTIONCONVERSIONWORD] is not bound in this Context. Unable to find [LOGGING_EXCEPTIONCONVERSIONWORD].. Returning null.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.7.RELEASE)
2018-05-02 20:56:22.956 INFO 1 --- [ost-startStop-1] es.enxenio.GGAL1701.ApplicationWebXml : Starting ApplicationWebXml on c72e1d8684c7 with PID 1 (/usr/local/tomcat/webapps/ROOT/WEB-INF/classes started by root in /usr/local/tomcat)
2018-05-02 20:56:22.958 DEBUG 1 --- [ost-startStop-1] es.enxenio.GGAL1701.ApplicationWebXml : Running with Spring Boot v1.4.7.RELEASE, Spring v4.3.9.RELEASE
2018-05-02 20:56:22.959 INFO 1 --- [ost-startStop-1] es.enxenio.GGAL1701.ApplicationWebXml : The following profiles are active: prod
2018-05-02 20:56:23.096 DEBUG 1 --- [kground-preinit] org.jboss.logging : Logging Provider: org.jboss.logging.Slf4jLoggerProvider found via system property
2018-05-02 20:56:25.745 DEBUG 1 --- [ost-startStop-1] net.bull.javamelody : spring interceptor initialized
2018-05-02 20:56:25.757 DEBUG 1 --- [ost-startStop-1] net.bull.javamelody : spring interceptor initialized
2018-05-02 20:56:25.758 DEBUG 1 --- [ost-startStop-1] net.bull.javamelody : spring interceptor initialized
2018-05-02 20:56:27.019 INFO 1 --- [ost-startStop-1] e.enxenio.GGAL1701.config.WebConfigurer : Web application configuracion, using profiles: [prod]
2018-05-02 20:56:27.020 DEBUG 1 --- [ost-startStop-1] e.enxenio.GGAL1701.config.WebConfigurer : Registering Caching HTTP Headers Filter
2018-05-02 20:56:27.021 INFO 1 --- [ost-startStop-1] e.enxenio.GGAL1701.config.WebConfigurer : Web application fully configured
2018-05-02 20:56:27.056 WARN 1 --- [ost-startStop-1] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [es/enxenio/GGAL1701/config/DatabaseConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2018-05-02 20:56:27.062 WARN 1 --- [ost-startStop-1] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available)
2018-05-02 20:56:27.198 ERROR 1 --- [ost-startStop-1] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method entityManagerFactory in es.enxenio.GGAL1701.config.DatabaseConfiguration required a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' in your configuration.
02-May-2018 20:56:27.199 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:755)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:731)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [es/enxenio/GGAL1701/config/DatabaseConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493)
02-May-2018 20:56:27.202 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive /usr/local/tomcat/webapps/ROOT.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:731)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
02-May-2018 20:56:27.204 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /usr/local/tomcat/webapps/ROOT.war has finished in 9,137 ms
02-May-2018 20:56:27.212 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/docs
02-May-2018 20:56:27.267 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/docs has finished in 55 ms
02-May-2018 20:56:27.270 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/examples
02-May-2018 20:56:27.535 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/examples has finished in 265 ms
02-May-2018 20:56:27.535 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/host-manager
02-May-2018 20:56:27.566 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/host-manager has finished in 31 ms
02-May-2018 20:56:27.566 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/manager
02-May-2018 20:56:27.588 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/manager has finished in 22 ms
02-May-2018 20:56:27.593 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
02-May-2018 20:56:27.631 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
02-May-2018 20:56:27.651 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 9639 ms

You have two choices, both works correctly:
The first is to pass the values as JAVA_OPTS as follows (you are going through the parameters wrong):
docker run \
--network public \
--link pg \
--name tm \
-e JAVA_OPTS= \
"-Dspring.datasource.url=jdbc:postgresql://pg:5432/ggal1701
-Dspring.datasource.username=postgres \
-Dspring.datasource.password=postgres" \
-p 9000:8080 worker
The second is to pass the values as environment variables as follows (your mistake is the absence of quotes):
docker run \
--network public \
--link pg \
--name tm \
-e DATASOURCE_JDBC_URL="jdbc:postgresql://pg:5432/ggal1701" \
-e DB_USERNAME="postgres" \
-e DB_PASSWORD="postgres" \
-p 9000:8080 worker
Remember to specify these parameters in your configuration to use this second option. In the first one you don't have to configure anything directly.
As part of the devOps culture I never recommend hardcoding the settings and opting for the second option while it is intended for that purpose. They both have to work for you, and if you don't, you have some other mistake.
What you say about the hikariPool error is only a consequence of the datasource failure. Try one of these two ways and, in my professional opinion, opt for the second.
I leave you a good tutorial: Spring-boot tutorial

If your task is to pass jdbc url as a parameter during container startup there is not need to do it through DatabaseConfiguration. It can be done fairly simpler using placeholders in your configuration and environment variables in docker-run command.
Define placeholders in the configuration:
spring:
datasource:
url: ${JDBC_URL}
username: ${DATABASE_USERNAME}
password: ${DATABASE_PASSWORD}
And run the container like this:
docker run \
--network public \
--link pg \
--name tm \
-e JDBC_URL="jdbc:postgresql://pg:5432/ggal1701" \
-e DATABASE_USERNAME="postgres" \
-e DATABASE_PASSWORD="postgres" \
-p 9000:8080 worker
Note: docker link is deprecated functionality, you'd probably want to replace it.

Java properties should work according to the Spring Boot Externalized Configuration Docs. Might that be that you're not using the right name for the java properties?
From your production properties I see, for instance, that the property for the database URL is spring.datasource.url:
spring:
# Configuración de la BASE DE DATOS
datasource:
url: jdbc:postgresql://pg:5432/ggal1701
However you passing through the following Java Property:
-Ddatasource.jdbcUrl=jdbc:postgresql://pg:5432/ggal1701
I think instead you should use:
-Dspring.datasource.url=jdbc:postgresql://pg:5432/ggal1701
Another suggestion that always worked for me is to use environment variables instead of java properties. You can was them with equal simplicity to your Docker:
-e SPRING_DATASOURCE_URL=jdbc:postgresql://pg:5432/ggal1701

Related

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

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
The browser returns me a 404 error instead.
I have tried several options
docker compose nginx and tomcat, expose only nginx on internet
Docker Nginx Reverse Proxy for Protection of Docker Container
docker after run image 404. Tomcat - requested resource is not available
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 <hogstrom#apache.org>
9056B710F1E332780DE7AF34CBAEBE39A46C4CA1 \
# Jeremy Whitlock <jwhitlock#apache.org>
F067B8140F5DD80E1D3B5D92318242FE9A0B1183 \
# Richard Kenneth McGuire (CODE SIGNING KEY) <rickmcguire#apache.org>
223D3A74B068ECA354DC385CE126833F9CF64915 \
# Jonathan Gallimore <jgallimore#apache.org>
DBCCD103B8B24F86FFAAB025C8BB472CD297D428 \
# Jarek Gawor (CODE SIGNING KEY) <gawor#apache.org>
7A2744A8A9AAF063C23EB7868EBE7DBE8D050EEF \
# Jarek Gawor <gawor#apache.org>
B8B301E6105DF628076BD92C5483E55897ABD9B9 \
# Andy Gumbrecht (TomEE Code Signing) <agumbrecht#tomitribe.com>
FAA603D58B1BA4EDF65896D0ED340E0E6D545F97 \
# Romain Manni-Bucau <rmannibucau#tomitribe.com>
A57DAF81C1B69921F4BA8723A8DE0A4DB863A7C1 \
# Mark Struberg (Apache) <struberg#apache.org>
82D8419BA697F0E7FB85916EE91287822FDB81B1 \
# David Blevins <dblevins#apache.org>
B7574789F5018690043E6DD9C212662E12F3E1DD \
# Xu Hai Hong (Ivan Xu # Geronimo) <xhhsld#gmail.com>
C23A3F6F595EBD0F960270CC997C8F1A5BE6E4C1 \
# Jean-Louis Monteiro (CODE SIGNING KEY) <jlmonteiro#apache.org>
678F2D98F1FD9643811639FB622B8F2D043F71D8 \
# Romain Manni-Bucau <rmannibucau#apache.org>
BDD0BBEB753192957EFC5F896A62FC8EF17D8FEF \
# Romain Manni-Bucau <rmannibucau#apache.org>
D11DF12CC2CA4894BDE638B967C1227A2678363C \
# Roberto Cortez (Apache Signing Key) <radcortez#yahoo.com>
C92604B0DEC5C62CFF5801E73D4683C24EDC64D1 \
# David Blevins <dblevins#tomitribe.com>
626C542EDA7C113814B77AF09C04914D63645D20 \
# Jean-Louis Monteiro (CODE SIGNING KEY) <jlmonteiro#apache.org>
3948829384B269D333CC5B98358807C52B4B0E23 \
# Richard Zowalla (Code Signing Key) <rzo1#apache.org>
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 class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> The requested resource [/example/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 class="line" /><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
}
}
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 <hogstrom#apache.org>
9056B710F1E332780DE7AF34CBAEBE39A46C4CA1 \
# Jeremy Whitlock <jwhitlock#apache.org>
F067B8140F5DD80E1D3B5D92318242FE9A0B1183 \
# Richard Kenneth McGuire (CODE SIGNING KEY) <rickmcguire#apache.org>
223D3A74B068ECA354DC385CE126833F9CF64915 \
# Jonathan Gallimore <jgallimore#apache.org>
DBCCD103B8B24F86FFAAB025C8BB472CD297D428 \
# Jarek Gawor (CODE SIGNING KEY) <gawor#apache.org>
7A2744A8A9AAF063C23EB7868EBE7DBE8D050EEF \
# Jarek Gawor <gawor#apache.org>
B8B301E6105DF628076BD92C5483E55897ABD9B9 \
# Andy Gumbrecht (TomEE Code Signing) <agumbrecht#tomitribe.com>
FAA603D58B1BA4EDF65896D0ED340E0E6D545F97 \
# Romain Manni-Bucau <rmannibucau#tomitribe.com>
A57DAF81C1B69921F4BA8723A8DE0A4DB863A7C1 \
# Mark Struberg (Apache) <struberg#apache.org>
82D8419BA697F0E7FB85916EE91287822FDB81B1 \
# David Blevins <dblevins#apache.org>
B7574789F5018690043E6DD9C212662E12F3E1DD \
# Xu Hai Hong (Ivan Xu # Geronimo) <xhhsld#gmail.com>
C23A3F6F595EBD0F960270CC997C8F1A5BE6E4C1 \
# Jean-Louis Monteiro (CODE SIGNING KEY) <jlmonteiro#apache.org>
678F2D98F1FD9643811639FB622B8F2D043F71D8 \
# Romain Manni-Bucau <rmannibucau#apache.org>
BDD0BBEB753192957EFC5F896A62FC8EF17D8FEF \
# Romain Manni-Bucau <rmannibucau#apache.org>
D11DF12CC2CA4894BDE638B967C1227A2678363C \
# Roberto Cortez (Apache Signing Key) <radcortez#yahoo.com>
C92604B0DEC5C62CFF5801E73D4683C24EDC64D1 \
# David Blevins <dblevins#tomitribe.com>
626C542EDA7C113814B77AF09C04914D63645D20 \
# Jean-Louis Monteiro (CODE SIGNING KEY) <jlmonteiro#apache.org>
3948829384B269D333CC5B98358807C52B4B0E23 \
# Richard Zowalla (Code Signing Key) <rzo1#apache.org>
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.

Why doesn't work logging in my springboot app on aws elasticbeanstalk?

My war application deployed on aws elasticbeanstalk doesn't write any logs.
I have the same problem like Logs not working on Elastic Beanstalk Tomcat environment. For tests and simplification I deployed a new empty war project generated from Spring framework Initializr (https://start.spring.io/) built by maven on OpenJDK Java11 to Tomcat 8.5 with Corretto 11 running on 64bit Amazon Linux 2/4.1.1.
I use slf4j logger.
And some info level logs records. On localhost works fine.
On aws elb is /var/log/tomcat/catalina.2020-11-05.log log file and after start I can see only this logs :
05-Nov-2020 10:48:37.902 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/8.5.56
05-Nov-2020 10:48:37.906 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jun 23 2020 17:39:13 UTC
05-Nov-2020 10:48:37.907 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 8.5.56.0
05-Nov-2020 10:48:37.907 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
05-Nov-2020 10:48:37.908 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 4.14.192-147.314.amzn2.x86_64
05-Nov-2020 10:48:37.908 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
05-Nov-2020 10:48:37.911 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/lib/jvm/java-11-amazon-corretto.x86_64
05-Nov-2020 10:48:37.913 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 11.0.8+10-LTS
05-Nov-2020 10:48:37.914 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Amazon.com Inc.
05-Nov-2020 10:48:37.914 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/share/tomcat
05-Nov-2020 10:48:37.914 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/share/tomcat
05-Nov-2020 10:48:37.914 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib]
05-Nov-2020 10:48:38.025 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
05-Nov-2020 10:48:38.078 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
05-Nov-2020 10:48:38.118 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1766 ms
05-Nov-2020 10:48:38.261 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
05-Nov-2020 10:48:38.263 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.56
05-Nov-2020 10:48:38.289 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/var/lib/tomcat/webapps/ROOT]
05-Nov-2020 10:48:38.738 WARNING [localhost-startStop-1] org.apache.tomcat.util.descriptor.web.WebXml.setVersion Unknown version string [4.0]. Default version will be used.
05-Nov-2020 10:48:41.253 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.
05-Nov-2020 10:48:41.544 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/var/lib/tomcat/webapps/ROOT] has finished in [3,252] ms
05-Nov-2020 10:48:41.552 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
05-Nov-2020 10:48:41.586 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 3467 ms
There is missing my info logs or any other springboot logs from my app.
In previous versions of ELB on java 1.8 it works fine. What has been changed?
How can I turn on logging again?
This was problem in our java spring application. Wrong devel configuration.
In application.properties was this line
logging.file.name=log/synchronization.log
I didn't notice that at first sight. In application-production.properties wasn't anything about logging therefore this configuration affected production, and all logs was written to this file (wrong path because on aws eb(tomcat) is directory for logging logs/ not log/). That's why I cannot see logs on standard log path less /var/log/tomcat/
I changed in application-production.properties to
logging.file.name=logs/my-app.log
and that is. It works now.

Helm chart spring boot application shut down immediately after starting

I was trying out spring boot microservice deployment on kubernetes cluster using Helm Chart. But I noticed a strange issue that my spring boot application start but it shutdown immediately after
Here are the logs
Started JhooqK8sApplication in 3.431 seconds (JVM running for 4.149)
2020-06-25 20:57:24.460 INFO 1 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-06-25 20:57:24.469 INFO 1 --- [extShutdownHook] o.e.jetty.server.AbstractConnector : Stopped ServerConnector#548a102f{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2020-06-25 20:57:24.470 INFO 1 --- [extShutdownHook] org.eclipse.jetty.server.session : node0 Stopped scavenging
2020-06-25 20:57:24.474 INFO 1 --- [extShutdownHook] o.e.j.s.h.ContextHandler.application : Destroying Spring FrameworkServlet 'dispatcherServlet'
2020-06-25 20:57:24.493 INFO 1 --- [extShutdownHook] o.e.jetty.server.handler.ContextHandler : Stopped o.s.b.w.e.j.JettyEmbeddedWebAppContext#56528192{application,/,[file:///tmp/jetty-docbase.4637295322181051129.8080/],UNAVAILABLE}
Spring Boot Version : 2.2.7.RELEASE
Docker Hub Public image for spring boot : rahulwagh17/kubernetes:jhooq-k8s-springboot-jetty
One strange thing which i noticed when i use kubectl command manually to create deployment and service spring boot deployments goes perfectly fine.
vagrant#kmaster:~$ kubectl create deployment demo --image=rahulwagh17/kubernetes:jhooq-k8s-springboot-jetty
vagrant#kmaster:~$ kubectl expose deployment demo --type=LoadBalancer --name=demo-service --external-ip=1.1.1.1 --port=8080
(I followed this guide for deploying spring boot on kubernete - Deploy spring boot on kubernetes cluster)
I am just wodering is there something wrong with spring boot or my helm setup?
Here is my helm templates -
---
# Source: springboot/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: RELEASE-NAME-springboot
labels:
helm.sh/chart: springboot-0.1.0
app.kubernetes.io/name: springboot
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/version: "1.16.0"
app.kubernetes.io/managed-by: Helm
---
# Source: springboot/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: RELEASE-NAME-springboot
labels:
helm.sh/chart: springboot-0.1.0
app.kubernetes.io/name: springboot
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/version: "1.16.0"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: springboot
app.kubernetes.io/instance: RELEASE-NAME
---
# Source: springboot/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: RELEASE-NAME-springboot
labels:
helm.sh/chart: springboot-0.1.0
app.kubernetes.io/name: springboot
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/version: "1.16.0"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: springboot
app.kubernetes.io/instance: RELEASE-NAME
template:
metadata:
labels:
app.kubernetes.io/name: springboot
app.kubernetes.io/instance: RELEASE-NAME
spec:
serviceAccountName: RELEASE-NAME-springboot
securityContext:
{}
containers:
- name: springboot
securityContext:
{}
image: "rahulwagh17/kubernetes:jhooq-k8s-springboot-jetty"
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{}
---
# Source: springboot/templates/tests/test-connection.yaml
apiVersion: v1
kind: Pod
metadata:
name: "RELEASE-NAME-springboot-test-connection"
labels:
helm.sh/chart: springboot-0.1.0
app.kubernetes.io/name: springboot
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/version: "1.16.0"
app.kubernetes.io/managed-by: Helm
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['RELEASE-NAME-springboot:80']
restartPolicy: Never
2020-06-25 20:57:24.469 INFO 1 --- [extShutdownHook] o.e.jetty.server.AbstractConnector : Stopped ServerConnector#548a102f{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
ports:
- name: http
containerPort: 80
It appears the liveness probe (configured to contact the port named http) is killing your Pod since your container appears to be listening on :8080 but you've told kubernetes that it's listening on :80
Since a kubectl created deployment will not have any such specificity, kubernetes won't use a liveness probe and there you are
You can usually configure the spring application via an environment variable if you want to test that theory:
containers:
- name: springboot
env:
- name: SERVER_PORT
value: '80'
# and its friend, which is the one that
# you should be using for liveness and readiness
- name: MANAGEMENT_SERVER_PORT
value: '8080'
securityContext:
{}
image: "rahulwagh17/kubernetes:jhooq-k8s-springboot-jetty"
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 80
protocol: TCP

How do I automatically execute war files at Jenkins?

I am going to use Jenkins to execute the project automatically. The project is uploaded to github and succeeded in building War files using Jenkins. War file were moved to Tomcat's Webapps file, and Tomcat built it, but Tomcat runs properly, but projects don't run the project.
Setting
init_server.sh
echo "> Check the currently running spring server pid "
CURRENT_PID=$(ps -ef | grep java | grep tomcat | awk '{print $2}')
echo "$CURRENT_PID"
if [ -z $CURRENT_PID ]; then
echo "> No applications are currently running and will not be shut down."
else
echo "> kill -9 $CURRENT_PID"
kill -9 $CURRENT_PID
sleep 10
fi
rm -rf /usr/local/tomcat9/webapps/ji**t /usr/local/tomcat9/webapps/ji**t .war
echo nohup mv /root/jenkinsproject/deploy/*.war /usr/local/tomcat9/webapps/jinheeproject.war >> /root/jenkinsproject/logs/springtestprojectSys.log &
mv /root/jenkinsproject/deploy/*.war /usr/local/tomcat9/webapps/ji**t.war
sleep 10
cd /usr/local/tomcat9/bin
./startup.sh
echo "Execution complete."
application.yml
Run build in Jenkins, Follow the instructions in the Shell file, turn off the old Tomcat, and run the new Tomcat. And I type 'serverIP:8080' and the Tomcat server starts. But if I type 'serverIP:8080/helloworld', I see 404 error.
NOTE: I tested my project in the local environment. It was successful.
example: localhost:8080/helloworld
server.xml in cloud server
<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 "%r" %s %b" />
<Context path="" docBase="ji**t" reloadable="false" />
</Host>
my catalina logs
03-Mar-2020 16:55:23.226 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.31
03-Mar-2020 16:55:23.229 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Feb 5 2020 19:32:12 UTC
03-Mar-2020 16:55:23.230 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.31.0
03-Mar-2020 16:55:23.230 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
03-Mar-2020 16:55:23.230 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 4.4.0-59-generic
03-Mar-2020 16:55:23.230 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
03-Mar-2020 16:55:23.230 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/lib/jvm/java-8-openjdk-amd64/jre
03-Mar-2020 16:55:23.231 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_242-8u242-b08-0ubuntu3~16.04-b08
03-Mar-2020 16:55:23.231 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Private Build
03-Mar-2020 16:55:23.232 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat9
03-Mar-2020 16:55:23.232 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat9
03-Mar-2020 16:55:23.233 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat9/conf/logging.properties
03-Mar-2020 16:55:23.233 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
03-Mar-2020 16:55:23.233 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
03-Mar-2020 16:55:23.233 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
03-Mar-2020 16:55:23.234 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
03-Mar-2020 16:55:23.234 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
03-Mar-2020 16:55:23.234 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat9
03-Mar-2020 16:55:23.234 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat9
03-Mar-2020 16:55:23.235 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat9/temp
03-Mar-2020 16:55:23.235 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib]
03-Mar-2020 16:55:23.451 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
03-Mar-2020 16:55:23.498 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [518] milliseconds
03-Mar-2020 16:55:23.528 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
03-Mar-2020 16:55:23.528 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.31]
03-Mar-2020 16:55:27.202 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.
03-Mar-2020 16:55:27.296 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat9/webapps/host-manager]
03-Mar-2020 16:55:27.328 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat9/webapps/host-manager] has finished in [31] ms
03-Mar-2020 16:55:27.328 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat9/webapps/manager]
03-Mar-2020 16:55:27.352 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat9/webapps/manager] has finished in [24] ms
03-Mar-2020 16:55:27.352 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat9/webapps/ROOTBEFORE]
03-Mar-2020 16:55:27.365 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat9/webapps/ROOTBEFORE] has finished in [12] ms
03-Mar-2020 16:55:27.365 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat9/webapps/docs]
03-Mar-2020 16:55:27.379 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat9/webapps/docs] has finished in [14] ms
03-Mar-2020 16:55:27.383 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
03-Mar-2020 16:55:27.391 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [3,892] milliseconds
There was something I was missing. I forgot to inherit SpringBootServletInitializer and set it up.
application.java
#SpringBootApplication
public class Application extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

docker after run image 404. Tomcat - requested resource is not available

I need to collect a simple Java application on Tomcat in docker container, but after the launch we have error:
HTTP Status 404 - /docker-test-02-1.0-SNAPSHOT
type Status report
message /docker-test-02-1.0-SNAPSHOT
description The requested resource is not available.
Apache Tomcat/8.0.41
Project:
Dockerfile:
FROM tomcat:8.0.41-jre8
MAINTAINER Sergii D
# fixed path for copying
COPY docker-test-02-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/ROOT.war
# Routine for me - optional for your case
EXPOSE 8080
# And run tomcat
CMD ["/usr/local/tomcat/bin/catalina.sh", "run"]
docker build -t yourname .
docker run --rm -it -p 8080:8080 yourname
user#pc MINGW64 /d/docker-dir
$ docker build -t hello-docker-01 .
Sending build context to Docker daemon 103.4 kB
Step 1/5 : FROM tomcat:8.0.41-jre8
---> f1fc1ce9e0ab
Step 2/5 : MAINTAINER Sergii D
---> Using cache
---> 538a59db8c27
Step 3/5 : COPY docker-test-02-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/ROOT.w
ar
---> 3fdcd3813c43
Removing intermediate container af956ac954a9
Step 4/5 : EXPOSE 8080
---> Running in 7bef72073fa8
---> bc5e2f1a9bf1
Removing intermediate container 7bef72073fa8
Step 5/5 : CMD /usr/local/tomcat/bin/catalina.sh run
---> Running in c51d453b3752
---> f742d6cd3cf5
Removing intermediate container c51d453b3752
Successfully built f742d6cd3cf5
SECURITY WARNING: You are building a Docker image from Windows against a non-Win
dows Docker host. All files and directories added to build context will have '-r
wxr-xr-x' permissions. It is recommended to double check and reset permissions f
or sensitive files and directories.
user#pc MINGW64 /d/docker-dir
$ docker --rm -it -p 8080:8080 hello-docker-01
flag provided but not defined: --rm
See 'C:\Program Files\Docker Toolbox\docker.exe --help'.
user#pc MINGW64 /d/docker-dir
$ docker run --rm -it -p 8080:8080 hello-docker-01
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/lib/jvm/java-8-openjdk-amd64/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin
/tomcat-juli.jar
31-Jan-2017 14:14:10.330 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Server version: Apache Tomcat/8.0.41
31-Jan-2017 14:14:10.344 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Server built: Jan 18 2017 22:19:39 UTC
31-Jan-2017 14:14:10.344 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Server number: 8.0.41.0
31-Jan-2017 14:14:10.344 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log OS Name: Linux
31-Jan-2017 14:14:10.344 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log OS Version: 4.4.43-boot2docker
31-Jan-2017 14:14:10.345 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Architecture: amd64
31-Jan-2017 14:14:10.346 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Java Home: /usr/lib/jvm/java-8-openjdk-amd64/jre
31-Jan-2017 14:14:10.346 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log JVM Version: 1.8.0_111-8u111-b14-2~bpo8+1-b14
31-Jan-2017 14:14:10.347 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log JVM Vendor: Oracle Corporation
31-Jan-2017 14:14:10.347 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log CATALINA_BASE: /usr/local/tomcat
31-Jan-2017 14:14:10.347 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log CATALINA_HOME: /usr/local/tomcat
31-Jan-2017 14:14:10.348 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tom
cat/conf/logging.properties
31-Jan-2017 14:14:10.348 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.Cl
assLoaderLogManager
31-Jan-2017 14:14:10.348 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
31-Jan-2017 14:14:10.349 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catali
na.webresources
31-Jan-2017 14:14:10.349 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Djava.endorsed.dirs=/usr/local/tomcat/endorse
d
31-Jan-2017 14:14:10.349 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
31-Jan-2017 14:14:10.350 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
31-Jan-2017 14:14:10.350 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
31-Jan-2017 14:14:10.350 INFO [main] org.apache.catalina.core.AprLifecycleListen
er.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.10 using APR
version 1.5.1.
31-Jan-2017 14:14:10.351 INFO [main] org.apache.catalina.core.AprLifecycleListen
er.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters
[false], random [true].
31-Jan-2017 14:14:10.381 INFO [main] org.apache.catalina.core.AprLifecycleListen
er.initializeSSL OpenSSL successfully initialized (OpenSSL 1.1.0c 10 Nov 2016)
31-Jan-2017 14:14:10.748 INFO [main] org.apache.coyote.AbstractProtocol.init Ini
tializing ProtocolHandler ["http-apr-8080"]
31-Jan-2017 14:14:10.769 INFO [main] org.apache.coyote.AbstractProtocol.init Ini
tializing ProtocolHandler ["ajp-apr-8009"]
31-Jan-2017 14:14:10.772 INFO [main] org.apache.catalina.startup.Catalina.load I
nitialization processed in 2074 ms
31-Jan-2017 14:14:10.860 INFO [main] org.apache.catalina.core.StandardService.st
artInternal Starting service Catalina
31-Jan-2017 14:14:10.861 INFO [main] org.apache.catalina.core.StandardEngine.sta
rtInternal Starting Servlet Engine: Apache Tomcat/8.0.41
31-Jan-2017 14:14:10.958 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployWAR Deploying web application archive /usr/local/tomcat/webap
ps/ROOT.war
31-Jan-2017 14:14:11.884 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployWAR Deployment of web application archive /usr/local/tomcat/w
ebapps/ROOT.war has finished in 921 ms
31-Jan-2017 14:14:11.893 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory /usr/local/tomc
at/webapps/manager
31-Jan-2017 14:14:11.988 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory /usr/local/
tomcat/webapps/manager has finished in 95 ms
31-Jan-2017 14:14:11.988 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory /usr/local/tomc
at/webapps/host-manager
31-Jan-2017 14:14:12.051 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory /usr/local/
tomcat/webapps/host-manager has finished in 63 ms
31-Jan-2017 14:14:12.052 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory /usr/local/tomc
at/webapps/docs
31-Jan-2017 14:14:12.093 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory /usr/local/
tomcat/webapps/docs has finished in 41 ms
31-Jan-2017 14:14:12.101 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory /usr/local/tomc
at/webapps/examples
31-Jan-2017 14:14:12.812 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory /usr/local/
tomcat/webapps/examples has finished in 712 ms
31-Jan-2017 14:14:12.823 INFO [main] org.apache.coyote.AbstractProtocol.start St
arting ProtocolHandler ["http-apr-8080"]
31-Jan-2017 14:14:12.839 INFO [main] org.apache.coyote.AbstractProtocol.start St
arting ProtocolHandler ["ajp-apr-8009"]
31-Jan-2017 14:14:12.844 INFO [main] org.apache.catalina.startup.Catalina.start
Server startup in 2071 ms
Then I open the link in a browser
http://192.168.99.100:8080/docker-test-02-1.0-SNAPSHOT
and I see an errorThe requested resource is not available.
How can I fix that?
PS: If open 192.168.99.100:8080 there will be sample TomCat page, so all ok with TomCat
.png
You are copying your war file as Root. war when you copy it in docker file. Copy it as /usr/local/tomcat/webapps/ instead. Or try with context ROOT.

Categories

Resources