Spring Docker Container stops because it tries to connect to localhost MongoDB even though it already connects correctly to MongoDB Container - spring

Edit: The solution is as described by Valijon. But in addition, the following line was missing before my first insert in the DemoApplication.java:
MongoOperations mongoOps = new MongoTemplate(new SimpleMongoClientDbFactory(new ConnectionString("mongodb://docker_mongo:27017/db")));
so I wrote a very basic Spring application that is supposed to connect to a MongoDB, store some data, retrieve it and print some stuff for testing purposes.
For that purpose, I use docker-compose up to create a container "docker_mongo" and one called "docker_spring".
Now the connection to the Mongo container is actually successfull (see logs), but after that, the Spring container tries to establish another connection to a standard MongoDB on localhost:27017. And that then fails which leads to the container to exit with code 1.
I also edited my application.properties (see below).
I guess it has something to do with Spring Mongo autoconfiguration and I already tried to deactivate it as described in this post: Mongo tries to connect automatically to port 27017(localhost).
However, deactivating the autoconfiguration leads to other errors that I have no idea how to solve right now (I guess I have to refactor the way I connect to the MongoDB in my Spring application and I did not find simple enough tutorials on the internet that tells me how to do that without using the autoconfig features).
I am really a beginner when it comes to coding, so sorry when the question is of poor quality or a duplicate <3 (I googled quite some hours until now though...)
I feel like the solution is really simple, but I just found no article that covers exactly my issue :'(
application.properties:
spring.data.mongodb.host=mongo
spring.data.mongodb.port=27017
spring.data.mongodb.database=db
spring.data.mongodb.uri=mongodb://docker_mongo:27017/db
Dockerfile:
FROM openjdk:11
VOLUME /tmp
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} /tmp/app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/tmp/app.jar"]
RUN echo "hello world"
docker-compose.yaml:
version: '3.1'
services:
mongo:
container_name: docker_mongo
networks:
- gateway
ports:
- "27017:27017"
hostname: mongo
image: mongo:latest
command: mongod --port 27017
volumes:
- ./data/db:/data/db
spring:
build: .
container_name: docker_spring
networks:
- gateway
ports:
- "8080:8080"
hostname: spring
depends_on:
- mongo
networks:
gateway:
driver: "bridge"
DemoApplication.java that is being called by the main (I outsourced that into a separate class):
package com.example.demo;
import com.example.model.Expenditure;
import com.mongodb.client.MongoClients;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.SimpleMongoClientDbFactory;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import java.time.LocalDate;
/*
#SpringBootApplication(exclude={
MongoAutoConfiguration.class,
MongoDataAutoConfiguration.class
})
*/
#SpringBootApplication
#ComponentScan({"com.example.client","com.example.demo","com.example.model"})
public class DemoApplication implements CommandLineRunner {
#Autowired
private ExpenditureRepository repository;
#Override
public void run(String... args) throws Exception {
MongoOperations mongoOps = new MongoTemplate(new SimpleMongoClientDbFactory(MongoClients.create(), "db"));
mongoOps.insert(new Expenditure("Aldi",10.01, LocalDate.parse("2019-10-05")));
System.out.println(mongoOps.findOne(new Query(Criteria.where("name").is("Aldi")),Expenditure.class));
mongoOps.dropCollection("expenditure");
PopulateExpenditureDB.populateExpenditures(mongoOps);
}
}
MongoDbFactory.java:
package com.example.demo;
import com.mongodb.client.MongoDatabase;
import org.springframework.dao.DataAccessException;
public interface MongoDbFactory {
MongoDatabase getDb() throws DataAccessException;
MongoDatabase getDb(String dbName) throws DataAccessException;
}
ExpenditureRepository.java:
package com.example.demo;
import com.example.model.Expenditure;
import java.time.LocalDate;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
//mongodb Host & Port defined in application.properties
public interface ExpenditureRepository extends MongoRepository<Expenditure, String> {
/*
public void create(Expenditure expenditure) {
if(expenditure.)
}
public Expenditure findById(int id) {
return data.get(id)
}
*/
public Expenditure findByName (String name);
public List<Expenditure> findByExDate (LocalDate exDate);
}
Docker logs:
~/new_Webapp$ sudo docker-compose up
Creating network "newwebapp_gateway" with driver "bridge"
Building spring
Step 1/6 : FROM openjdk:11
---> 612d4d483eee
Step 2/6 : VOLUME /tmp
---> Running in 3aff2f893162
Removing intermediate container 3aff2f893162
---> 2bf19d4c67b1
Step 3/6 : ARG JAR_FILE=target/*.jar
---> Running in b7c3782bbc1a
Removing intermediate container b7c3782bbc1a
---> b029607db12b
Step 4/6 : COPY ${JAR_FILE} /tmp/app.jar
---> f3168bc17ae3
Step 5/6 : ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/tmp/app.jar"]
---> Running in f729f7204cdd
Removing intermediate container f729f7204cdd
---> aceb4c1a0bda
Step 6/6 : RUN echo "hello world"
---> Running in d4ab9bb0f498
hello world
Removing intermediate container d4ab9bb0f498
---> 45ae63ef2bd1
Successfully built 45ae63ef2bd1
Successfully tagged newwebapp_spring:latest
WARNING: Image for service spring was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating docker_mongo ...
Creating docker_mongo ... done
Creating docker_spring ...
Creating docker_spring ... done
Attaching to docker_mongo, docker_spring
docker_mongo | 2020-02-07T14:45:26.462+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
docker_mongo | 2020-02-07T14:45:26.464+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=mongo
docker_mongo | 2020-02-07T14:45:26.464+0000 I CONTROL [initandlisten] db version v4.2.2
docker_mongo | 2020-02-07T14:45:26.464+0000 I CONTROL [initandlisten] git version: a0bbbff6ada159e19298d37946ac8dc4b497eadf
docker_mongo | 2020-02-07T14:45:26.464+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
docker_mongo | 2020-02-07T14:45:26.464+0000 I CONTROL [initandlisten] allocator: tcmalloc
docker_mongo | 2020-02-07T14:45:26.464+0000 I CONTROL [initandlisten] modules: none
docker_mongo | 2020-02-07T14:45:26.464+0000 I CONTROL [initandlisten] build environment:
docker_mongo | 2020-02-07T14:45:26.464+0000 I CONTROL [initandlisten] distmod: ubuntu1804
docker_mongo | 2020-02-07T14:45:26.464+0000 I CONTROL [initandlisten] distarch: x86_64
docker_mongo | 2020-02-07T14:45:26.464+0000 I CONTROL [initandlisten] target_arch: x86_64
docker_mongo | 2020-02-07T14:45:26.464+0000 I CONTROL [initandlisten] options: { net: { bindIp: "*", port: 27017 } }
docker_mongo | 2020-02-07T14:45:26.464+0000 I STORAGE [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
docker_mongo | 2020-02-07T14:45:26.464+0000 I STORAGE [initandlisten]
docker_mongo | 2020-02-07T14:45:26.464+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
docker_mongo | 2020-02-07T14:45:26.464+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
docker_mongo | 2020-02-07T14:45:26.464+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7471M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
docker_mongo | 2020-02-07T14:45:26.877+0000 I STORAGE [initandlisten] WiredTiger message [1581086726:877548][1:0x7ff0c5201b00], txn-recover: Recovering log 36 through 37
docker_mongo | 2020-02-07T14:45:26.904+0000 I STORAGE [initandlisten] WiredTiger message [1581086726:904522][1:0x7ff0c5201b00], txn-recover: Recovering log 37 through 37
docker_mongo | 2020-02-07T14:45:26.950+0000 I STORAGE [initandlisten] WiredTiger message [1581086726:950147][1:0x7ff0c5201b00], txn-recover: Main recovery loop: starting at 36/5888 to 37/256
docker_mongo | 2020-02-07T14:45:27.008+0000 I STORAGE [initandlisten] WiredTiger message [1581086727:8723][1:0x7ff0c5201b00], txn-recover: Recovering log 36 through 37
docker_mongo | 2020-02-07T14:45:27.044+0000 I STORAGE [initandlisten] WiredTiger message [1581086727:44798][1:0x7ff0c5201b00], txn-recover: Recovering log 37 through 37
docker_mongo | 2020-02-07T14:45:27.075+0000 I STORAGE [initandlisten] WiredTiger message [1581086727:75209][1:0x7ff0c5201b00], txn-recover: Set global recovery timestamp: (0,0)
docker_mongo | 2020-02-07T14:45:27.102+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
docker_mongo | 2020-02-07T14:45:27.106+0000 I STORAGE [initandlisten] Timestamp monitor starting
docker_mongo | 2020-02-07T14:45:27.109+0000 I CONTROL [initandlisten]
docker_mongo | 2020-02-07T14:45:27.110+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
docker_mongo | 2020-02-07T14:45:27.110+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
docker_mongo | 2020-02-07T14:45:27.110+0000 I CONTROL [initandlisten]
docker_mongo | 2020-02-07T14:45:27.112+0000 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
docker_mongo | 2020-02-07T14:45:27.114+0000 I STORAGE [initandlisten] Flow Control is enabled on this deployment.
docker_mongo | 2020-02-07T14:45:27.114+0000 I SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
docker_mongo | 2020-02-07T14:45:27.114+0000 I SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
docker_mongo | 2020-02-07T14:45:27.116+0000 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
docker_mongo | 2020-02-07T14:45:27.116+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
docker_mongo | 2020-02-07T14:45:27.118+0000 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
docker_mongo | 2020-02-07T14:45:27.118+0000 I NETWORK [initandlisten] Listening on /tmp/mongodb-27017.sock
docker_mongo | 2020-02-07T14:45:27.118+0000 I NETWORK [initandlisten] Listening on 0.0.0.0
docker_mongo | 2020-02-07T14:45:27.118+0000 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
docker_mongo | 2020-02-07T14:45:27.118+0000 I NETWORK [initandlisten] waiting for connections on port 27017
docker_spring |
docker_spring | . ____ _ __ _ _
docker_spring | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
docker_spring | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
docker_spring | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
docker_spring | ' |____| .__|_| |_|_| |_\__, | / / / /
docker_spring | =========|_|==============|___/=/_/_/_/
docker_spring | :: Spring Boot :: (v2.2.1.RELEASE)
docker_spring |
docker_spring | 2020-02-07 14:45:27.552 INFO 1 --- [ main] com.example.demo.MainClass : Starting MainClass v0.0.1-SNAPSHOT on spring with PID 1 (/tmp/app.jar started by root in /)
docker_spring | 2020-02-07 14:45:27.556 INFO 1 --- [ main] com.example.demo.MainClass : No active profile set, falling back to default profiles: default
docker_spring | 2020-02-07 14:45:27.950 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
docker_spring | 2020-02-07 14:45:27.992 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 38ms. Found 1 repository interfaces.
docker_mongo | 2020-02-07T14:45:28.000+0000 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>
docker_spring | 2020-02-07 14:45:28.364 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
docker_spring | 2020-02-07 14:45:28.372 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
docker_spring | 2020-02-07 14:45:28.372 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.27]
docker_spring | 2020-02-07 14:45:28.425 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
docker_spring | 2020-02-07 14:45:28.426 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 822 ms
docker_spring | 2020-02-07 14:45:28.616 INFO 1 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[docker_mongo:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
docker_mongo | 2020-02-07T14:45:28.643+0000 I NETWORK [listener] connection accepted from 192.168.0.3:53260 #1 (1 connection now open)
docker_mongo | 2020-02-07T14:45:28.649+0000 I NETWORK [conn1] received client metadata from 192.168.0.3:53260 conn1: { driver: { name: "mongo-java-driver|legacy", version: "3.11.2" }, os: { type: "Linux", name: "Linux", architecture: "amd64", version: "5.3.0-28-generic" }, platform: "Java/Oracle Corporation/11.0.6+10" }
docker_spring | 2020-02-07 14:45:28.659 INFO 1 --- [ker_mongo:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:1}] to docker_mongo:27017
docker_spring | 2020-02-07 14:45:28.663 INFO 1 --- [ker_mongo:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=docker_mongo:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 2, 2]}, minWireVersion=0, maxWireVersion=8, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=2669943}
docker_spring | 2020-02-07 14:45:28.703 WARN 1 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
docker_spring | 2020-02-07 14:45:28.703 WARN 1 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
docker_spring | 2020-02-07 14:45:28.717 WARN 1 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
docker_spring | 2020-02-07 14:45:28.717 WARN 1 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
docker_spring | 2020-02-07 14:45:28.951 INFO 1 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
docker_spring | 2020-02-07 14:45:29.076 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
docker_spring | 2020-02-07 14:45:29.078 INFO 1 --- [ main] com.example.demo.MainClass : Started MainClass in 1.787 seconds (JVM running for 2.142)
docker_spring | 2020-02-07 14:45:29.081 INFO 1 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
docker_spring | 2020-02-07 14:45:29.083 WARN 1 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
docker_spring | 2020-02-07 14:45:29.083 WARN 1 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
docker_spring | 2020-02-07 14:45:29.085 WARN 1 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.LocalDateTime to class java.time.Instant as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
docker_spring | 2020-02-07 14:45:29.085 WARN 1 --- [ main] o.s.data.convert.CustomConversions : Registering converter from class java.time.Instant to class java.time.LocalDateTime as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
docker_spring | 2020-02-07 14:45:29.086 INFO 1 --- [localhost:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server localhost:27017
docker_spring |
docker_spring | com.mongodb.MongoSocketOpenException: Exception opening socket
docker_spring | at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70) ~[mongodb-driver-core-3.11.2.jar!/:na]
docker_spring | at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:128) ~[mongodb-driver-core-3.11.2.jar!/:na]
docker_spring | at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.11.2.jar!/:na]
docker_spring | at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
docker_spring | Caused by: java.net.ConnectException: Connection refused (Connection refused)
docker_spring | at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:na]
docker_spring | at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) ~[na:na]
docker_spring | at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242) ~[na:na]
docker_spring | at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224) ~[na:na]
docker_spring | at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403) ~[na:na]
docker_spring | at java.base/java.net.Socket.connect(Socket.java:609) ~[na:na]
docker_spring | at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:64) ~[mongodb-driver-core-3.11.2.jar!/:na]
docker_spring | at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:79) ~[mongodb-driver-core-3.11.2.jar!/:na]
docker_spring | at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65) ~[mongodb-driver-core-3.11.2.jar!/:na]
docker_spring | ... 3 common frames omitted
docker_spring |
docker_spring | 2020-02-07 14:45:29.119 INFO 1 --- [ main] org.mongodb.driver.cluster : Cluster description not yet available. Waiting for 30000 ms before timing out
docker_spring | 2020-02-07 14:45:59.125 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener :
docker_spring |
docker_spring | Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
docker_spring | 2020-02-07 14:45:59.131 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed
docker_spring |
docker_spring | java.lang.IllegalStateException: Failed to execute CommandLineRunner
docker_spring | at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:787) ~[spring-boot-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:768) ~[spring-boot-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) ~[spring-boot-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at com.example.demo.MainClass.main(MainClass.java:8) ~[classes!/:0.0.1-SNAPSHOT]
docker_spring | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
docker_spring | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
docker_spring | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
docker_spring | at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
docker_spring | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) ~[app.jar:0.0.1-SNAPSHOT]
docker_spring | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) ~[app.jar:0.0.1-SNAPSHOT]
docker_spring | at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) ~[app.jar:0.0.1-SNAPSHOT]
docker_spring | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) ~[app.jar:0.0.1-SNAPSHOT]
docker_spring | Caused by: org.springframework.dao.DataAccessResourceFailureException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]
docker_spring | at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:90) ~[spring-data-mongodb-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2902) ~[spring-data-mongodb-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:587) ~[spring-data-mongodb-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at org.springframework.data.mongodb.core.MongoTemplate.insertDocument(MongoTemplate.java:1494) ~[spring-data-mongodb-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at org.springframework.data.mongodb.core.MongoTemplate.doInsert(MongoTemplate.java:1294) ~[spring-data-mongodb-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:1226) ~[spring-data-mongodb-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:1211) ~[spring-data-mongodb-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at com.example.demo.DemoApplication.run(DemoApplication.java:40) ~[classes!/:0.0.1-SNAPSHOT]
docker_spring | at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:784) ~[spring-boot-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | ... 13 common frames omitted
docker_spring | Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]
docker_spring | at com.mongodb.internal.connection.BaseCluster.getDescription(BaseCluster.java:182) ~[mongodb-driver-core-3.11.2.jar!/:na]
docker_spring | at com.mongodb.internal.connection.SingleServerCluster.getDescription(SingleServerCluster.java:41) ~[mongodb-driver-core-3.11.2.jar!/:na]
docker_spring | at com.mongodb.client.internal.MongoClientDelegate.getConnectedClusterDescription(MongoClientDelegate.java:145) ~[mongodb-driver-3.11.2.jar!/:na]
docker_spring | at com.mongodb.client.internal.MongoClientDelegate.createClientSession(MongoClientDelegate.java:100) ~[mongodb-driver-3.11.2.jar!/:na]
docker_spring | at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.getClientSession(MongoClientDelegate.java:277) ~[mongodb-driver-3.11.2.jar!/:na]
docker_spring | at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:201) ~[mongodb-driver-3.11.2.jar!/:na]
docker_spring | at com.mongodb.client.internal.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:1048) ~[mongodb-driver-3.11.2.jar!/:na]
docker_spring | at com.mongodb.client.internal.MongoCollectionImpl.executeInsertOne(MongoCollectionImpl.java:498) ~[mongodb-driver-3.11.2.jar!/:na]
docker_spring | at com.mongodb.client.internal.MongoCollectionImpl.insertOne(MongoCollectionImpl.java:482) ~[mongodb-driver-3.11.2.jar!/:na]
docker_spring | at com.mongodb.client.internal.MongoCollectionImpl.insertOne(MongoCollectionImpl.java:476) ~[mongodb-driver-3.11.2.jar!/:na]
docker_spring | at org.springframework.data.mongodb.core.MongoTemplate.lambda$insertDocument$16(MongoTemplate.java:1500) ~[spring-data-mongodb-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:585) ~[spring-data-mongodb-2.2.1.RELEASE.jar!/:2.2.1.RELEASE]
docker_spring | ... 19 common frames omitted
docker_spring |
docker_spring | 2020-02-07 14:45:59.140 INFO 1 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
docker_mongo | 2020-02-07T14:45:59.146+0000 I NETWORK [conn1] end connection 192.168.0.3:53260 (0 connections now open)
docker_spring exited with code 1

It's very simple
MongoClients.create() without any parameters to connect to a MongoDB instance running on localhost on port 27017.
https://mongodb.github.io/mongo-java-driver/3.4/driver-async/tutorials/connect-to-mongodb/#connect-to-a-standalone-mongodb-instance
Spring Boot already connected to MongoDB
docker_spring | 2020-02-07 14:45:28.616 INFO 1 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[docker_mongo:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
docker_mongo | 2020-02-07T14:45:28.643+0000 I NETWORK [listener] connection accepted from 192.168.0.3:53260 #1 (1 connection now open)
docker_mongo | 2020-02-07T14:45:28.649+0000 I NETWORK [conn1] received client metadata from 192.168.0.3:53260 conn1: { driver: { name: "mongo-java-driver|legacy", version: "3.11.2" }, os: { type: "Linux", name: "Linux", architecture: "amd64", version: "5.3.0-28-generic" }, platform: "Java/Oracle Corporation/11.0.6+10" }
docker_spring | 2020-02-07 14:45:28.659 INFO 1 --- [ker_mongo:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:1}] to docker_mongo:27017
docker_spring | 2020-02-07 14:45:28.663 INFO 1 --- [ker_mongo:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=docker_mongo:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 2, 2]}, minWireVersion=0, maxWireVersion=8, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=2669943}
Change to this:
#SpringBootApplication
#ComponentScan({"com.example.client","com.example.demo","com.example.model"})
public class DemoApplication implements CommandLineRunner {
#Autowired
private MongoOperations mongoOps;
#Override
public void run(String... args) throws Exception {
mongoOps.insert(new Expenditure("Aldi",10.01, LocalDate.parse("2019-10-05")));
System.out.println(mongoOps.findOne(new Query(Criteria.where("name").is("Aldi")),Expenditure.class));
mongoOps.dropCollection("expenditure");
PopulateExpenditureDB.populateExpenditures(mongoOps);
}
}

Related

Running Spring Boot Native Application on Azure Functions: Permission denied with server.port: 80

I have created a simple Spring Boot Application and compiled it with Spring Native gradle bootBuildImage. I uploaded the docker container to an private registry and deployed it to Microsoft Azure Function. Accessing the function will correctly start the Spring Boot Application inside the docker container. But it crashes with following exception:
2021-11-09T15:46:55.996267267Z 2021-11-09 15:46:55.996 INFO 1 --- [ main] o.s.nativex.NativeListener : This application is bootstrapped with code generated with Spring AOT
2021-11-09T15:46:55.997230973Z
2021-11-09T15:46:55.997396574Z . ____ _ __ _ _
2021-11-09T15:46:55.997539875Z /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
2021-11-09T15:46:55.997679976Z ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2021-11-09T15:46:55.997816777Z \\/ ___)| |_)| | | | | || (_| | ) ) ) )
2021-11-09T15:46:55.997979078Z ' |____| .__|_| |_|_| |_\__, | / / / /
2021-11-09T15:46:55.998114779Z =========|_|==============|___/=/_/_/_/
2021-11-09T15:46:55.999546489Z :: Spring Boot :: (v2.5.6)
2021-11-09T15:46:55.999559889Z
2021-11-09T15:46:56.065075944Z 2021-11-09 15:46:56.054 INFO 1 --- [ main] o.s.boot.SpringApplication : Starting application using Java 11.0.13 on 421026966d15 with PID 1 (started by cnb in /workspace)
2021-11-09T15:46:56.065102544Z 2021-11-09 15:46:56.056 INFO 1 --- [ main] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default
2021-11-09T15:46:56.095177553Z 2021-11-09 15:46:56.094 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-11-09T15:46:56.097067866Z 2021-11-09 15:46:56.096 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 1 ms. Found 1 JPA repository interfaces.
2021-11-09T15:46:56.147529016Z 2021-11-09 15:46:56.147 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 80 (http)
2021-11-09T15:46:56.148811625Z 2021-11-09 15:46:56.148 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-11-09T15:46:56.149445829Z 2021-11-09 15:46:56.148 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.54]
2021-11-09T15:46:56.154613565Z 2021-11-09 15:46:56.154 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-11-09T15:46:56.155352670Z 2021-11-09 15:46:56.154 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 95 ms
2021-11-09T15:46:56.177839326Z 2021-11-09 15:46:56.177 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-11-09T15:46:56.179695539Z 2021-11-09 15:46:56.179 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-11-09T15:46:56.181115849Z 2021-11-09 15:46:56.180 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-11-09T15:46:56.183164263Z 2021-11-09 15:46:56.182 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-11-09T15:46:56.533544294Z 2021-11-09 15:46:56.533 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-11-09T15:46:56.534665902Z 2021-11-09 15:46:56.533 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2021-11-09T15:46:56.675326478Z 2021-11-09 15:46:56.675 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-11-09T15:46:56.676515986Z 2021-11-09 15:46:56.676 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-11-09T15:46:56.722262803Z 2021-11-09 15:46:56.722 WARN 1 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-11-09T15:46:56.746931074Z 2021-11-09 15:46:56.746 WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
2021-11-09T15:46:56.749313091Z 2021-11-09 15:46:56.749 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-11-09T15:46:56.750124797Z 2021-11-09 15:46:56.749 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2021-11-09T15:46:56.877499580Z 2021-11-09 15:46:56.877 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2021-11-09T15:46:56.878593388Z 2021-11-09 15:46:56.877 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-11-09T15:46:56.888123954Z 2021-11-09 15:46:56.880 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener :
2021-11-09T15:46:56.888151454Z
2021-11-09T15:46:56.888156354Z Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-11-09T15:46:56.888160554Z 2021-11-09 15:46:56.880 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed
2021-11-09T15:46:56.888164954Z
2021-11-09T15:46:56.888168654Z org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
2021-11-09T15:46:56.888172954Z at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[de.aditu.buchschrank.BuchschrankApplicationKt:5.3.12]
2021-11-09T15:46:56.888177354Z at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[de.aditu.buchschrank.BuchschrankApplicationKt:5.3.12]
2021-11-09T15:46:56.888181254Z at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[na:na]
2021-11-09T15:46:56.888196454Z at java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
2021-11-09T15:46:56.888200454Z at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[de.aditu.buchschrank.BuchschrankApplicationKt:5.3.12]
2021-11-09T15:46:56.888204354Z at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[de.aditu.buchschrank.BuchschrankApplicationKt:5.3.12]
2021-11-09T15:46:56.888208354Z at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) ~[na:na]
2021-11-09T15:46:56.888212155Z at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[na:na]
2021-11-09T15:46:56.888216155Z at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[na:na]
2021-11-09T15:46:56.888220055Z at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[de.aditu.buchschrank.BuchschrankApplicationKt:2.5.6]
2021-11-09T15:46:56.888224455Z at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[de.aditu.buchschrank.BuchschrankApplicationKt:2.5.6]
2021-11-09T15:46:56.888228555Z at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[de.aditu.buchschrank.BuchschrankApplicationKt:2.5.6]
2021-11-09T15:46:56.888232355Z at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[de.aditu.buchschrank.BuchschrankApplicationKt:2.5.6]
2021-11-09T15:46:56.888236255Z at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[de.aditu.buchschrank.BuchschrankApplicationKt:2.5.6]
2021-11-09T15:46:56.888240055Z at de.aditu.buchschrank.BuchschrankApplicationKt.main(BuchschrankApplication.kt:17) ~[na:na]
2021-11-09T15:46:56.888243955Z Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
2021-11-09T15:46:56.888247755Z at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229) ~[na:na]
2021-11-09T15:46:56.888251555Z at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43) ~[na:na]
2021-11-09T15:46:56.888255455Z at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[de.aditu.buchschrank.BuchschrankApplicationKt:5.3.12]
2021-11-09T15:46:56.888259455Z ... 14 common frames omitted
2021-11-09T15:46:56.888263155Z Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
2021-11-09T15:46:56.888266855Z at org.apache.catalina.core.StandardService.addConnector(StandardService.java:238) ~[na:na]
2021-11-09T15:46:56.888270755Z at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282) ~[na:na]
2021-11-09T15:46:56.888275055Z at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213) ~[na:na]
2021-11-09T15:46:56.888281755Z ... 16 common frames omitted
2021-11-09T15:46:56.888285555Z Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
2021-11-09T15:46:56.888289355Z at org.apache.catalina.connector.Connector.startInternal(Connector.java:1075) ~[na:na]
2021-11-09T15:46:56.888293055Z at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[na:na]
2021-11-09T15:46:56.888296855Z at org.apache.catalina.core.StandardService.addConnector(StandardService.java:234) ~[na:na]
2021-11-09T15:46:56.888300655Z ... 18 common frames omitted
2021-11-09T15:46:56.888304255Z Caused by: java.net.SocketException: Permission denied
2021-11-09T15:46:56.888308255Z at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST_SocketException_constructor_df417f52c09624a386e25e5af85993f853394076(JNIJavaCallWrappers.java:0) ~[na:na]
2021-11-09T15:46:56.888312255Z at sun.nio.ch.Net.bind0(Net.java) ~[na:na]
2021-11-09T15:46:56.888315955Z at sun.nio.ch.Net.bind(Net.java:455) ~[na:na]
2021-11-09T15:46:56.888319655Z at sun.nio.ch.Net.bind(Net.java:447) ~[na:na]
2021-11-09T15:46:56.888323255Z at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227) ~[na:na]
2021-11-09T15:46:56.888327055Z at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:271) ~[de.aditu.buchschrank.BuchschrankApplicationKt:9.0.54]
2021-11-09T15:46:56.888330955Z at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:226) ~[de.aditu.buchschrank.BuchschrankApplicationKt:9.0.54]
2021-11-09T15:46:56.888334755Z at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1208) ~[de.aditu.buchschrank.BuchschrankApplicationKt:9.0.54]
2021-11-09T15:46:56.888338655Z at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1294) ~[de.aditu.buchschrank.BuchschrankApplicationKt:9.0.54]
2021-11-09T15:46:56.888342555Z at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:614) ~[de.aditu.buchschrank.BuchschrankApplicationKt:9.0.54]
2021-11-09T15:46:56.888346355Z at org.apache.catalina.connector.Connector.startInternal(Connector.java:1072) ~[na:na]
2021-11-09T15:46:56.888350255Z ... 20 common frames omitted
2021-11-09T15:46:56.888353856Z
Regarding the logs, Azure starts docker with
docker run -d -p 7502:80...
The first port seems to be random.
The full source code can be found here: https://github.com/lesestunden/buchschrank-backend
Does anybody have an idea whats going wrong?
Thanks a lot!
Your application should listen on a non-privileged port (> 1024).
The created container is unable to use a privileged port. The bootBuildImage task creates and runs images utilizing buildpacks (for runtime paketobuildpacks/run:tiny-cnb), the application in the container doesn't run as root. Therefore you can not listen on a port below 1024.
Spring boot uses paketo-buildpacks, which have some security-hardenings in them
The stack images are run as a dedicated non-root user when building
and running applications.
see paketo documentation
Solution is using a port bigger than 1024 (e.g. 8080) and configure the port like in this answer: Azure Functions with docker: How change port?

Exception opening socket - MongoDB, Docker

I have Maven Multi-Module application(Spring Boot + MySql + MongoDB) with using docker image, but i can't get connection to MongoDB.
Thing is when local mongo instance "MongoDB Server on Windows Services" is turned on and use spring.data.mongodb.host=localhost all is working fine.
But when I turn off mongo instance and try to go with:
spring.data.mongodb.host=$(MONGO_HOST) to use it with docker I'm getting error "Exception opening socket"
I start my application with execute command:
mvn install and tryed with docker-compose up --build
console
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.1)
2021-09-25 12:19:22.635 INFO 8588 --- [ main] c.o.o.n.controller.NoteControllerTest : Starting NoteControllerTest using Java 16.0.1 on AntonioPC with PID 8588 (started by ajago in D:\Programming\Eclipse-workspace\OC_Project10\Notes)
2021-09-25 12:19:22.642 INFO 8588 --- [ main] c.o.o.n.controller.NoteControllerTest : No active profile set, falling back to default profiles: default
2021-09-25 12:19:23.776 INFO 8588 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2021-09-25 12:19:23.777 INFO 8588 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-09-25 12:19:23.824 INFO 8588 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data JPA - Could not safely identify store assignment for repository candidate interface com.openclassrooms.ocproject10.notes.repository.NoteRepository. If you want this repository to be a JPA repository, consider annotating your entities with one of these annotations: javax.persistence.Entity, javax.persistence.MappedSuperclass (preferred), or consider extending one of the following types with your repository: org.springframework.data.jpa.repository.JpaRepository.
2021-09-25 12:19:23.826 INFO 8588 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 36 ms. Found 0 JPA repository interfaces.
2021-09-25 12:19:24.093 INFO 8588 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2021-09-25 12:19:24.094 INFO 8588 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
2021-09-25 12:19:24.126 INFO 8588 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 31 ms. Found 1 MongoDB repository interfaces.
2021-09-25 12:19:24.876 INFO 8588 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-09-25 12:19:25.458 INFO 8588 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-09-25 12:19:25.596 INFO 8588 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-09-25 12:19:25.685 INFO 8588 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-09-25 12:19:25.882 INFO 8588 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-09-25 12:19:26.112 INFO 8588 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2021-09-25 12:19:27.051 INFO 8588 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-09-25 12:19:27.065 INFO 8588 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-09-25 12:19:27.486 INFO 8588 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms'}
2021-09-25 12:19:27.586 INFO 8588 --- [localhost:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server localhost:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70) ~[mongodb-driver-core-4.2.3.jar:na]
at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:143) ~[mongodb-driver-core-4.2.3.jar:na]
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.lookupServerDescription(DefaultServerMonitor.java:188) ~[mongodb-driver-core-4.2.3.jar:na]
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:144) ~[mongodb-driver-core-4.2.3.jar:na]
at java.base/java.lang.Thread.run(Thread.java:831) ~[na:na]
Caused by: java.net.ConnectException: Connection refused: no further information
at java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[na:na]
at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:669) ~[na:na]
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:542) ~[na:na]
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597) ~[na:na]
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:333) ~[na:na]
at java.base/java.net.Socket.connect(Socket.java:645) ~[na:na]
at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:107) ~[mongodb-driver-core-4.2.3.jar:na]
at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:79) ~[mongodb-driver-core-4.2.3.jar:na]
at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65) ~[mongodb-driver-core-4.2.3.jar:na]
... 4 common frames omitted
2021-09-25 12:19:28.302 WARN 8588 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-09-25 12:19:28.988 INFO 8588 --- [ main] o.s.b.t.m.w.SpringBootMockServletContext : Initializing Spring TestDispatcherServlet ''
2021-09-25 12:19:28.988 INFO 8588 --- [ main] o.s.t.web.servlet.TestDispatcherServlet : Initializing Servlet ''
2021-09-25 12:19:28.990 INFO 8588 --- [ main] o.s.t.web.servlet.TestDispatcherServlet : Completed initialization in 2 ms
2021-09-25 12:19:29.018 INFO 8588 --- [ main] c.o.o.n.controller.NoteControllerTest : Started NoteControllerTest in 7.33 seconds (JVM running for 9.77)
2021-09-25 12:19:29.380 INFO 8588 --- [ main] org.mongodb.driver.cluster : Cluster description not yet available. Waiting for 30000 ms before timing out
docker-compose.yml
version: '2'
services:
reports:
image: 'reports:latest'
build:
context: ./reports
container_name: reports
ports:
- 8080:8080
environment:
- PATIENTS_URL=http://gps:8081
- NOTES_URL=http://rewards:8082
patients:
image: 'patients:latest'
build:
context: ./patients
container_name: patients
ports:
- 8081:8081
environment:
- MYSQL_HOST=db-mysql
depends_on:
- db-mysql
notes:
image: 'notes:latest'
build:
context: ./notes
container_name: notes
ports:
- 8082:8082
environment:
- MONGO_HOST=mongodb
depends_on:
- mongodb
db-mysql:
image: mysql:latest
container_name: mysql
ports:
- 3306:3306
command: --innodb --init-file /data/application/init.sql
volumes:
- ./init.sql:/data/application/init.sql
environment:
MYSQL_DATABASE: project_10
MYSQL_ROOT_USER: root
MYSQL_ROOT_PASSWORD: Musapa1990..
mongodb:
image: mongo:latest
container_name: mongodb
network_mode: host
restart: always
ports:
- 27017:27017
environment:
MONGO_INITDB_DATABASE: project_10
application.properties
# App config
logging.level.org.springframework=INFO
spring.application.name=P10_notes
server.port=8082
################### MongoDB Configuration ##########################
spring.data.mongodb.database=project_10
spring.data.mongodb.port=27017
#spring.data.mongodb.host=localhost
spring.data.mongodb.host=$(MONGO_HOST)
spring.data.mongodb.authentication-database=admin
# thymeleaf configurations for Auto reload Thymeleaf templates without restart
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=file:src/main/resources/templates/
I read similar articles here and tried different things, but nothing helped me.
In the end I messed up something when installing mongodb. When I reinstalled the mongo it worked. I did not make any crucial changes in the code.
Only what I added was:
################### MongoDB Configuration ##########################
spring.data.mongodb.database=project_10
spring.data.mongodb.port=27017
#spring.data.mongodb.host=localhost
spring.data.mongodb.host=${MONGO_HOST}
spring.data.mongodb.authentication-database=admin
I added that on all 3 module on application.properties because each of modules are using MongoDB.
If that not work then you can try that
change localhost and 127.0.0.1 it worked for me
like this
#spring.data.mongodb.host=localhost
spring.data.mongodb.host=127.0.0.1

Docker-compose, spring app + mongoDB on non-default port

I have a problem with connecting to mongodb from my app.
Here is the docker-compose file:
version: "3"
services:
olx-crawler:
container_name: olx-crawler
image: myimage:v1
ports:
- "8099:8099"
depends_on:
- olx-mongo
environment:
SPRING_DATA_MONGODB_HOST: olx-mongo
olx-mongo:
container_name: olx-mongo
image: mongo
ports:
- "27777:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: biafra
MONGO_INITDB_ROOT_PASSWORD: password
And here is my application.yaml:
spring:
data:
mongodb:
host: localhost
port: 27777
username: biafra
password: password
authentication-database: admin
logging:
level:
org.springframework.data.mongodb.core.MongoTemplate: DEBUG
server:
port: 8099
Now i have done a similar project to this (docker-compose -> spring app + mongodb) and it worked correctly, but it was with the default mongo port 27017.
And i know you have to use mongo container name instead of localhost, this is what this:
SPRING_DATA_MONGODB_HOST: olx-mongo
is for it replaces "localhost" in application.yml with olx-mongo, as you can see in app logs:
Exception in monitor thread while connecting to server olx-mongo:27777
Here are some logs:
olx-mongo | 2020-04-15T18:00:15.170+0000 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
olx-mongo | 2020-04-15T18:00:15.174+0000 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
olx-mongo | 2020-04-15T18:00:15.175+0000 I NETWORK [listener] Listening on /tmp/mongodb-27017.sock
olx-mongo | 2020-04-15T18:00:15.175+0000 I NETWORK [listener] Listening on 0.0.0.0
olx-mongo | 2020-04-15T18:00:15.175+0000 I NETWORK [listener] waiting for connections on port 27017
olx-crawler | 2020-04-15 18:00:15.436 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
olx-crawler | 2020-04-15 18:00:15.486 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 45ms. Found 1 MongoDB repository interfaces.
olx-mongo | 2020-04-15T18:00:16.000+0000 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>
olx-crawler | 2020-04-15 18:00:16.037 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8099 (http)
olx-crawler | 2020-04-15 18:00:16.050 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
olx-crawler | 2020-04-15 18:00:16.052 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
olx-crawler | 2020-04-15 18:00:16.116 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
olx-crawler | 2020-04-15 18:00:16.117 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1487 ms
olx-crawler | 2020-04-15 18:00:16.468 INFO 1 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[olx-mongo:27777], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize
=500}
olx-crawler | 2020-04-15 18:00:16.469 INFO 1 --- [ main] org.mongodb.driver.cluster : Adding discovered server olx-mongo:27777 to client view of cluster
olx-crawler | 2020-04-15 18:00:16.550 INFO 1 --- [olx-mongo:27777] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server olx-mongo:27777
olx-crawler |
olx-crawler | com.mongodb.MongoSocketOpenException: Exception opening socket
olx-crawler | at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70) ~[mongodb-driver-core-3.11.2.jar!/:na]
olx-crawler | at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:128) ~[mongodb-driver-core-3.11.2.jar!/:na]
olx-crawler | at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.11.2.jar!/:na]
olx-crawler | at java.base/java.lang.Thread.run(Thread.java:844) [na:na]
olx-crawler | Caused by: java.net.ConnectException: Connection refused (Connection refused)
olx-crawler | at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:na]
olx-crawler | at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:400) ~[na:na]
olx-crawler | at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:243) ~[na:na]
olx-crawler | at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:225) ~[na:na]
olx-crawler | at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:402) ~[na:na]
olx-crawler | at java.base/java.net.Socket.connect(Socket.java:591) ~[na:na]
olx-crawler | at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:64) ~[mongodb-driver-core-3.11.2.jar!/:na]
olx-crawler | at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:79) ~[mongodb-driver-core-3.11.2.jar!/:na]
olx-crawler | at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65) ~[mongodb-driver-core-3.11.2.jar!/:na]
olx-crawler | ... 3 common frames omitted
olx-crawler |
olx-crawler | 2020-04-15 18:00:17.096 INFO 1 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
olx-crawler | 2020-04-15 18:00:17.229 INFO 1 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
olx-crawler | 2020-04-15 18:00:17.306 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8099 (http) with context path ''
olx-crawler | 2020-04-15 18:00:17.315 INFO 1 --- [ main] c.e.olxcrawler.OlxCrawlerApplication : Started OlxCrawlerApplication in 3.944 seconds (JVM running for 4.977)
Any help?
Well you wrote
And i know you have to use mongo container name instead of localhost, but it still does not work.
but you have
spring:
data:
mongodb:
host: localhost
port: 27777
Problem is that with this config you are not able to connect to mongo from within spring boot container. It's just configuration for "outside world" of container. For example you can connect to it from your locally running spring boot application which doesn't run inside docker.
To connect to mongo from within dockerized spring boot app, change host to olx-mongo and port to 27017.

Flyway not finding migrations when run from IntelliJ when using Gradle

When I run my Spring Boot Kotlin application that uses Flyway from the command line, it seems to work, but from IntelliJ it fails. I created a minimal sample project that replicates the problem: https://github.com/pupeno/notflying
The error I get from IntelliJ is about the migrations not being found:
Caused by: java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
at org.springframework.util.Assert.state(Assert.java:94) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.checkLocationExists(FlywayAutoConfiguration.java:184) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.flyway(FlywayAutoConfiguration.java:149) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$ffc78d0a.CGLIB$flyway$0(<generated>) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$ffc78d0a$$FastClassBySpringCGLIB$$5b3da70f.invoke(<generated>) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$ffc78d0a.flyway(<generated>) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
... 27 common frames omitted
The migrations are there and correctly named as far as I can see:
PS C:\Users\pupeno\Temporary\notflying> dir .\src\main\resources\db\migration\
Directory: C:\Users\pupeno\Temporary\notflying\src\main\resources\db\migration
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2019-08-26 08:32 718 V0001__create_countries_table.sql
PS C:\Users\pupeno\Temporary\notflying>
The IntelliJ configuration for running it looks like this:
I added:
logging.level.org.flywaydb=DEBUG
to application.properties and the full output of trying to start the application from IntelliJ looks like this:
"C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\jbr\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\lib\idea_rt.jar=50536:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\pupeno\Temporary\notflying\build\classes\java\main;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-data-jpa\2.1.7.RELEASE\5e4a5d5442f32f5e12b36674a620ec57b0b66c6e\spring-boot-starter-data-jpa-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-thymeleaf\2.1.7.RELEASE\cf9547e20aa6a32c0b0f53400db6eecfab660f86\spring-boot-starter-thymeleaf-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.1.7.RELEASE\fa43baf40bde3ecdb93ac9c545dd39f82ab29c35\spring-boot-starter-web-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-kotlin\2.9.9\446b0567b26965cf7db859ba48a73ab30b4016b7\jackson-module-kotlin-2.9.9.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-devtools\2.1.7.RELEASE\5a846c6e9ab67a4cbf7c4f22bc13bcab188198f9\spring-boot-devtools-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.flywaydb\flyway-core\5.2.4\50a92d39554615bd4ff56d148a359b20dc17f655\flyway-core-5.2.4.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.2.71\7512db3b3182753bd2e48ce8d345abbadc40fe6b\kotlin-reflect-1.2.71.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk8\1.2.71\5470d1f752cd342edb77e1062bac07e838d2cea4\kotlin-stdlib-jdk8-1.2.71.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-aop\2.1.7.RELEASE\4577d056af1f823bb7730c99f43c3268dd697310\spring-boot-starter-aop-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-jdbc\2.1.7.RELEASE\3ea97a134b44a886ff529215e7bec04bfd93fa5b\spring-boot-starter-jdbc-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\javax.transaction\javax.transaction-api\1.3\e006adf5cf3cca2181d16bd640ecb80148ec0fce\javax.transaction-api-1.3.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\javax.xml.bind\jaxb-api\2.3.1\8531ad5ac454cc2deb9d4d32c40c4d7451939b5d\jaxb-api-2.3.1.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.h2database\h2\1.4.199\7bf08152984ed8859740ae3f97fae6c72771ae45\h2-1.4.199.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.hibernate\hibernate-core\5.3.10.Final\e608b854325005edbf43cb2b6041fdafd3f2eb57\hibernate-core-5.3.10.Final.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-jpa\2.1.10.RELEASE\12639406aa28c3a5195a1a4c9077fe562f54bc31\spring-data-jpa-2.1.10.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aspects\5.1.9.RELEASE\a8aec853c345ed54a99627cee9f755ce7dbb734\spring-aspects-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-json\2.1.7.RELEASE\9c12f046a7c4ae110d89163a491ad0d7cf036e79\spring-boot-starter-json-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.1.7.RELEASE\e23f4e9460e0e2220b444e40fc7fd6e95f66e0fe\spring-boot-starter-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.thymeleaf\thymeleaf-spring5\3.0.11.RELEASE\de7bf0adf13b5e9c4811f95edf18279da193c0c6\thymeleaf-spring5-3.0.11.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.thymeleaf.extras\thymeleaf-extras-java8time\3.0.4.RELEASE\36e7175ddce36c486fff4578b5af7bb32f54f5df\thymeleaf-extras-java8time-3.0.4.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\2.1.7.RELEASE\11f2a86aefefba72a4efe5ff18f4165a4b4e78b\spring-boot-starter-tomcat-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.hibernate.validator\hibernate-validator\6.0.17.Final\af73055fc4a103ab347c56e7da5a143d68a0170\hibernate-validator-6.0.17.Final.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.1.9.RELEASE\b9d4a2140488f0e6f9aa231e7938ae18da77b637\spring-webmvc-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-web\5.1.9.RELEASE\9fe4390420fdd0b63dc4ed90d9027dafa9f74f80\spring-web-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.9.9\4b04126963103216c9c43b0f34bbc36315654204\jackson-datatype-jdk8-2.9.9.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.9.9\a33df137557793b0404a486888dbe049f7abeeeb\jackson-datatype-jsr310-2.9.9.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.9.9\a92facb55a2538e7b2fe14294570a18b823ad431\jackson-module-parameter-names-2.9.9.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.9.9\d6eb9817d9c7289a91f043ac5ee02a6b3cc86238\jackson-databind-2.9.9.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.9.0\7c10d545325e3a6e72e06381afe469fd40eb701\jackson-annotations-2.9.0.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk7\1.2.71\4ce93f539e2133f172f1167291a911f83400a5d0\kotlin-stdlib-jdk7-1.2.71.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.2.71\d9717625bb3c731561251f8dd2c67a1011d6764c\kotlin-stdlib-1.2.71.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.1.7.RELEASE\2c9d3e2c6ea3cb435e99e2973009636b62a9d816\spring-boot-autoconfigure-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.1.7.RELEASE\1599a2ad1fc6d36dbfc2a7c0dd5dab3a0bb27c61\spring-boot-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\5.1.9.RELEASE\c37f8fe15a5ae4ea1f351bd46167fd492a84eefa\spring-context-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\5.1.9.RELEASE\bc2312ffad02251b9d472e4a7c0e472a58f50fbf\spring-aop-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.aspectj\aspectjweaver\1.9.4\9205229878f3d62fbd3a32a0fb6be2d6ad8589a9\aspectjweaver-1.9.4.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.zaxxer\HikariCP\3.2.0\6c66db1c636ee90beb4c65fe34abd8ba9396bca6\HikariCP-3.2.0.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-orm\5.1.9.RELEASE\220169d217f7114706141fc0afba425a5b368dce\spring-orm-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jdbc\5.1.9.RELEASE\3fd70356ba8d7c00c4081c1a207766352624414e\spring-jdbc-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\javax.activation\javax.activation-api\1.2.0\85262acf3ca9816f9537ca47d5adeabaead7cb16\javax.activation-api-1.2.0.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.hibernate.common\hibernate-commons-annotations\5.0.4.Final\965a18fdf939ee75e41f7918532d37b3a8350535\hibernate-commons-annotations-5.0.4.Final.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.3.2.Final\3789d00e859632e6c6206adc0c71625559e6e3b0\jboss-logging-3.3.2.Final.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\javax.persistence\javax.persistence-api\2.2\25665ac8c0b62f50e6488173233239120fc52c96\javax.persistence-api-2.2.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.javassist\javassist\3.23.2-GA\c5afe660a95e87ceb518e4f5cf02f5c56b547683\javassist-3.23.2-GA.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy\1.9.16\e7d63009be7b87ff1f15b72e5b8c59c897a8d8bd\byte-buddy-1.9.16.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\antlr\antlr\2.7.7\83cd2cd674a217ade95a4bb83a8a14f351f48bd0\antlr-2.7.7.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jboss\jandex\2.0.5.Final\7060f67764565b9ee9d467e3ed0cb8a9c601b23a\jandex-2.0.5.Final.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml\classmate\1.4.0\291658ac2ce2476256c7115943652c0accb5c857\classmate-1.4.0.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.dom4j\dom4j\2.1.1\3dce5dbb3571aa820c677fadd8349bfa8f00c199\dom4j-2.1.1.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.1.10.RELEASE\c73a76070181b59b19df6893e1ca729263a69b47\spring-data-commons-2.1.10.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-tx\5.1.9.RELEASE\a9125e2c8eeb193030f3972c6293616943c55ef2\spring-tx-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.1.9.RELEASE\5a03b3983108d73978aec2fa3e681aedad6782c\spring-beans-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-expression\5.1.9.RELEASE\db3a2468c1b7d697ec3b3ec6e5652dc282994fe3\spring-expression-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-core\5.1.9.RELEASE\dc3815439579b4fa0c19970e6b8e5d774af8d988\spring-core-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.thymeleaf\thymeleaf\3.0.11.RELEASE\628ebb91f520053d4120b7b18bf78ff295d57461\thymeleaf-3.0.11.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.1.7.RELEASE\6e829f739992a7f368c0af44a08ed89ad2a1972f\spring-boot-starter-logging-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.3\7c4f3c474fb2c041d8028740440937705ebb473a\logback-classic-1.2.3.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.11.2\6d37bf7b046c0ce2669f26b99365a2cfa45c4c18\log4j-to-slf4j-2.11.2.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.26\8031352b2bb0a49e67818bf04c027aa92e645d5c\jul-to-slf4j-1.7.26.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.26\77100a62c2e6f04b53977b9f541044d7d722693d\slf4j-api-1.7.26.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\javax.annotation\javax.annotation-api\1.3.2\934c04d3cfef185a8008e7bf34331b79730a9d43\javax.annotation-api-1.3.2.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-websocket\9.0.22\45974d3443cc15ad9d10239d762d5e15759e6364\tomcat-embed-websocket-9.0.22.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-core\9.0.22\79f39903498b28adacb18fe2ea046edd306295a6\tomcat-embed-core-9.0.22.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\9.0.22\4da4b778b635a7e78ca7cd7288253e2e47b88a9f\tomcat-embed-el-9.0.22.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\javax.validation\validation-api\2.0.1.Final\cb855558e6271b1b32e716d24cb85c7f583ce09e\validation-api-2.0.1.Final.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.9.9\bfff5af9fb8347d26bbb7959cb9b4fe9a2b0ca5e\jackson-core-2.9.9.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-common\1.2.71\ba18ca1aa0e40eb6f1865b324af2f4cbb691c1ec\kotlin-stdlib-common-1.2.71.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.23\ec62d74fe50689c28c0ff5b35d3aebcaa8b5be68\snakeyaml-1.23.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jetbrains\annotations\13.0\919f0dfe192fb4e063e7dacadee7f8bb9a2672a9\annotations-13.0.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.1.9.RELEASE\7c372790c999777d20f364960cf557dd74f890cf\spring-jcl-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.attoparser\attoparser\2.0.5.RELEASE\a93ad36df9560de3a5312c1d14f69d938099fa64\attoparser-2.0.5.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.unbescape\unbescape\1.1.6.RELEASE\7b90360afb2b860e09e8347112800d12c12b2a13\unbescape-1.1.6.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.3\864344400c3d4d92dfeb0a305dc87d953677c03c\logback-core-1.2.3.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.11.2\f5e9a2ffca496057d6891a3de65128efc636e26e\log4j-api-2.11.2.jar tech.flexpoint.notflying.NotflyingApplicationKt
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.7.RELEASE)
2019-08-26 10:36:00.478 INFO 7132 --- [ restartedMain] t.f.notflying.NotflyingApplicationKt : Starting NotflyingApplicationKt on Utopia-Planitia with PID 7132 (C:\Users\pupeno\Temporary\notflying\build\classes\java\main started by pupeno in C:\Users\pupeno\Temporary\notflying)
2019-08-26 10:36:00.484 INFO 7132 --- [ restartedMain] t.f.notflying.NotflyingApplicationKt : No active profile set, falling back to default profiles: default
2019-08-26 10:36:00.549 INFO 7132 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-08-26 10:36:00.550 INFO 7132 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-08-26 10:36:01.616 INFO 7132 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-08-26 10:36:01.641 INFO 7132 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 16ms. Found 0 repository interfaces.
2019-08-26 10:36:02.113 INFO 7132 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$e16cf649] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-08-26 10:36:02.433 INFO 7132 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-08-26 10:36:02.460 INFO 7132 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-08-26 10:36:02.460 INFO 7132 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.22]
2019-08-26 10:36:02.696 INFO 7132 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-08-26 10:36:02.696 INFO 7132 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2146 ms
2019-08-26 10:36:02.831 WARN 7132 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
2019-08-26 10:36:02.834 INFO 7132 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-08-26 10:36:02.848 INFO 7132 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-08-26 10:36:02.864 ERROR 7132 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:307) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at tech.flexpoint.notflying.NotflyingApplicationKt.main(NotflyingApplication.kt:13) ~[main/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.1.7.RELEASE.jar:2.1.7.RELEASE]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
... 26 common frames omitted
Caused by: java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
at org.springframework.util.Assert.state(Assert.java:94) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.checkLocationExists(FlywayAutoConfiguration.java:184) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.flyway(FlywayAutoConfiguration.java:149) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$616ac3e9.CGLIB$flyway$1(<generated>) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$616ac3e9$$FastClassBySpringCGLIB$$a2f39a48.invoke(<generated>) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$616ac3e9.flyway(<generated>) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
... 27 common frames omitted
Process finished with exit code 0
I've tried this, with the same result, both with the JDK provided by IntelliJ (version 11 I think) as well as Oracle JDK 11:
PS C:\Users\pupeno\Temporary\notflying> java --version
java 12.0.2 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
When I trigger a build in IntelliJ, I get some warning (not sure if relevant):
I re-created the project with Maven and it seems to work out of the box, with no issues. So, I'd say, the problem seems to be in how IntelliJ imports Gradle projects.
Perfectly work on my machine
Probably migrations not copied to build/resources/main/db directory
Try next:
Delete build directory
Invalidate idea cache link
Reimport gradle link
If that doesn't help replace Build to gradle build in configuration settings:
Also maybe gradle not have access to read migration file or parent directory. Check permissions in file system or try clone github repository to another folder.
Looks like Intellij might have created the directory as
src/main/resources/db.migration
with the files in a directory called db.migration, instead of
src/main/resources/db/migration
with the files in a directory called migration.
My try, which succeeded:
Rename to a name that isn't your name in mind.
Run gradle clean and start test.
Expect: No migrations found.
Rename it again to your desired name. Run the test again.
Expect: Migrations found!
Its definitely a bug in IntelliJ/Gradle where it doesn't detect resources to import when there is no builds exists before its compilation. Making changes to the script refreshes its state, and automatically imports the resource afterwards.
Working fine for me:
$ ./gradlew bootRun
./gradlew: 39: cd: can't cd to "./
> Task :bootRun
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.7.RELEASE)
2019-08-26 08:21:36.837 INFO 1789 --- [ restartedMain] t.f.notflying.NotflyingApplicationKt : Starting NotflyingApplicationKt on LAP025 with PID 1789 (/mnt/c/Users/bleug/Desktop/notflying/build/classes/kotlin/main started by bleug in /mnt/c/Users/bleug/Desktop/notflying)
2019-08-26 08:21:36.846 INFO 1789 --- [ restartedMain] t.f.notflying.NotflyingApplicationKt : No active profile set, falling back to default profiles: default
2019-08-26 08:21:37.116 INFO 1789 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-08-26 08:21:37.116 INFO 1789 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-08-26 08:21:40.958 INFO 1789 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-08-26 08:21:41.124 INFO 1789 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 106ms. Found 0 repository interfaces.
2019-08-26 08:21:42.578 INFO 1789 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$6414adf5] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-08-26 08:21:43.698 INFO 1789 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-08-26 08:21:43.781 INFO 1789 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-08-26 08:21:43.782 INFO 1789 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.22]
2019-08-26 08:21:44.196 INFO 1789 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-08-26 08:21:44.196 INFO 1789 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 7080 ms
2019-08-26 08:21:44.735 INFO 1789 --- [ restartedMain] o.f.c.internal.license.VersionPrinter : Flyway Community Edition 5.2.4 by Boxfuse
2019-08-26 08:21:44.765 INFO 1789 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-08-26 08:21:45.433 INFO 1789 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-08-26 08:21:45.460 INFO 1789 --- [ restartedMain] o.f.c.internal.database.DatabaseFactory : Database: jdbc:h2:mem:testdb (H2 1.4)
2019-08-26 08:21:45.607 WARN 1789 --- [ restartedMain] o.f.c.internal.database.base.Database : Flyway upgrade recommended: H2 1.4.199 is newer than this version of Flyway and support has not been tested.
2019-08-26 08:21:45.860 INFO 1789 --- [ restartedMain] o.f.core.internal.command.DbValidate : Successfully validated 1 migration (execution time 00:00.086s)
2019-08-26 08:21:45.893 INFO 1789 --- [ restartedMain] o.f.c.i.s.JdbcTableSchemaHistory : Creating Schema History table: "PUBLIC"."flyway_schema_history"
2019-08-26 08:21:45.976 INFO 1789 --- [ restartedMain] o.f.core.internal.command.DbMigrate : Current version of schema "PUBLIC": << Empty Schema >>
2019-08-26 08:21:45.993 INFO 1789 --- [ restartedMain] o.f.core.internal.command.DbMigrate : Migrating schema "PUBLIC" to version 0001 - create countries table
2019-08-26 08:21:46.051 INFO 1789 --- [ restartedMain] o.f.core.internal.command.DbMigrate : Successfully applied 1 migration to schema "PUBLIC" (execution time 00:00.165s)
2019-08-26 08:21:46.616 INFO 1789 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-08-26 08:21:46.939 INFO 1789 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.3.10.Final}
2019-08-26 08:21:46.944 INFO 1789 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-08-26 08:21:47.555 INFO 1789 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2019-08-26 08:21:48.169 INFO 1789 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2019-08-26 08:21:48.963 INFO 1789 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-08-26 08:21:49.033 INFO 1789 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2019-08-26 08:21:49.920 INFO 1789 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-08-26 08:21:50.137 WARN 1789 --- [ restartedMain] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2019-08-26 08:21:50.476 WARN 1789 --- [ restartedMain] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2019-08-26 08:21:51.143 INFO 1789 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-08-26 08:21:51.153 INFO 1789 --- [ restartedMain] t.f.notflying.NotflyingApplicationKt : Started NotflyingApplicationKt in 15.774 seconds (JVM running for 17.982)
If you enable debug logger by adding this line in application.properties:
logging.level.org.flywaydb=DEBUG
It will show you the exact path :
2019-08-26 08:30:31.661 DEBUG 1996 --- [ restartedMain] o.f.c.i.s.classpath.ClassPathScanner : Scanning URL: file:/mnt/c/Users/bleug/Desktop/notflying/build/resources/main/db/migration
Try to run it from a path with no space.
Edit:
Use gradle to run the project
It might be a long shot but still:
Can you try editing the path provided to flyway scripts to use backslash instead of forward slash?
flyway.locations=classpath:db\migration
or even
flyway.locations=filesystem=C:\Users\pupeno\Temporary\notflying\src\main\resources\db\migration
I've noticed that you are running your application in a Windows environment. It might be that Gradle does some magic regarding the default values but IntelliJ doesn't.
The answer by Nick was correct that migrations weren't being copied into the build/resources folder.
I work around this by adding the following to my script:
tasks.withType(org.flywaydb.gradle.task.AbstractFlywayTask) {
dependsOn processResources
}
Not sure why the Flyway gradle plugin doesn't do that.

Whitelabel error page on localhost:8080\sendMesssage?

I have just started Springboot with Twilio but for some reason when I run the localhost\sendMessage command I get the Whitelabel error Page. When I run the below code the test concludes successfully:
package com.example.demo
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.RequestMapping
#RestController
public class SMSController{
#RequestMapping( "/")
fun helloSpringBoot() = "Hello Spring Boot!"
}
This is the result of the code above:
But when I run the below code with the localhost:8080\sendMessage I get the screenshot that follows the code:
package com.example.demo
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.RequestMapping
import com.twilio.http.TwilioRestClient
import com.twilio.rest.api.v2010.account.MessageCreator
import com.twilio.type.PhoneNumber
#RestController
public class SMSController{
#RequestMapping("/sendMessage")
fun sendMessage(){
val client = TwilioRestClient.Builder(
System.getenv("ACCOUNT_SID"),
System.getenv("AUTH_TOKEN")).build()
val message = MessageCreator(
PhoneNumber(System.getenv("+1..........")),
PhoneNumber("+1.........."),
"Lambda is annoying..Sigh"
).create(client)
}
}
Am I missing something?
I have added my Stack TRace:
"C:\Program Files\Java\jdk1.8.0_25\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.1\lib\idea_rt.jar=25281:C:\Program Files\JetBrains\IntelliJ IDEA 2019.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_25\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\rt.jar;C:\Users\Jevon\IdeaProjects\demo\out\production\classes;C:\Users\Jevon\IdeaProjects\demo\out\production\resources;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\com.twilio.sdk\twilio\7.17.9\8de7649313c8fa3dfcbd215b6c0300ca1c4184f5\twilio-7.17.9.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.1.4.RELEASE\a4659d55f57421a5ef122cb670b7b544ef8190e8\spring-boot-starter-web-2.1.4.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-json\2.1.4.RELEASE\247d7c2efae986f310a29e9fef7174adc91d0835\spring-boot-starter-json-2.1.4.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.1.4.RELEASE\8fa436ef4e273cb476d5dc3aa73701a8837460af\spring-boot-starter-2.1.4.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.3.21\d0d5ff2ac2ebd8a42697af41e20fc225a23c5d3b\kotlin-reflect-1.3.21.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk8\1.3.21\d0634d54452abc421db494ad32dd215e6591c49f\kotlin-stdlib-jdk8-1.3.21.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\com.google.guava\guava\18.0\cce0823396aa693798f8882e64213b1772032b09\guava-18.0.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\joda-time\joda-time\2.10.1\9ac3dbf89dbf2ee385185dd0cd3064fe789efee0\joda-time-2.10.1.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\io.jsonwebtoken\jjwt\0.4\61ce246d937a0fd3acf06d3bef5fc9e3933ae812\jjwt-0.4.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpclient\4.5.8\c27c9d6f15435dc2b6947112027b418b0eef32b9\httpclient-4.5.8.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpcore\4.4.11\de748cf874e4e193b42eceea9fe5574fabb9d4df\httpcore-4.4.11.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.9.8\bcd02aa9195390e23747ed40bf76be869ad3a2fb\jackson-datatype-jdk8-2.9.8.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.9.8\28ad1bced632ba338e51c825a652f6e11a8e6eac\jackson-datatype-jsr310-2.9.8.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.9.8\c4eef0e6e20d60fb27af4bc4770dba7bcc3f6de6\jackson-module-parameter-names-2.9.8.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.9.8\11283f21cc480aa86c4df7a0a3243ec508372ed2\jackson-databind-2.9.8.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.9.8\f5a654e4675769c716e5b387830d19b501ca191\jackson-core-2.9.8.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.9.0\7c10d545325e3a6e72e06381afe469fd40eb701\jackson-annotations-2.9.0.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\javax.xml.bind\jaxb-api\2.3.1\8531ad5ac454cc2deb9d4d32c40c4d7451939b5d\jaxb-api-2.3.1.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\2.1.4.RELEASE\3b0c04450d86fc29c9fdad555b4555e553a4008\spring-boot-starter-tomcat-2.1.4.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.hibernate.validator\hibernate-validator\6.0.16.Final\ad9557c558972093c0567a2a1f224f318c00f650\hibernate-validator-6.0.16.Final.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.1.6.RELEASE\cf4ea53740c93e0b8ff951ef0a3eaf154c74dbd0\spring-webmvc-5.1.6.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework\spring-web\5.1.6.RELEASE\4e15a24feba0581a02efd508af03a15b05570bd4\spring-web-5.1.6.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.1.4.RELEASE\d5f8b3f7835a23b4dfd8d1489d265c1e426e317b\spring-boot-autoconfigure-2.1.4.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.1.4.RELEASE\5ad0355a8c810b32b9221b9b92746b51c983337f\spring-boot-2.1.4.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.1.4.RELEASE\2fb669a89cd65b275be20ab755c3742399395dff\spring-boot-starter-logging-2.1.4.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\javax.annotation\javax.annotation-api\1.3.2\934c04d3cfef185a8008e7bf34331b79730a9d43\javax.annotation-api-1.3.2.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\5.1.6.RELEASE\7b9e80ab68ee91ca0462a0eb2c58a9d957788b\spring-context-5.1.6.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\5.1.6.RELEASE\a473d4bca7295f2b90522594e413f9e19107c1d2\spring-aop-5.1.6.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.1.6.RELEASE\90d2f4bf7eced108de0b5bf617abb2b13a6206a3\spring-beans-5.1.6.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework\spring-expression\5.1.6.RELEASE\50fe4080029e43e7612e50fb4d7c7c43e95bf03c\spring-expression-5.1.6.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework\spring-core\5.1.6.RELEASE\9329591e728ef9844911e082e399f4fc3e3ecb37\spring-core-5.1.6.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk7\1.3.21\d207ce2c9bcf17dc8e51bab4dbfdac4d013e7138\kotlin-stdlib-jdk7-1.3.21.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.3.21\4bcc2012b84840e19e1e28074284cac908be0295\kotlin-stdlib-1.3.21.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.3\7c4f3c474fb2c041d8028740440937705ebb473a\logback-classic-1.2.3.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.11.2\6d37bf7b046c0ce2669f26b99365a2cfa45c4c18\log4j-to-slf4j-2.11.2.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.23\ec62d74fe50689c28c0ff5b35d3aebcaa8b5be68\snakeyaml-1.23.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.26\8031352b2bb0a49e67818bf04c027aa92e645d5c\jul-to-slf4j-1.7.26.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.26\77100a62c2e6f04b53977b9f541044d7d722693d\slf4j-api-1.7.26.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\commons-codec\commons-codec\1.11\3acb4705652e16236558f0f4f2192cc33c3bd189\commons-codec-1.11.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\javax.activation\javax.activation-api\1.2.0\85262acf3ca9816f9537ca47d5adeabaead7cb16\javax.activation-api-1.2.0.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-websocket\9.0.17\a786505cc2697f7f2d8693c0c318270cc8addd92\tomcat-embed-websocket-9.0.17.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-core\9.0.17\aacb92c34eb2e88f38a060c9fcaaae329a79c9ca\tomcat-embed-core-9.0.17.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\9.0.17\595fbb87426e23f27c71b267f22b6e7d2a91a2aa\tomcat-embed-el-9.0.17.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\javax.validation\validation-api\2.0.1.Final\cb855558e6271b1b32e716d24cb85c7f583ce09e\validation-api-2.0.1.Final.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.3.2.Final\3789d00e859632e6c6206adc0c71625559e6e3b0\jboss-logging-3.3.2.Final.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\com.fasterxml\classmate\1.4.0\291658ac2ce2476256c7115943652c0accb5c857\classmate-1.4.0.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.1.6.RELEASE\a4ad3c98c7cc31357e94e12772c8e6449522bc5\spring-jcl-5.1.6.RELEASE.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-common\1.3.21\f30e4a9897913e53d778f564110bafa1fef46643\kotlin-stdlib-common-1.3.21.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.jetbrains\annotations\13.0\919f0dfe192fb4e063e7dacadee7f8bb9a2672a9\annotations-13.0.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.3\864344400c3d4d92dfeb0a305dc87d953677c03c\logback-core-1.2.3.jar;C:\Users\Jevon\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.11.2\f5e9a2ffca496057d6891a3de65128efc636e26e\log4j-api-2.11.2.jar" com.example.demo.DemoApplicationKt
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2019-04-04 15:32:35.584 INFO 8012 --- [ main] com.example.demo.DemoApplicationKt : Starting DemoApplicationKt on Javy26 with PID 8012 (C:\Users\Jevon\IdeaProjects\demo\out\production\classes started by Jevon in C:\Users\Jevon\IdeaProjects\demo)
2019-04-04 15:32:35.596 INFO 8012 --- [ main] com.example.demo.DemoApplicationKt : No active profile set, falling back to default profiles: default
2019-04-04 15:32:35.828 WARN 8012 --- [kground-preinit] o.s.h.c.j.Jackson2ObjectMapperBuilder : For Jackson Kotlin classes support please add "com.fasterxml.jackson.module:jackson-module-kotlin" to the classpath
2019-04-04 15:32:39.918 INFO 8012 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-04-04 15:32:39.970 INFO 8012 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-04-04 15:32:39.970 INFO 8012 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17]
2019-04-04 15:32:40.214 INFO 8012 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-04-04 15:32:40.214 INFO 8012 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4486 ms
2019-04-04 15:32:41.275 INFO 8012 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-04-04 15:32:41.807 INFO 8012 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-04-04 15:32:41.811 INFO 8012 --- [ main] com.example.demo.DemoApplicationKt : Started DemoApplicationKt in 7.81 seconds (JVM running for 10.279)
2019-04-04 15:33:24.230 INFO 8012 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-04-04 15:33:24.230 INFO 8012 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-04-04 15:33:24.250 INFO 8012 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 20 ms
I went back through the Kotlin documentation rather than focus on the tutorial and made the necessary changes. Once that was done the code started working as it should. See changes below:
#RestController
public class SMSController{
#RequestMapping(value = ["/sendMessage"])
fun sendMessage(){
val client = TwilioRestClient.Builder("ACCOUNT_SID",
"AUTH_TOKEN").build()
val message = MessageCreator(
PhoneNumber("+1........"),
PhoneNumber("+1........"),
"Lambda is annoying..Sigh").create(client)
}
}

Resources