FINERACT-730: Fixed dependencies, SSL config and main class etc to get bootRun to work. Migrated from Gradle Tomcat plugin to Cargo plugin to fix integration test

This commit is contained in:
Petri Tuomola
2020-05-05 22:04:04 +02:00
committed by Michael Vorburger ⛑️
parent cb690f6d5b
commit b05162f60b
9 changed files with 94 additions and 142 deletions
+3 -2
View File
@@ -37,14 +37,15 @@ RUN ./gradlew clean -x rat -x test war
# ========================================= # =========================================
FROM bitnami/tomcat:7.0.94 as fineract FROM bitnami/tomcat:9.0 as fineract
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/jre ENV JAVA_HOME /usr/local/openjdk-8/jre
USER root USER root
RUN apt-get update -qq && apt-get install -y wget RUN apt-get update -qq && apt-get install -y wget
COPY --from=builder /fineract/build/libs/fineract-provider.war /opt/bitnami/tomcat/webapps COPY --from=builder /fineract/build/libs/fineract-provider.war /opt/bitnami/tomcat/webapps
COPY --from=builder /usr/local/openjdk-8/jre /usr/local/openjdk-8/jre
RUN keytool -genkey -keyalg RSA -alias tomcat -keystore /opt/bitnami/tomcat/tomcat.keystore -keypass xyz123 -storepass xyz123 -noprompt -dname "CN=Fineract, OU=Fineract, O=Fineract, L=Unknown, ST=Unknown, C=Unknown" RUN keytool -genkey -keyalg RSA -alias tomcat -keystore /opt/bitnami/tomcat/tomcat.keystore -keypass xyz123 -storepass xyz123 -noprompt -dname "CN=Fineract, OU=Fineract, O=Fineract, L=Unknown, ST=Unknown, C=Unknown"
COPY ./docker/server.xml /opt/bitnami/tomcat/conf COPY ./docker/server.xml /opt/bitnami/tomcat/conf
+3 -2
View File
@@ -20,6 +20,7 @@ Requirements
============ ============
* Java >= 1.8 (Oracle JVMs have been tested) * Java >= 1.8 (Oracle JVMs have been tested)
* MySQL 5.5 * MySQL 5.5
* Tomcat 9, if deploying to a separate servlet container. Until FINERACT-730, Tomcat 7/8 were also supported, but now Tomcat 9 is required.
You can run the required version of the database server in a container, instead of having to install it, like this: You can run the required version of the database server in a container, instead of having to install it, like this:
@@ -38,7 +39,7 @@ Instructions how to run for local development
Run the following commands: Run the following commands:
1. `./gradlew createDB -PdbName=fineract_tenants` 1. `./gradlew createDB -PdbName=fineract_tenants`
1. `./gradlew createDB -PdbName=fineract_default` 1. `./gradlew createDB -PdbName=fineract_default`
1. `./gradlew tomcatRunWAR` 1. `./gradlew bootRun`
Instructions to download gradle wrapper Instructions to download gradle wrapper
@@ -63,7 +64,7 @@ Instructions to run Apache RAT (Release Audit Tool)
Instructions to build a WAR file Instructions to build a WAR file
============ ============
1. Extract the archive file to your local directory. 1. Extract the archive file to your local directory.
2. Run `./gradlew clean war` or `./gradlew build` to build a deployable war file which will be created at build/libs directory. 2. Run `./gradlew clean bootWar` or `./gradlew build` to build a deployable war file which will be created at build/libs directory.
Instructions to execute Integration tests Instructions to execute Integration tests
+4 -3
View File
@@ -70,7 +70,7 @@
Either JSSE or OpenSSL style configuration may be used regardless of Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below. the SSLImplementation selected. JSSE style configuration is used below.
--> -->
<Connector protocol="org.apache.coyote.http11.Http11Protocol" <Connector protocol="org.apache.coyote.http11.Http11NioProtocol"
port="8443" maxThreads="200" scheme="https" port="8443" maxThreads="200" scheme="https"
secure="true" SSLEnabled="true" secure="true" SSLEnabled="true"
keystoreFile="/opt/bitnami/tomcat/tomcat.keystore" keystoreFile="/opt/bitnami/tomcat/tomcat.keystore"
@@ -108,8 +108,9 @@
--> -->
<!-- Define an AJP 1.3 Connector on port 8009 --> <!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <!--
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" secret="xyz123" />
-->
<!-- An Engine represents the entry point (within Catalina) that processes <!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone every request. The Engine implementation for Tomcat stand alone
+38 -48
View File
@@ -18,8 +18,7 @@
*/ */
description = '''\ description = '''\
Run as: Run as:
gradle clean tomcatrunwar gradle clean bootRun'''
'''
project.ext.jerseyVersion = '1.19.4' project.ext.jerseyVersion = '1.19.4'
@@ -35,7 +34,7 @@ buildscript {
dependencies { dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE' classpath 'io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE'
classpath 'com.bmuschko:gradle-tomcat-plugin:2.5', classpath 'com.bmuschko:gradle-cargo-plugin:2.7.1',
'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0', 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0',
'org.zeroturnaround:gradle-jrebel-plugin:1.1.2', 'org.zeroturnaround:gradle-jrebel-plugin:1.1.2',
'org.springframework.boot:spring-boot-gradle-plugin:2.2.4.RELEASE' 'org.springframework.boot:spring-boot-gradle-plugin:2.2.4.RELEASE'
@@ -60,7 +59,7 @@ apply plugin: 'war'
apply plugin: 'org.springframework.boot' apply plugin: 'org.springframework.boot'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'idea' apply plugin: 'idea'
apply plugin: 'com.bmuschko.tomcat' apply plugin: 'com.bmuschko.cargo'
apply plugin: 'project-report' apply plugin: 'project-report'
apply plugin: 'java-library' apply plugin: 'java-library'
apply plugin: 'openjpa' apply plugin: 'openjpa'
@@ -88,6 +87,7 @@ dependencyManagement {
dependency 'com.google.code.gson:gson:+' dependency 'com.google.code.gson:gson:+'
dependency 'com.google.guava:guava:28.1-jre' dependency 'com.google.guava:guava:28.1-jre'
dependency 'org.apache.commons:commons-email:1.5' dependency 'org.apache.commons:commons-email:1.5'
dependency 'org.apache.commons:commons-io:+'
dependency 'org.drizzle.jdbc:drizzle-jdbc:1.4' dependency 'org.drizzle.jdbc:drizzle-jdbc:1.4'
dependency 'com.lowagie:itext:2.1.7' dependency 'com.lowagie:itext:2.1.7'
dependency 'com.lowagie:itext-rtf:2.1.7' dependency 'com.lowagie:itext-rtf:2.1.7'
@@ -124,13 +124,7 @@ dependencyManagement {
entry 'poi' entry 'poi'
entry 'poi-ooxml' entry 'poi-ooxml'
entry 'poi-ooxml-schemas' entry 'poi-ooxml-schemas'
} }
dependencySet(group: 'org.apache.tomcat.embed', version: '7.0.94') {
entry 'tomcat-embed-core'
entry 'tomcat-embed-jasper'
entry 'tomcat-embed-logging-log4j'
}
} }
} }
@@ -274,7 +268,6 @@ configurations {
exclude module: 'classworlds' exclude module: 'classworlds'
} }
runtime runtime
all*.exclude group: 'commons-logging'
all*.exclude module: 'jul-to-slf4j' // see FINERACT-700 re. ClassCircularityError: java/util/logging/LogRecord all*.exclude module: 'jul-to-slf4j' // see FINERACT-700 re. ClassCircularityError: java/util/logging/LogRecord
} }
/* Pick up dependencies based on the environemnt, defaults to production */ /* Pick up dependencies based on the environemnt, defaults to production */
@@ -419,52 +412,51 @@ task licenseFormatBuildScripts (type:nl.javadude.gradle.plugins.license.License)
} }
licenseFormat.dependsOn licenseFormatBuildScripts licenseFormat.dependsOn licenseFormatBuildScripts
tomcatRun { configurations
httpPort = 8080 {
httpsPort = 8443 tomcat
stopPort = 8081
stopKey= 'stopKey'
enableSSL = true
} }
tomcatRunWar { dependencies {
httpPort = 8080 tomcat "org.apache.tomcat:tomcat:9.0.34@zip"
httpsPort = 8443
stopPort = 8081
stopKey= 'stopKey'
enableSSL = true
keystoreFile = file('src/main/resources/keystore.jks')
keystorePass = 'openmf'
} }
task tomcatRunWarAsDaemonForIntegrationTest(type: com.bmuschko.gradle.tomcat.tasks.TomcatRunWar) { cargo {
httpPort = 8080 containerId "tomcat9x"
httpsPort = 8443
stopPort = 8081 local {
stopKey= 'stopKey' installer {
enableSSL = true installConfiguration = configurations.tomcat
keystoreFile = file('src/main/resources/keystore.jks') downloadDir = file("$buildDir/download")
keystorePass = 'openmf' extractDir = file("$buildDir/tomcat")
daemon = true }
containerProperties {
property 'cargo.tomcat.connector.keystoreFile', file('src/main/resources/keystore.jks')
property 'cargo.tomcat.connector.keystorePass', 'openmf'
property 'cargo.tomcat.httpSecure', true
property 'cargo.tomcat.connector.sslProtocol', 'TLS'
property 'cargo.tomcat.connector.clientAuth', false
property 'cargo.protocol', 'https'
property 'cargo.servlet.port', 8443
}
}
} }
task tomcatStopAfterIntegrationTest(type: com.bmuschko.gradle.tomcat.tasks.TomcatStop) { cargoRunLocal.dependsOn bootWar
stopPort = 8081 cargoStartLocal.dependsOn bootWar
stopKey = 'stopKey'
}
/* http://stackoverflow.com/questions/19653311/jpa-repository-works-in-idea-and-production-but-not-in-gradle */ /* http://stackoverflow.com/questions/19653311/jpa-repository-works-in-idea-and-production-but-not-in-gradle */
sourceSets.main.output.resourcesDir = sourceSets.main.java.outputDir sourceSets.main.output.resourcesDir = sourceSets.main.java.outputDir
sourceSets.test.output.resourcesDir = sourceSets.test.java.outputDir sourceSets.test.output.resourcesDir = sourceSets.test.java.outputDir
/* Exclude maria db and embedded tomcat related files for non dev builds */ /* Exclude maria db related files for non dev builds */
if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) { if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) {
sourceSets { sourceSets {
main { main {
java { java {
exclude '**/Server*' exclude '**/ServerWithMariaDB*'
exclude '**/MariaDB4j*' exclude '**/MariaDB4j*'
exclude '**/EmbeddedTomcatWithSSLConfiguration.java'
} }
} }
test { test {
@@ -489,10 +481,8 @@ configurations {
task integrationTest(type:Test) { task integrationTest(type:Test) {
description = "Run integration tests (located in src/integrationTest/java). Starts Tomcat in daemon mode before executing the tests (and stops it after)." description = "Run integration tests (located in src/integrationTest/java). Starts Tomcat in daemon mode before executing the tests (and stops it after)."
dependsOn war dependsOn cargoStartLocal
dependsOn tomcatRunWarAsDaemonForIntegrationTest finalizedBy cargoStopLocal
tasks.findByName('tomcatRunWarAsDaemonForIntegrationTest').mustRunAfter 'war'
finalizedBy tomcatStopAfterIntegrationTest
testClassesDirs = project.sourceSets.integrationTest.output.classesDirs testClassesDirs = project.sourceSets.integrationTest.output.classesDirs
classpath = project.sourceSets.integrationTest.runtimeClasspath classpath = project.sourceSets.integrationTest.runtimeClasspath
@@ -576,11 +566,11 @@ def qualifyVersionIfNecessary(version) {
} }
springBoot { springBoot {
mainClassName = 'org.apache.fineract.ServerWithMariaDB4jApplication' mainClassName = 'org.apache.fineract.ServerApplication'
} }
bootWar { bootWar {
mainClassName = 'org.apache.fineract.ServerWithMariaDB4jApplication' mainClassName = 'org.apache.fineract.ServerApplication'
} }
// To generate an HTML report instead of XML // To generate an HTML report instead of XML
+21 -15
View File
@@ -17,25 +17,26 @@
* under the License. * under the License.
*/ */
dependencies { dependencies {
tomcat "org.apache.tomcat.embed:tomcat-embed-core", providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
"org.apache.tomcat.embed:tomcat-embed-logging-log4j" // NOT tomcat-embed-logging-juli (http://stackoverflow.com/questions/23963049/classcircularityerror-java-util-logging-logrecord-running-gradle-webapp-with-ja)
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper") { spotbugsPlugins "jp.skypencil.findbugs.slf4j:bug-pattern:1.4.2@jar"
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
spotbugsPlugins 'jp.skypencil.findbugs.slf4j:bug-pattern:1.4.2@jar'
compile ('org.springframework.boot:spring-boot-starter-data-jpa') { compile ('org.springframework.boot:spring-boot-starter-data-jpa') {
exclude group: 'org.hibernate' exclude group: 'org.hibernate'
} }
compile ('com.amazonaws:aws-java-sdk-s3') {
exclude group: 'commons-logging'
}
compile ('org.mnode.ical4j:ical4j') {
exclude group: 'commons-logging'
}
api( api(
'com.google.code.gson:gson', 'com.google.code.gson:gson',
'org.springframework:spring-jms', 'org.springframework:spring-jms',
'joda-time:joda-time', 'joda-time:joda-time',
'org.mnode.ical4j:ical4j',
'com.google.guava:guava', 'com.google.guava:guava',
'org.springframework:spring-context-support', 'org.springframework:spring-context-support',
'org.springframework.security.oauth:spring-security-oauth2', 'org.springframework.security.oauth:spring-security-oauth2',
@@ -44,13 +45,15 @@ dependencies {
'jakarta.jms:jakarta.jms-api', 'jakarta.jms:jakarta.jms-api',
'jakarta.management.j2ee:jakarta.management.j2ee-api' 'jakarta.management.j2ee:jakarta.management.j2ee-api'
) )
api ('org.apache.openjpa:openjpa') { api ('org.apache.openjpa:openjpa') {
exclude group: 'org.eclipse.persistence' exclude group: 'org.eclipse.persistence'
exclude group: 'org.apache.geronimo.specs' exclude group: 'org.apache.geronimo.specs'
} }
api('org.quartz-scheduler:quartz') {
exclude group: 'com.zaxxer', module: 'HikariCP-java7' api('org.quartz-scheduler:quartz') {
} exclude group: 'com.zaxxer', module: 'HikariCP-java7'
}
implementation( implementation(
//'ch.vorburger.mariaDB4j:mariaDB4j:2.4.0', //'ch.vorburger.mariaDB4j:mariaDB4j:2.4.0',
@@ -73,6 +76,7 @@ dependencies {
'org.apache.commons:commons-email', 'org.apache.commons:commons-email',
'org.apache.commons:commons-lang3', 'org.apache.commons:commons-lang3',
'org.apache.commons:commons-io',
'org.drizzle.jdbc:drizzle-jdbc', 'org.drizzle.jdbc:drizzle-jdbc',
@@ -84,7 +88,6 @@ dependencies {
'com.googlecode.flyway:flyway-core', 'com.googlecode.flyway:flyway-core',
'com.amazonaws:aws-java-sdk-s3',
'net.sf.ehcache:ehcache', 'net.sf.ehcache:ehcache',
'com.github.spullara.mustache.java:compiler', 'com.github.spullara.mustache.java:compiler',
'com.jayway.jsonpath:json-path', 'com.jayway.jsonpath:json-path',
@@ -108,7 +111,6 @@ dependencies {
'com.google.code.gson:gson', 'com.google.code.gson:gson',
'org.springframework:spring-jms', 'org.springframework:spring-jms',
'joda-time:joda-time', 'joda-time:joda-time',
'org.mnode.ical4j:ical4j',
'com.google.guava:guava', 'com.google.guava:guava',
'org.apache.poi:poi-ooxml', 'org.apache.poi:poi-ooxml',
'org.springframework:spring-context-support', 'org.springframework:spring-context-support',
@@ -117,9 +119,13 @@ dependencies {
exclude group: 'regexp' exclude group: 'regexp'
} }
testCompile ('io.rest-assured:rest-assured') { testCompile ('io.rest-assured:rest-assured') {
exclude group: 'commons-logging'
exclude group: 'org.apache.sling' exclude group: 'org.apache.sling'
} }
testCompile ('org.springframework.boot:spring-boot-starter-test') { testCompile ('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'com.jayway.jsonpath', module: 'json-path' exclude group: 'com.jayway.jsonpath', module: 'json-path'
} }
testCompile ('org.mnode.ical4j:ical4j') {
exclude group: 'commons-logging'
}
} }
@@ -161,4 +161,4 @@ public class SchedulerJobHelper {
} }
} }
} }
} }
@@ -18,14 +18,15 @@
*/ */
package org.apache.fineract; package org.apache.fineract;
import java.io.IOException;
import org.apache.fineract.infrastructure.core.boot.AbstractApplicationConfiguration; import org.apache.fineract.infrastructure.core.boot.AbstractApplicationConfiguration;
import org.apache.fineract.infrastructure.core.boot.ApplicationExitUtil;
import org.apache.fineract.infrastructure.core.boot.EmbeddedTomcatWithSSLConfiguration; import org.apache.fineract.infrastructure.core.boot.EmbeddedTomcatWithSSLConfiguration;
import org.apache.fineract.infrastructure.core.boot.db.DataSourceConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.apache.fineract.infrastructure.core.boot.db.DataSourceProperties; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.SpringApplication; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;
/** /**
* Fineract main() application which launches Fineract in an embedded Tomcat HTTP * Fineract main() application which launches Fineract in an embedded Tomcat HTTP
@@ -40,17 +41,26 @@ import org.springframework.context.annotation.Import;
* *
* It's the old/classic Mifos (non-X) Workspace 2.0 reborn for Fineract! ;-) * It's the old/classic Mifos (non-X) Workspace 2.0 reborn for Fineract! ;-)
* *
* @see DataSourceProperties about how to configure the DataSource used
* @see ServerWithMariaDB4jApplication for an alternative with an embedded DB * @see ServerWithMariaDB4jApplication for an alternative with an embedded DB
*/ */
public class ServerApplication {
@Import({ DataSourceConfiguration.class, EmbeddedTomcatWithSSLConfiguration.class }) public class ServerApplication extends SpringBootServletInitializer {
@Import({ EmbeddedTomcatWithSSLConfiguration.class })
@ImportResource({ "classpath*:META-INF/spring/hikariDataSource.xml" })
private static class Configuration extends AbstractApplicationConfiguration { } private static class Configuration extends AbstractApplicationConfiguration { }
public static void main(String[] args) throws Exception { @Override
ConfigurableApplicationContext ctx = SpringApplication.run(Configuration.class, args); protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx); return builder.sources(Configuration.class);
} }
} private static SpringApplicationBuilder configureApplication(SpringApplicationBuilder builder) {
return builder.sources(Configuration.class);
}
public static void main(String[] args) throws IOException {
ConfigurableApplicationContext ctx = configureApplication(new SpringApplicationBuilder(ServerApplication.class)).run(args);
//ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx);
}
}
@@ -21,11 +21,11 @@ package org.apache.fineract.infrastructure.core.boot;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import org.apache.catalina.connector.Connector; import org.apache.catalina.connector.Connector;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.coyote.http11.Http11NioProtocol; import org.apache.coyote.http11.Http11NioProtocol;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
@@ -34,10 +34,10 @@ import org.springframework.core.io.Resource;
@Configuration @Configuration
public class EmbeddedTomcatWithSSLConfiguration { public class EmbeddedTomcatWithSSLConfiguration {
// http://docs.spring.io/spring-boot/docs/1.1.5.RELEASE/reference/htmlsingle/#howto-enable-multiple-connectors-in-tomcat // https://docs.spring.io/spring-boot/docs/2.2.6.RELEASE/reference/html/howto.html#howto-enable-multiple-connectors-in-tomcat
@Bean @Bean
public TomcatServletWebServerFactory servletContainer() { public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.setContextPath(getContextPath()); tomcat.setContextPath(getContextPath());
tomcat.addAdditionalTomcatConnectors(createSslConnector()); tomcat.addAdditionalTomcatConnectors(createSslConnector());
@@ -53,16 +53,12 @@ public class EmbeddedTomcatWithSSLConfiguration {
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler(); Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
try { try {
File keystore = getFile(getKeystore()); File keystore = getFile(getKeystore());
File truststore = keystore;
connector.setScheme("https"); connector.setScheme("https");
connector.setSecure(true); connector.setSecure(true);
connector.setPort(getHTTPSPort()); connector.setPort(getHTTPSPort());
protocol.setSSLEnabled(true); protocol.setSSLEnabled(true);
protocol.setKeystoreFile(keystore.getAbsolutePath()); protocol.setKeystoreFile(keystore.getAbsolutePath());
protocol.setKeystorePass(getKeystorePass()); protocol.setKeystorePass(getKeystorePass());
protocol.setTruststoreFile(truststore.getAbsolutePath());
protocol.setTruststorePass(getKeystorePass());
// ? protocol.setKeyAlias("apitester");
return connector; return connector;
} catch (IOException ex) { } catch (IOException ex) {
throw new IllegalStateException("can't access keystore: [" + "keystore" + "] or truststore: [" + "keystore" + "]", ex); throw new IllegalStateException("can't access keystore: [" + "keystore" + "] or truststore: [" + "keystore" + "]", ex);
@@ -1,53 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.core.boot;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ImportResource;
/**
* Required to still have a working legacy "classic" WAR.
*
* Configuration just adds the JNDI-based DataSource lookup to its
* AbstractApplicationConfiguration.
*
* This (intentionally) only configures the original (pre-Spring Boot &amp;
* MariaDB4j) fineract Spring Beans, and does NOT include the embedded Tomcat
* (incl. TomcatSSLConfiguration) nor the MariaDB4jSetupService or
* MariaDB4jDataSourceConfiguration, and not even the DataSourceConfiguration
* (as it uses "classic" JNDI) - we want the WAR to "work like before".
*
* @see <a
* href="http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-convert-an-existing-application-to-spring-boot">#howto-convert-an-existing-application-to-spring-boot</a>
*/
public class WarWebApplicationInitializer extends SpringBootServletInitializer {
@ImportResource({ "classpath*:META-INF/spring/hikariDataSource.xml" })
private static class Configuration extends AbstractApplicationConfiguration {
}
@Override
protected SpringApplicationBuilder configure(
SpringApplicationBuilder application) {
// let's share Spring Boot Love, so no showBanner(false)
return application.sources(Configuration.class);
}
}