failed to initialize Tomcat while running Spring boot app with vaadin in docker

Kiemoon

I'm hobbyst and recently switched from heroku to render.com. I wanted to put my SringBoot app there but it requires me to run it in docker environment which I have no expirience with. I managed to write Dockerfile for it, and run it from jar file, but I still getting the log:

Caused by: java.lang.IllegalStateException: StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[] failed to start
Dec 11 12:57:44 PM      at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.rethrowDeferredStartupExceptions(TomcatWebServer.java:171) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]
Dec 11 12:57:44 PM      at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:110) ~[spring-boot-2.2.4.RELEASE.jar!/:2.2.4.RELEASE]  

My suspicion is that is becuse of vaadin-dev-server-settings.json:

{
  "frontendFolder": "C:/Users/kiemoon/IdeaProjects/Vadin/assistant_vaadin/frontend",
  "themeFolder": "themes",
  "themeResourceFolder": "C:/Users/kiemoon/IdeaProjects/Vadin/assistant_vaadin/build/flow-frontend",
  "staticOutput": "build/classes/META-INF/VAADIN/webapp/VAADIN/static",
  "generatedFolder": "generated",
  "frontendBundleOutput": "build/classes/META-INF/VAADIN/webapp/",
  "addonFrontendFolder": "build/flow-frontend/",
  "themeName": "",
  "clientServiceWorkerSource": "C:\\Users\\kiemoon\\IdeaProjects\\Vadin\\assistant_vaadin\\build\\sw.ts",
  "pwaEnabled": false,
  "offlineEnabled": false,
  "offlinePath": "'offline.html'"
}

or is it because of Dockerfile? :

FROM openjdk:11
WORKDIR /
ADD build/libs/assistant_vaadin-0.0.1-SNAPSHOT.jar app.jar
CMD java -jar -Dspring.profiles.active=prod app.jar

application.properties:

server.tomcat.accesslog.enabled=true

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true

spring.datasource.url=jdbc:*******
spring.datasource.username=*******
spring.datasource.password=*******
spring.datasource.driver-class-name=org.postgresql.Driver

vaadin.productionMode=true

buil.gradle:

buildscript {
    repositories {
        mavenCentral()
        maven { setUrl("https://maven.vaadin.com/vaadin-prereleases") }
        maven { setUrl("https://maven.vaadin.com/vaadin-addons") }
    }
}
plugins {
    id 'org.springframework.boot' version '2.2.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
    id 'com.vaadin'
}

defaultTasks("clean", "build")

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
    maven { setUrl("https://maven.vaadin.com/vaadin-prereleases") }
    maven { setUrl("https://maven.vaadin.com/vaadin-addons") }
}

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

dependencies {
    implementation('com.vaadin:vaadin-spring-boot-starter')
    implementation 'org.jetbrains:annotations:20.1.0'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    implementation 'com.opencsv:opencsv:5.7.1'
    implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'org.postgresql:postgresql:42.5.1'

    annotationProcessor 'org.projectlombok:lombok'
    implementation 'org.springframework.boot:spring-boot-starter'
}

dependencyManagement {
    imports {
        mavenBom "com.vaadin:vaadin-bom:$vaadinVersion"
    }
}

test {
    useJUnitPlatform()
}

// The following pnpmEnable = true is not needed as pnpm is used by default,
// this is just an example of how to configure the Gradle Vaadin Plugin:
// for more configuration options please see: https://vaadin.com/docs/latest/guide/start/gradle/#all-options
vaadin {
    pnpmEnable = true
}

bootRun {
    systemProperties = System.properties
}
Leif Åstrand

You need to enable production mode for the Gradle build and not only in the Spring configuration by setting productionMode = true in the vaadin section of build.gradle or by running Gradle with -Pvaadin.productionMode=true.

See https://vaadin.com/docs/latest/guide/start/gradle/#production for more information, but note that the very first examples assume a war deployment rather than using Spring Boot.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Pass command line args to Java app (Spring Boot) running in Docker

Spring boot web app not running on tomcat 9

Why the spring boot vaadin app can not run?

Exception when running Spring Boot app inside of Docker

error while running spring boot app on localhost

Spring boot WAR deployment failed to start in Tomcat

Spring Boot upload feature doesn't work in production while running on Docker

Docker-compose: Issue while running the spring boot enabled and spring cloud config application

java.lang.VerifyError while starting spring boot app using tomcat

Getting Tomcat 404 error while trying to deploy simple hello spring boot app

Connection refused by Spring boot app running in different docker container

Running Spring Boot 2 app on SAP Neo Cloud Tomcat

Android - Build Failed error While Running an App

Spring boot API and React js running on Tomcat

Running Spring Boot app inside Docker container, unable to connect MySQL

Failed to initialize libdc1394 when running caffe docker image

Spring Boot, failed to initialise embedded tomcat

JSF components are not rendered when running Spring Boot app on Eclipse Tomcat

Spring Boot with RabbitMQ failed to initialize

spring boot app not connecting to activemq which is running in a docker container

Error while running spring boot on external tomcat inside docker container

Spring Boot + Tomcat + Jetty - Application failed to start

Caused by: com.vaadin.flow.server.ExecutionFailedException: Command 'npm install' failed to finish for Sparing Boot app with Vaadin

Getting Exceptions while running a Spring boot app with elasticsearch

Authentication failed connecting to MongoDB running in a local docker cointainer from Spring Boot application

Logging In A Spring Boot Application Deployed to Docker Tomcat

Spring boot don't initialize on tomcat9

Failed to initialize the reader while running Spring Batch while reading from sql Table

Heroku R10 Error while running Spring Boot App