JMS not starting in Spring Boot application - spring-boot

I developed a spring boot application which send and listen message in Activemq using JMS, but while running application, JMS is not getting started by spring boot
This is mainclass, Application.java
#SpringBootApplication
#EnableJms
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}
Configuration class: Config.java
#Configuration
public class Config {
#Bean
public Queue queue() {
return new ActiveMQQueue("inmemory.queue");
}
#Bean
public JmsTemplate jmsTemplate() {
return new JmsTemplate(activeMQConnectionFactory());
}
}
Listener class is used to listen to the queue: Listener.java
#Component
public class Listener {
#JmsListener(destination = "inmemory.queue")
public void listener(String message) {
System.out.println("message received" + message);
}
}
Producer class is used to send message to queue from controller: Producer.java
#RestController
public class Producer {
#Autowired
Queue queue;
#Autowired
JmsTemplate jmstemplate;
#RequestMapping(method = RequestMethod.GET, path = "/test3/{message}")
public String test3(#PathVariable String message) {
jmstemplate.convertAndSend(queue, message);
return "teste3" + message;
}
}
application.properties
spring.activemq.in-memory=true
spring.activemq.pool.enabled=false
server.port=8081
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>5.1.4.RELEASE</version>
</dependency>
</dependencies>
</project>
This is a screenshot of application starting without starting JMS

Please use below code for jmsTemplate(...) method.
#Bean
public JmsTemplate jmsTemplate() {
return new JmsTemplate(new ActiveMQConnectionFactory("vm://localhost"));
}
I have tested and it is working, let me know if you need sample code.
Also, no need to install ActiveMQ in local when you are using a starter.
Output
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.6.RELEASE)
2019-09-16 12:39:15.477 INFO 14111 --- [ main] c.e.activeissue.ActiveIssueApplication : Starting ActiveIssueApplication on kode12-B250M-D3H with PID 14111 (/home/yprajapati/Downloads/active-issue/target/classes started by yprajapati in /home/yprajapati/Downloads/active-issue)
2019-09-16 12:39:15.493 INFO 14111 --- [ main] c.e.activeissue.ActiveIssueApplication : No active profile set, falling back to default profiles: default
2019-09-16 12:39:16.895 INFO 14111 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)
2019-09-16 12:39:16.919 INFO 14111 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-09-16 12:39:16.919 INFO 14111 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.21]
2019-09-16 12:39:16.991 INFO 14111 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-09-16 12:39:16.991 INFO 14111 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1407 ms
2019-09-16 12:39:17.204 INFO 14111 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-09-16 12:39:17.440 INFO 14111 --- [ main] o.apache.activemq.broker.BrokerService : Using Persistence Adapter: MemoryPersistenceAdapter
2019-09-16 12:39:17.505 INFO 14111 --- [ JMX connector] o.a.a.broker.jmx.ManagementContext : JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
2019-09-16 12:39:17.574 INFO 14111 --- [ main] o.apache.activemq.broker.BrokerService : Apache ActiveMQ 5.15.9 (localhost, ID:kode12-B250M-D3H-39191-1568617757456-0:1) is starting
2019-09-16 12:39:17.577 INFO 14111 --- [ main] o.apache.activemq.broker.BrokerService : Apache ActiveMQ 5.15.9 (localhost, ID:kode12-B250M-D3H-39191-1568617757456-0:1) started
2019-09-16 12:39:17.577 INFO 14111 --- [ main] o.apache.activemq.broker.BrokerService : For help or more information please see: http://activemq.apache.org
2019-09-16 12:39:17.594 INFO 14111 --- [ main] o.a.activemq.broker.TransportConnector : Connector vm://localhost started
2019-09-16 12:39:17.734 INFO 14111 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8081 (http) with context path ''
2019-09-16 12:39:17.737 INFO 14111 --- [ main] c.e.activeissue.ActiveIssueApplication : Started ActiveIssueApplication in 2.872 seconds (JVM running for 3.326)

Related

There's a ghost code in the boot spring What's the problem?

I'm Java Boots Spring, Maven
In the spring,
We added jpa and Thymereaf as dependencies.
And I ran.
However, the working http://localhost:8080/ was disconnected and an error occurred.
The same was true of other dependencies added.
So I deleted it again from pom.xml.
However, the local host did not work again.
And I found something strange in the class I added.
I annotated it, but it didn't work.
The controller worked after deleting the class code.
Even if I deleted the class, the controller worked.
This is a ghost code.
And this is an added class.
/*
package com.team2.crowdfunding.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
#Controller
public class MemberController {
#GetMapping("/save")
public String saveForm() {
return "/user/save";
}
#GetMapping("/")
public String saveForm2() {
System.out.println("겟 처음");
return "/index";
}
}
*/
And this is the spring that outputs.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.5)
2022-11-29 16:01:17.947 INFO 19648 --- [ restartedMain] c.t.c.CrowdfundingApplication : Starting CrowdfundingApplication using Java 18.0.2.1 on DESKTOP-TMFMLDT with PID 19648 (C:\Users\bitcamp\IdeaProjects\crowdfunding2\target\classes started by bitcamp in C:\Users\bitcamp\IdeaProjects\crowdfunding2)
2022-11-29 16:01:17.948 INFO 19648 --- [ restartedMain] c.t.c.CrowdfundingApplication : No active profile set, falling back to 1 default profile: "default"
2022-11-29 16:01:17.988 INFO 19648 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-11-29 16:01:17.988 INFO 19648 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-11-29 16:01:18.463 WARN 19648 --- [ restartedMain] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.team2.crowdfunding]' package. Please check your configuration.
2022-11-29 16:01:18.812 INFO 19648 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-11-29 16:01:18.821 INFO 19648 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-11-29 16:01:18.821 INFO 19648 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.68]
2022-11-29 16:01:18.994 INFO 19648 --- [ restartedMain] org.apache.jasper.servlet.TldScanner : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2022-11-29 16:01:18.998 INFO 19648 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-11-29 16:01:18.999 INFO 19648 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1010 ms
2022-11-29 16:01:19.203 INFO 19648 --- [ restartedMain] f.a.AutowiredAnnotationBeanPostProcessor : Autowired annotation should only be used on methods with parameters: public org.springframework.security.crypto.password.PasswordEncoder com.team2.crowdfunding.controller.UserController.passwordEncoder()
2022-11-29 16:01:19.322 INFO 19648 --- [ restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: ServletContext resource [/index.html]
2022-11-29 16:01:19.452 INFO 19648 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2022-11-29 16:01:19.483 INFO 19648 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2022-11-29 16:01:19.491 INFO 19648 --- [ restartedMain] c.t.c.CrowdfundingApplication : Started CrowdfundingApplication in 1.81 seconds (JVM running for 2.124)
2022-11-29 16:01:22.123 INFO 19648 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-11-29 16:01:22.123 INFO 19648 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-11-29 16:01:22.124 INFO 19648 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
What's the problem?
........................

ShedLock with Spring boot with couchbase

Given my Spring boot application code:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import com.couchbase.client.java.Bucket;
import net.javacrumbs.shedlock.provider.couchbase.javaclient3.CouchbaseLockProvider;
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
#SpringBootApplication
#EnableScheduling
#EnableSchedulerLock(defaultLockAtMostFor = "10m")
public class MythoughtsApplication {
public static void main(String[] args) {
SpringApplication.run(MythoughtsApplication.class, args);
}
#Bean
public CouchbaseLockProvider lockProvider(Bucket bucket) {
return new CouchbaseLockProvider(bucket);
}
}
pom.xml
using the latest shedlock in the below pom.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.guru</groupId>
<artifactId>mythoughts</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mythoughts</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-couchbase</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>java-client</artifactId>
</dependency>
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>core-io</artifactId>
<version>2.3.1</version>
</dependency>
**<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-spring</artifactId>
**<version>4.37.0</version>**
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-couchbase-javaclient3</artifactId>
**<version>4.37.0</version>**
</dependency>**
<dependency>
<groupId>com.unboundid</groupId>
<artifactId>unboundid-ldapsdk</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
couchbase Connection file
#Configuration
public class CouchbaseConfig extends AbstractCouchbaseConfiguration {
#Override
public String getConnectionString() {
// TODO Auto-generated method stub
return "127.0.0.1";
}
#Override
public String getUserName() {
// TODO Auto-generated method stub
return "admin";
}
#Override
public String getPassword() {
// TODO Auto-generated method stub
return "1234";
}
#Override
public String getBucketName() {
// TODO Auto-generated method stub
return "admin";
}
}
controller file
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.guru.mythoughts.service.UserService;
import net.javacrumbs.shedlock.core.LockAssert;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
#RestController
public class UserController {
#Scheduled(cron = "*/5 * * * * *")
#SchedulerLock(name = "scheduledTaskName", lockAtMostFor = "PT5M", lockAtLeastFor = "PT4M")
public void scheduledTask() {
LockAssert.assertLocked();
System.out.println("cloked");
}
}
Output with error:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.0)
2022-06-21 17:36:01.346 INFO 21152 --- [ main] c.zzz.mythoughts.MyApplication : Starting MythoughtsApplication using Java 1.8.0_271 on DESKTOP-O8IM34ASBST with PID 21152 (C:\Users\G\Downloads\mythoughts\target\classes started by in C:\Users\G\Downloads\mythoughts)
2022-06-21 17:36:01.350 INFO 21152 --- [ main] c.zzz.mythoughts.MythoughtsApplication : No active profile set, falling back to 1 default profile: "default"
2022-06-21 17:36:01.889 INFO 21152 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Couchbase repositories in DEFAULT mode.
2022-06-21 17:36:02.033 INFO 21152 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 139 ms. Found 0 Couchbase repository interfaces.
2022-06-21 17:36:02.039 INFO 21152 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Couchbase repositories in DEFAULT mode.
2022-06-21 17:36:02.061 INFO 21152 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 22 ms. Found 1 Couchbase repository interfaces.
2022-06-21 17:36:02.504 INFO 21152 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-06-21 17:36:02.514 INFO 21152 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-06-21 17:36:02.514 INFO 21152 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.63]
2022-06-21 17:36:02.751 INFO 21152 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-06-21 17:36:02.751 INFO 21152 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1346 ms
2022-06-21 17:36:03.445 INFO 21152 --- [ cb-events] com.couchbase.core : [com.couchbase.core][CoreCreatedEvent] {"clientVersion":"3.3.0","clientGitHash":"${buildNumber}","coreVersion":"2.3.1","coreGitHash":"${buildNumber}","userAgent":"couchbase-java/3.3.0 (Windows 10 10.0 amd64; Java HotSpot(TM) 64-Bit Server VM 1.8.0_271-b09)","maxNumRequestsInRetry":32768,"ioEnvironment":{"nativeIoEnabled":true,"eventLoopThreadCount":4,"eventLoopGroups":["NioEventLoopGroup"]},"ioConfig":{"captureTraffic":[],"mutationTokensEnabled":true,"networkResolution":"auto","dnsSrvEnabled":true,"tcpKeepAlivesEnabled":true,"tcpKeepAliveTimeMs":60000,"configPollIntervalMs":2500,"kvCircuitBreakerConfig":"disabled","queryCircuitBreakerConfig":"disabled","viewCircuitBreakerConfig":"disabled","searchCircuitBreakerConfig":"disabled","analyticsCircuitBreakerConfig":"disabled","managerCircuitBreakerConfig":"disabled","eventingCircuitBreakerConfig":"disabled","backupCircuitBreakerConfig":"disabled","numKvConnections":1,"maxHttpConnections":12,"idleHttpConnectionTimeoutMs":4500,"configIdleRedialTimeoutMs":300000,"memcachedHashingStrategy":"StandardMemcachedHashingStrategy"},"compressionConfig":{"enabled":true,"minRatio":0.83,"minSize":32},"securityConfig":{"tlsEnabled":false,"nativeTlsEnabled":true,"hostnameVerificationEnabled":true,"trustCertificates":null,"trustManagerFactory":null,"ciphers":[]},"timeoutConfig":{"kvMs":2500,"kvDurableMs":10000,"managementMs":75000,"queryMs":75000,"viewMs":75000,"searchMs":75000,"analyticsMs":75000,"connectMs":10000,"disconnectMs":10000,"eventingMs":75000,"backupMs":75000},"loggerConfig":{"customLogger":null,"fallbackToConsole":false,"consoleLogLevel":{"name":"INFO","resourceBundleName":"sun.util.logging.resources.logging","localizedName":"INFO"},"consoleLoggerFormatter":"DefaultLoggerFormatter","disableSlf4j":false,"loggerName":"CouchbaseLogger","diagnosticContextEnabled":false},"orphanReporterConfig":{"emitIntervalMs":10000,"sampleSize":10,"queueLength":1024,"enabled":true},"thresholdLoggingTracerConfig":{"enabled":true,"emitIntervalMs":10000,"sampleSize":10,"queueLength":1024,"kvThresholdMs":500,"queryThresholdMs":1000,"searchThresholdMs":1000,"analyticsThresholdMs":1000,"viewThresholdMs":1000},"loggingMeterConfig":{"enabled":true,"emitIntervalMs":600000},"retryStrategy":"BestEffortRetryStrategy","requestTracer":"ThresholdLoggingTracer","meter":"LoggingMeter","numRequestCallbacks":0,"scheduler":"ParallelScheduler","schedulerThreadCount":8,"transactionsConfig":{"durabilityLevel":"MAJORITY","timeoutMs":15000,"cleanupConfig":{"runLostAttemptsCleanupThread":true,"runRegularAttemptsCleanupThread":true,"cleanupWindowMs":60000,"cleanupSet":""},"numAtrs":1024,"metadataCollection":"none","scanConsistency":"none"}} {"coreId":"0xa407cf8700000001","seedNodes":[{"address":"127.0.0.1"}]}
2022-06-21 17:36:03.445 INFO 21152 --- [ cb-events] com.couchbase.transactions : [com.couchbase.transactions][TransactionsStartedEvent] Transactions successfully initialised, regular cleanup enabled=true, lost cleanup enabled=true
2022-06-21 17:36:03.452 INFO 21152 --- [ cb-events] com.couchbase.node : [com.couchbase.node][NodeConnectedEvent] Node connected {"coreId":"0xa407cf8700000001","managerPort":"8091","remote":"127.0.0.1"}
2022-06-21 17:36:03.985 WARN 21152 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'lockProvider' defined in com.guru.mythoughts.MythoughtsApplication: Unsatisfied dependency expressed through method 'lockProvider' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.couchbase.client.java.Bucket' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2022-06-21 17:36:04.026 INFO 21152 --- [ cb-events] com.couchbase.transactions.cleanup : [com.couchbase.transactions.cleanup][LogEvent] Waiting for 1 regular background threads to exit
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] c.c.transactions.cleanup.regular : [com.couchbase.transactions.cleanup.regular][LogEvent] Stopping background cleanup thread for transactions from this client
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] com.couchbase.transactions.cleanup.lost : [com.couchbase.transactions.cleanup.lost][LogEvent] Client d9110 has been told to cancel
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] com.couchbase.transactions.cleanup.lost : [com.couchbase.transactions.cleanup.lost][LogEvent] Client d9110 stopping lost cleanup process, 0 threads running
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] com.couchbase.transactions.cleanup.lost : [com.couchbase.transactions.cleanup.lost][LogEvent] Client d9110 stopped lost cleanup process and removed client from client records
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] com.couchbase.transactions.cleanup : [com.couchbase.transactions.cleanup][LogEvent] Background threads have exitted
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] com.couchbase.node : [com.couchbase.node][NodeDisconnectedEvent][667us] Node disconnected {"coreId":"0xa407cf8700000001","managerPort":"8091","remote":"127.0.0.1"}
2022-06-21 17:36:04.027 INFO 21152 --- [ cb-events] com.couchbase.core : [com.couchbase.core][ShutdownCompletedEvent][19ms] Completed shutdown and closed all open buckets {"coreId":"0xa407cf8700000001"}
2022-06-21 17:36:04.118 INFO 21152 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-06-21 17:36:04.130 INFO 21152 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-06-21 17:36:04.157 ERROR 21152 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method lockProvider in com.guru.mythoughts.MythoughtsApplication required a bean of type 'com.couchbase.client.java.Bucket' that could not be found.
Action:
Consider defining a bean of type 'com.couchbase.client.java.Bucket' in your configuration.
I have given sample code and when I tried to run the application I am getting the above error. I have scheduled a method in controller and it should run for every 5 seconds.
I have followed the above in the given below link
https://gitcode.net/mirrors/lukas-krecan/ShedLock/-/tree/master/providers/couchbase
How can i solve this error?
Autowired the Cluster class and used the cluster to get the bucket details with bean creation in main class which return the bucket object. please see the same code and it is working fine.
#Autowired
Cluster cluster;
#Bean
public Bucket getBucket() {
return cluster.bucket("bucket");
}
}
Another option is to have a Cluster argument to your getBucket() bean method.
#Bean
public Bucket getBucket(Cluster cluster){
return cluster.bucket("myBucket");
}

Rest controller not registerring

I am building an app with JWT security but it keeps ignoring my rest controllers, and not registering the APIs:
Here is my pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.0</version>
<relativePath/>
</parent>
<groupId>org.home</groupId>
<artifactId>testapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>testapp</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.6.3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.25</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<!-- SECURITY -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<!-- JWT -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Here is my application.yml
...
server:
url: https://localhost:8443
port: 8443
ssl:
enabled: true
key-store: classpath:keystore/my_keystore.p12
key-store-password: mySuperPassword#
key-store-type: pkcs12
key-alias: mykey
Here is my main class :
package org.home.mysecurityapplication;
#SpringBootApplication(scanBasePackages={"org.home.**"})
public class MySecureApplication {
public static void main(String[] args) {
SpringApplication.run(MySecureApplication.class, args);
}
}
Here is my web initializer :
package org.home.mysecurityapplication.configuration;
public class WebInitializer implements WebApplicationInitializer {
#Override
public void onStartup(ServletContext sc) {
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.setConfigLocations("org.home.**");
rootContext.refresh();
rootContext.setServletContext(sc);
sc.addListener(new ContextLoaderListener(rootContext));
ServletRegistration.Dynamic apiSR = sc.addServlet("api-dispatcher", new DispatcherServlet(rootContext));
apiSR.setLoadOnStartup(1);
apiSR.addMapping("/");
}
}
Here i am evabling mvc :
package org.home.mysecurityapplication.configuration;
#Configuration
#ComponentScan(basePackages={"org.home.**"})
#EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
}
Here is my security configurer adapter:
package org.home.mysecurityapplication.security;
#Configuration
#EnableWebSecurity
#EnableGlobalMethodSecurity(securedEnabled=true, prePostEnabled=true)
public class MyWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
private final MyAuthenticationProvider myAuthenticationProvider;
private final CredentialsFilter credentialsFilter;
#Autowired
public MyWebSecurityConfigurerAdapter(MyAuthenticationProvider myAuthenticationProvider, CredentialsFilter credentialsFilter) {
this.myAuthenticationProvider = myAuthenticationProvider;
this.credentialsFilter = credentialsFilter;
}
#Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers(HttpMethod.POST, "/roles").permitAll() // everyone should access login-api
;
// disable csrf
http.csrf().disable();
// app session is stateless
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
http.addFilterBefore(credentialsFilter, UsernamePasswordAuthenticationFilter.class);
http.requiresChannel(channel -> channel.anyRequest().requiresSecure());
}
#Override
protected void configure(AuthenticationManagerBuilder auth) {
auth.eraseCredentials(false)
.authenticationProvider(myAuthenticationProvider);
}
}
Here is my controller:
package org.home.mysecurityapplication.security.controller;
#RestController
#RequestMapping(value="")
public class SecurityController {
#Autowired
private SecurityService securityServiceImpl;
private static final Logger logger = LoggerFactory.getLogger(SecurityController.class);
#RequestMapping(value = "/roles", method = RequestMethod.POST, consumes=MediaType.APPLICATION_JSON_VALUE, produces=MediaType.TEXT_PLAIN_VALUE)
#ResponseStatus(HttpStatus.OK)
public #ResponseBody
String generateToken(#RequestBody CredentialsDTO credentials) throws MyRestPreconditionsException {
logger.debug("User "+credentials.getUsername()+" logging in ...");
String token = securityServiceImpl.generateTokenForUser(credentials);
logger.debug("User "+credentials.getUsername()+" log in successfull.");
return token;
}
}
As you can see, rest controller /roles does not register :(
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.6.0)
2022-02-15 22:37:37.906 INFO 10720 --- [ main] l.h.myapp.MySecurityApplication : Starting MySecurityApplication using Java 17.0.2 on HAL-9015 with PID 10720 (C:\Users\Lazaruss\IdeaProjects\greenhealth2\target\classes started by Lazaruss in C:\Users\Lazaruss\IdeaProjects\greenhealth2)
2022-02-15 22:37:37.909 INFO 10720 --- [ main] l.h.myapp.MySecurityApplication : No active profile set, falling back to default profiles: default
2022-02-15 22:37:38.629 INFO 10720 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-02-15 22:37:38.712 INFO 10720 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 68 ms. Found 1 JPA repository interfaces.
2022-02-15 22:37:39.879 INFO 10720 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8443 (https)
2022-02-15 22:37:39.894 INFO 10720 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-02-15 22:37:39.894 INFO 10720 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.55]
2022-02-15 22:37:40.036 INFO 10720 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-02-15 22:37:40.036 INFO 10720 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2067 ms
2022-02-15 22:37:40.330 INFO 10720 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-02-15 22:37:40.406 INFO 10720 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.1.Final
2022-02-15 22:37:40.652 INFO 10720 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2022-02-15 22:37:41.061 INFO 10720 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2022-02-15 22:37:41.840 INFO 10720 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-02-15 22:37:41.851 INFO 10720 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-02-15 22:37:42.435 WARN 10720 --- [ 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
2022-02-15 22:37:42.957 INFO 10720 --- [ main] o.s.s.w.a.c.ChannelProcessingFilter : Validated configuration attributes
2022-02-15 22:37:42.959 INFO 10720 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.access.channel.ChannelProcessingFilter#7af0693b, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#110318a7, org.springframework.security.web.context.SecurityContextPersistenceFilter#265c0752, org.springframework.security.web.header.HeaderWriterFilter#3c9cfcde, org.springframework.security.web.authentication.logout.LogoutFilter#2e5c7cd5, lazaruss.home.myapp.security.CredentialsFilter#6dc2e473, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#7a75183d, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#6f695077, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#42ac309, org.springframework.security.web.session.SessionManagementFilter#799fc4c9, org.springframework.security.web.access.ExceptionTranslationFilter#34fcc5e3, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#152dbf8e]
2022-02-15 22:37:43.681 INFO 10720 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8443 (https) with context path ''
2022-02-15 22:37:43.690 INFO 10720 --- [ main] l.h.myapp.MySecurityApplication : Started MySecurityApplication in 6.437 seconds (JVM running for 7.137)
2022-02-15 22:37:49.009 INFO 10720 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
I suspect you are having a problem with the scanned packages.
#SpringBootApplication encapsulates #Configuration, #EnableAutoConfiguration, and #ComponentScan annotations with their default attributes. The default value for #ComponentScan means that all the sub packages on the package the #ComponentScan is used are scanned. That is why it is usually a good practice to include the main class in the base package of the project, so please make sure it is located there.
Having written this, try the following (drop scanBasePackages attribute and #ComponentScan annotation):
#SpringBootApplication
public class MySecureApplication {
public static void main(String[] args) {
SpringApplication.run(MySecureApplication.class, args);
}
}
#Configuration
#EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
}

Print Hello World before Spring boot application start

Hello guys I want to ask if its possible to execute the print before the spring boot application start?
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class SampleApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(SampleApplication.class, args);
}
#Override
public void run(String... args) {
System.out.print("I would be appear in log first before spring application starts");
}
}
My problem of my code it will display the print after the spring boot application start
Current Output
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.2)
2021-09-26 06:13:53.267 INFO 10352 --- [ main] c.s.d.SampleApplicationTests : Starting SampleApplicationTests using Java 11.0.11 on User-Desktop with PID 10352 (started by ???)
2021-09-26 06:13:53.277 INFO 10352 --- [ main] c.s.d.Sample
ApplicationTests : No active profile set, falling back to default profiles: default
2021-09-26 06:13:54.879 INFO 10352 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-09-26 06:13:55.051 INFO 10352 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 148 ms. Found 9 JPA repository interfaces.
2021-09-26 06:13:57.118 INFO 10352 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-09-26 06:13:57.299 INFO 10352 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-09-26 06:13:57.563 INFO 10352 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-09-26 06:13:58.268 INFO 10352 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-09-26 06:14:03.062 INFO 10352 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-09-26 06:14:03.094 INFO 10352 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2021-09-26 06:14:08.430 INFO 10352 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-09-26 06:14:08.453 INFO 10352 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-09-26 06:14:15.216 INFO 10352 --- [ main] c.s.d.SampleApplicationTests : Started SampleApplicationTests in 22.607 seconds (JVM running for 24.991)
I would be appear in log first before spring application starts
Why don't you just print the log in main method before run invocation?
#SpringBootApplication
public class SampleApplication implements CommandLineRunner {
public static void main(String[] args) {
System.out.print("I would be appear in log first before spring application starts");
SpringApplication.run(SampleApplication.class, args);
}
#Override
public void run(String... args) {
}
}
run method is a method from Spring Boot so everything you do there is done after Spring Boot's start.
If by before the spring boot application start you mean application context startup, then yes, the easiest (for singletons beans, anyway) being to annotate your method with #PostConstruct.
#PostConstruct
public void init() {
//do something
}
Check for the #PostConstruct for e.g here.

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