Spring Boot Application immediately shuts down after starting in external TOMCAT - java

Spring boot immediately shuts down after starting in external TOMCAT. But in Eclipse this runs well and JAR with embed too.
I use Tomcat 7 and JAVA 8.
I read a lot of webs and documentation which do not exist.
My Eclipse POM is:
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.suez.demo</groupId>
<artifactId>Myapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Myappname</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<start-class>com.suez.demo.SuezApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.notnoop.apns</groupId>
<artifactId>apns</artifactId>
<version>1.0.0.Beta6</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.0.RELEASE</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generatePackage>com.suez.demo.ws</generatePackage>
<generateDirectory>${project.basedir}/src/main/java</generateDirectory>
<schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
<schemaIncludes>
<include>*.wsdl</include>
</schemaIncludes>
</configuration>
</plugin>
</plugins>
</build>
Tomcat output log last lines are:
2018-06-29 10:27:37.874 INFO 640 --- [ost-startStop-3] com.suez.demo.SuezApplication : Started SuezApplication in 29.104 seconds (JVM running for 91.714)
2018-06-29 10:27:37.905 INFO 640 --- [ost-startStop-3] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#75e8c829: startup date [Fri Jun 29 10:27:11 CEST 2018]; root of context hierarchy
2018-06-29 10:27:37.936 INFO 640 --- [ost-startStop-3] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2018-06-29 10:27:37.952 INFO 640 --- [ost-startStop-3] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
Can someone help me please?

It's hard to say out of the information you've provided, but what looks suspicious to me is that you're using spring-boot-starter-web which in turn brings tomcat starter transitively.
I see that the packaging of this module is WAR, so its intended to run in an external web container, but on the other hand, you say that it runs fine in "JAR with embed too".
So it's a little bit confusing.
I've never by myself deployed spring boot application as a WAR file, but I believe you can go to Start.spring.io and generate a sample application that will package itself into WAR. This option is not shown by default, so you'll have to click on "switch to the full version" link

Related

Spring Boot Database config wrong but starting ok

i have a problem with springboot, if i put wrong my datasource config (example bad password or user) my service start ok, launch the exception PostgresSQL FATAL .... bad password but not stop service. I try so much options but i can't see the problem.
My dependencies is: (i tried exclude for jdbc (tomcat) from starter-jpa).
My pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.14</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>foo.foo</groupId>
<artifactId>foo-server</artifactId>
<version>1.0.1-SNAPSHOT</version>
<name>fooSB</name>
<description>Foo Application Server</description>
<packaging>jar</packaging>
<properties>
<ignoreSnapshots>true</ignoreSnapshots>
<maven.javadoc.skip>true</maven.javadoc.skip>
<skipTests>true</skipTests>
<log4j2.version>2.17.1</log4j2.version>
<maven-javadoc-plugin-version>3.1.0</maven-javadoc-plugin-version>
<java.version>1.8</java.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<postgresql.version>42.4.1</postgresql.version>
<jdom2.version>2.0.6.1</jdom2.version>
<glassfish-el.version>3.0.4</glassfish-el.version>
<tomcat.version>9.0.58</tomcat.version>
<jackson-bom.version>2.13.2.1</jackson-bom.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<dependency>
<groupId>net.rakugakibox.spring.boot</groupId>
<artifactId>orika-spring-boot-starter</artifactId>
<version>1.8.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
</dependency>
<!-- Jasper -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.4.1</version>
<exclusions>
<exclusion>
<groupId>eclipse</groupId>
<artifactId>jdtcore</artifactId>
</exclusion>
<exclusion>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ar.com.fdvs</groupId>
<artifactId>DynamicJasper</artifactId>
<version>5.1.2</version>
<exclusions>
<exclusion>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
<dependency>
<groupId>javax.jws</groupId>
<artifactId>javax.jws-api</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<showDeprecation>${java.showDeprecation}</showDeprecation>
<showWarnings>${java.showWarnings}</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin-version}</version>
<configuration>
<detectJavaApiLink>false</detectJavaApiLink>
<source>8</source>
<encoding>${file-encoding}</encoding>
<docencoding>${file-encoding}</docencoding>
<overview>${basedir}/src/overview.html</overview>
</configuration>
<executions>
<execution>
<id>javadoc-jar</id>
<phase>install</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
#######################################################3
Properties:
########################
#------------START DB DATASOURCE PROPERTIES------------#
spring.datasource.url=jdbc:postgresql://localhost:5432/300-foo
spring.datasource.username=foo
spring.datasource.password=foo
spring.jpa.properties.hibernate.default_schema=public
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=none
spring.datasource.type = com.zaxxer.hikari.HikariDataSource
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
server.port=8088
server.http2.enabled=true
server.compression.enabled=true
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json,application/xml
server.compression.min-response-size=1B
server.tomcat.max-threads=200
server.tomcat.min-spare-threads=40
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.directory=/tmp/logs
server.tomcat.accesslog.pattern=%t %A %r %s - response bytes %b - time (ms) server process %D - time (ms) commit response %F
#------------START HIKARI ------------#
spring.datasource.hikari.connection-timeout=20000
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.idle-timeout=600000
spring.datasource.hikari.max-lifetime=1200000
spring.datasource.hikari.auto-commit=true
logging.level.com.zaxxer.hikari.HikariConfig=DEBUG
logging.level.com.zaxxer.hikari=TRACE
spring.datasource.validation-query=SELECT 1
spring.datasource.max-active=10
spring.datasource.max-idle=8
spring.datasource.min-idle=8
spring.datasource.initial-size=5
spring.datasource.test-on-borrow=true
spring.datasource.test-on-return=true
#-------------END HIKARI -------------#
#------------START SPRING DATA REST ------------#
spring.data.rest.detection-strategy=annotated
#-------------END SPRING DATA REST -------------#
#------------START JPA ------------#
spring.jpa.open-in-view=false
spring.jpa.show-sql=false
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=true
spring.jpa.hibernate.naming.physical-strategy = org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.hibernate.naming.implicit-strategy =org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
#-------------END JPA -------------#
#------------START LOGGING ------------#
logging.level.root=info
#logging.level.org.springframework.web: trace
#logging.level.org.apache: trace
#-------------END LOGGING -------------#
#------------START PID FILE ------------#
spring.pid.fail-on-write-error=true
spring.pid.file=FooApplication.pid
#-------------END PID FILE -------------#
#------------START ORIKA MAPPING PROPERTIES------------#
orika.mapNulls: false
#-------------END ORIKA MAPPING PROPERTIES-------------#
#---- DISABLE BANNER ----#
spring.main.banner-mode=off
#---- DISABLE BANNER ----#
Error launched when starting app (putting bad password)
Caused by: org.postgresql.util.PSQLException: FATAL: la autentificaci?n password fall? para el usuario ?foo?
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:646)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:180)
################################## the service finally started #######################################
11:02:13.237 INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Initialized JPA EntityManagerFactory for persistence unit 'default'
11:02:21.741 INFO o.s.b.d.a.OptionalLiveReloadServer - LiveReload server is running on port 35729
11:02:21.802 INFO o.a.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8082"]
11:02:21.834 INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 8082 (http) with context path ''
11:02:21.850 INFO n.t.c.view.FooServicesApplication - Started FooServicesApplication in 40.316 seconds (JVM running for 41.48)
To get the expected behavior, i create a bean that launched request (findAll) for one litle table. This bean have #PostConstruct and if BBDD return error my app will be stop.
Example:
#Component
public class DataBaseCheck {
#Autowired
private FooRepository fooRepository;
#Autowired
private ApplicationContext applicationContext;
private Logger log = LoggerFactory.getLogger(DataBaseCheck.class);
#PostConstruct
public void checkCorrectStatusDataBase() {
try {
log.info("We go check database connection...");
//call findAll from a little table - recommended one table with not more 10 elements.
fooRepository.findAll();
log.info("Checked correct database access");
}
} catch (Exception e) {
log.error("Error found trying connect database, please check your configuration.", e);
int exitCode = SpringApplication.exit(applicationContext, () -> 1);
System.exit(exitCode);
}
}
}

Camel FileConsumer does not handle Exchange but recognizes file

I have a spring-boot-application standalone application which uses apache camel to consume a single file, convert it and send the contents to a rest endpoint.
The current working setup
The pom.xml looks like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.thehandofnod</groupId>
<artifactId>recommenderclient</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>recommenderclient</name>
<description>Client application which communicates with the different Recommender</description>
<properties>
<java.version>1.8</java.version>
<camel-spring-boot-starter-version>2.25.2</camel-spring-boot-starter-version>
<camel-bindy-version>2.25.2</camel-bindy-version>
<camel-jackson-starter-version>2.25.2</camel-jackson-starter-version>
<camel-http-starter-version>2.25.2</camel-http-starter-version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>${camel-spring-boot-starter-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.camel/camel-bindy-starter -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-bindy-starter</artifactId>
<version>${camel-bindy-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.camel/camel-jackson-starter -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson-starter</artifactId>
<version>${camel-jackson-starter-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.camel/camel-jetty-starter -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http-starter</artifactId>
<version>${camel-http-starter-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!-- DB dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>jcc</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-webtestclient</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce</id>
<configuration>
<rules>
<dependencyConvergence/>
</rules>
</configuration>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.8</version>
<executions>
<execution>
<id>generate-docs</id>
<phase>prepare-package</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>html</backend>
<doctype>book</doctype>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-asciidoctor</artifactId>
<version>${spring-restdocs.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
As you can see I currently use the dependency spring-boot-starter-web to keep the application and therefore the camel routes running. I do this because otherwise the FileConsumer just recognizes the file, creates the exchange but does not route it to the endpoint for processing. That's where my question starts.
The problem
If I don't use the dependency spring-boot-starter-web but want my standalone application to run just only once the routes are just started and shutdown without doing anything (see 'The wished setup')
The problem seems to be that the method ScheduledBatchPollingConsumer#isBatchAllowed sometimes returns false and sometimes returns true. I can't figure out why but to me it seems a timing problem because if I have luck the file is consumed and processed and if I don't have luck the Exchange is not processed.
The wished setup
So I don't want to use the spring-boot-starter-web dependency and I don't want to keep the application running. This should be my wished configuration:
application.properties
camel.component.properties.encoding=UTF-8
# general spring-boot settings
#camel.springboot.main-run-controller=true
#camel.springboot.name=Recommender
# I don't want to keep it running! Shutdown after file was processed is what I wish for.
#camel.springboot.endpoint-bridge-error-handler=true
#camel.springboot.log-mask=true
# common attributes
projectID=2
# customer data route & properties
customerdata.from=file:D:\\projects\\TMP\\RecommenderClientTests\\source?fileName=CUSTOMER_DATA.csv&move=\..\processed&initialDelay=2000&delay=1000
customerdata.to=direct:TransmitCustomerData
# transmit customer data route & properties
transmitcustomerdata.from=direct:TransmitCustomerData
#transmitcustomerdata.to=file:D:\\projects\\TMP\\Camel\\to\\customer? tempFileName=CustomerRequest_tmp.txt&fileName=Customer.json
transmitcustomerdata.to=http://u086:9002/prioritizer/project/customer/transmit?\
bridgeEndpoint=false&\
throwExceptionOnFailure=false&\
httpMethod=POST
transmitcustomerdata.append=false
# archive
archiv=file:D:\\projects\\TMP\\RecommenderClientTests\\archiv? fileName=$simple{exchangeId}-$simple{date:now:yyyyMMddHHmm}&fileExist=Append
The question
How can I configure the file endpoint so that the file is always consumed and processed and the routes are shutdown afterwards?
There are options you can configure to shutdown after N messages processed, or being idel for more than N seconds, or after N time etc.
For example
camel.springboot.duration-max-messages = 1
See more at the docs: https://camel.apache.org/camel-spring-boot/latest/spring-boot.html

Azure spring boot deployment - container problem

I have a problem with my spring boot deployment on azure. I followed the steps on
microsoft docs and i was able to start my webservice locally.
I also deployed the example of microsoft and used my mysql database which is also hosted on azure and had no problems.
I also set the application setting WEBSITES_CONTAINER_START_TIME_LIMIT on maximum.
Here is my pom.xml
<groupId>groupId</groupId>
<artifactId>billSharingWebservice</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.0.6.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<version>5.1.1.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.6.RELEASE</version>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<deploymentType>jar</deploymentType>
<!-- Web App information -->
<resourceGroup>billSharing</resourceGroup>
<appName>billsharing</appName>
<region>westeurope</region>
<!-- Java Runtime Stack for Web App on Linux-->
<linuxRuntime>jre8</linuxRuntime>
</configuration>
</plugin>
</plugins>
</build>
After deployment on azure i got the following logs:
2018-10-25 16:09:22.956 INFO - Starting container for site
2018-10-25 16:09:22.958 INFO - docker run -d -p 43892:8443 --name billsharing_0 -e PORT=8443 -e WEBSITE_SITE_NAME=billsharing -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_INSTANCE_ID=96d743e51352785f93233abee2c7fb3857cba42475b37377d206d1fee114218f -e HTTP_LOGGING_ENABLED=1 appsvc/java:8-jre8_0000000000
2018-10-25 16:10:26.869 ERROR - Container billsharing_0 for site billsharing has exited, failing site start
Which isn't really helpfully.
Maybe someone has an idea to help me
Thanks.
I used your pom.xml and set WEBSITES_CONTAINER_START_TIME_LIMIT to 1800, the log stream didn't show "Container XXX for XXX initialized successfully" and the site showed unavailable service.
Then I tried the pom.xml Microsoft recommending and it worked fine.So maybe you could try my settings. Here is my pom.xml:
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- servlet dependency. -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- tomcat support.-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<deploymentType>jar</deploymentType>
<!-- configure app to run on port 80, required by App Service -->
<appSettings>
<property>
<name>JAVA_OPTS</name>
<value>-Dserver.port=80</value>
</property>
</appSettings>
<!-- Web App information -->
<resourceGroup>myStorageGroup</resourceGroup>
<appName>mvntest03</appName>
<region>eastus</region>
<!-- Java Runtime Stack for Web App on Linux-->
<linuxRuntime>jre8</linuxRuntime>
</configuration>
</plugin>
</plugins>
</build>
And here is my log stream page.
If you also have other settings or still have questions ,please let me know.

Migrated Spring boot 1.5 to 2.0, unable to start app getting: java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver

I upgraded my existing working Spring Boot application, from springboot 1.5 to 2.0.
Now, I am getting below error message, when I try to deploy the application.
Please help.
Note: I don't have #ComponentScan, instead I am using #SpringBootApplication at root package in my application. Also, I am using the latest version of apache camel springboot dependencies.
Also, if I remove the below dependency, the application deploys fine, but ofcourse, without Apache Camel router initialized!
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>2.20.2</version>
</dependency>
How I did update: Changed the springboot version in pom.xml
Tool used: STS (Spring Tool Suite)
14-03-2018 11:51:27.972-main-ERROR-SpringApplication - Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.test.MyTestApp]; nested exception is java.lang.IllegalStateException: Could not evaluate condition on org.apache.camel.spring.boot.health.HealthCheckRoutesAutoConfiguration due to org/springframework/boot/bind/RelaxedPropertyResolver not found. Make sure your own configuration does not rely on that class. This can also happen if you are #ComponentScanning a springframework package (e.g. if you put a #ComponentScan in the default package by mistake)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:616)
at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:548)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
at com.test.MyTestApp.main(MyTestApp.java:27)
Caused by: java.lang.IllegalStateException: Could not evaluate condition on org.apache.camel.spring.boot.health.HealthCheckRoutesAutoConfiguration due to org/springframework/boot/bind/RelaxedPropertyResolver not found. Make sure your own configuration does not rely on that class. This can also happen if you are #ComponentScanning a springframework package (e.g. if you put a #ComponentScan in the default package by mistake)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:55)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:109)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:217)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:606)
... 15 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver
at org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator.isEnabled(HierarchicalPropertiesEvaluator.java:49)
at org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator.evaluate(HierarchicalPropertiesEvaluator.java:42)
at org.apache.camel.spring.boot.util.GroupCondition.getMatchOutcome(GroupCondition.java:40)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
... 18 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 22 common frames omitted
Contents of pom.xml below:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>my-application</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>my-application</name>
<description>TEST Application</description>
<!-- Spring 1.5 to 2.0 Migration -->
<!-- <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version> <relativePath /> lookup parent from repository
</parent> -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
<version>0.0.20131108.vaadin1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>2.20.2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jaxb</artifactId>
<version>2.20.2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring</artifactId>
<version>2.20.2</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
</dependency>
<!-- Spring 1.5 to 2.0 Migration -->
<!-- <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId>
</dependency> -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.activation/activation -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.mail/mail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-java-sources</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>./src/main/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<finalName>test-app</finalName>
</build>
</project>
Got this resolved.The Apache Camel 2.20.2 is supported for spring boot 1.5 only. As per Apache Camel website, they will extend support to spring boot starting with 2.22 (early summers 2018). So to resolve, just need to use spring boot 1.5.10 only for now. Thanks all for checking / responding.
Reference Links: http://camel.apache.org/camel-2210-release.html
"This release supports only Spring Boot 1.5.x. Support for Spring Boot 2.0.x is coming in Camel version 2.22 which is planned for early summer 2018."
P.S. At http://start.spring.io/ (Switch to the full version) you can check if a Spring Project(Apache Camel) is compatible with your Spring Boot version. Currently the Initilizer shows
Apache Camel
Integration using Apache Camel
requires Spring Boot >=1.4.0.RELEASE and <2.0.0.M1

Spring Boot maven project from Eclipse doesn't work in Intellij

I have working spring boot maven project created in eclipse. Then i import its to Intellij Ultimate, everything goes fine, click run and:
and after this i have errors:
2017-02-15 12:46:58.459 ERROR 6020 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration due to javax/servlet/Filter not found. Make sure your own configuration does not rely on that class. This can also happen if you are #ComponentScanning a springframework package (e.g. if you put a #ComponentScan in the default package by mistake)
....
2017-02-15 12:46:58.478 ERROR 6020 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.context.annotation.AnnotationConfigApplicationContext#2f6c79e1: startup date [Wed Feb 15 12:46:56 CET 2017]; root of context hierarchy
Where is the problem ?
My POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 `http://maven.apache.org/xsd/maven-4.0.0.xsd">`
<modelVersion>4.0.0</modelVersion>
<groupId>com.twistezo</groupId>
<artifactId>StickyNotes</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>StickyNotes</name>
<description>StickyNotes SpringBoot app</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Starter class
#SpringBootApplication
public class StickyNotesApplication {
public static void main(String[] args) {
SpringApplication.run(StickyNotesApplication.class, args);
}
}
There is a known issue with IntelliJ IDEA Maven support and provided dependencies.
A workaround for your problem would be to change spring-boot-starter-tomcat dependency scope from provided to compile.
See also a related discussion for a similar case, but with a different dependency.

Categories