Apache Camel route definition in Spring XML and run with SpringBoot - java

I have defined Camel routes in 2 XML files, and would like to run the application using Spring Boot component.
Here is the main code:
Object[] sources = {
"META-INF/spring/propertiesContext.xml",
"META-INF/spring/concurrent-route-context.xml"
};
ApplicationContext applicationContext = new SpringApplication(sources).run(args);
CamelSpringBootApplicationController applicationController = applicationContext
.getBean(CamelSpringBootApplicationController.class);
applicationController.blockMainThread();
However, I got the following error during startup
2015-08-19 14:54:04.203 ERROR 13812 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at com.oocl.b2b.camel.spring.boot.test.ConcurrencyTest.testSpringBoot(ConcurrencyTest.java:44)
at com.oocl.b2b.camel.spring.boot.test.ConcurrencyTest.main(ConcurrencyTest.java:29)
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:183)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:156)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 6 common frames omitted
If I update my pom.xml by using "spring-boot-starter" instead of "spring-boot-starter-web", I got another exception
2015-08-19 15:02:06.930 INFO 4528 --- [ main] o.a.camel.spring.SpringCamelContext : Apache Camel 2.15.2 (CamelContext: concurrent-route-context) started in 1.320 seconds
2015-08-19 15:02:06.932 INFO 4528 --- [ main] c.o.b.c.s.boot.test.ConcurrencyTest : Started ConcurrencyTest in 2.615 seconds (JVM running for 2.867)
Exception in thread "main" 2015-08-19 15:02:06.933 INFO 4528 --- [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#142f024: startup date [Wed Aug 19 15:02:05 CST 2015]; root of context hierarchy
2015-08-19 15:02:06.934 INFO 4528 --- [ Thread-1] o.a.camel.spring.SpringCamelContext : Apache Camel 2.15.2 (CamelContext: concurrent-route-context) is shutting down
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.apache.camel.spring.boot.CamelSpringBootApplicationController] is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:371)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:331)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:968)
at com.oocl.b2b.camel.spring.boot.test.ConcurrencyTest.testSpringBoot(ConcurrencyTest.java:47)
at com.oocl.b2b.camel.spring.boot.test.ConcurrencyTest.main(ConcurrencyTest.java:30)
2015-08-19 15:02:06.937 INFO 4528 --- [ Thread-1] o.a.camel.impl.DefaultShutdownStrategy : Starting to graceful shutdown 4 routes (timeout 300 seconds)
Would anyone please advice if I have made any mis-config?

I don't know if you've found a solution for this yet, but try this for your application class:
#Configuration
#EnableAutoConfiguration
public class TestSpringBootApplication
{
public static void main(String... args)
{
(new SpringApplication("META-INF/spring/propertiesContext.xml",
"META-INF/spring/concurrent-route-context.xml")).run(args);
}
}

Related

Spring Boot 2.3 fails to start when spring.jpa.hibernate.ddl-auto equals to validate

I have a Spring boot: 2.3.0.RELEASE application with Flyway: 6.4.1 and Hibernate: hibernate-core: 5.4.22.Final, hibernate-validator: 6.1.5.Final, hibernate-commons-annotations: 5.1.0.Final.
I tried searching for errors but cannot find a solution. I tried applying this answer, but whenever spring.jpa.hibernate.ddl-auto=validate is set, it doesn't work if I use none, drop-create value everything back to the norm.
I run MySQL 5.7 in Docker, and the database with tables is there.
The error is below:
ConfigServletWebServerApplicationContext : Exception encountered
during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'requestMappingHandlerAdapter' defined
in class path resource
[org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]:
Unsatisfied dependency expressed through method
'requestMappingHandlerAdapter' parameter 1; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'mvcConversionService' defined in class path
resource
[org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate
[org.springframework.format.support.FormattingConversionService]:
Factory method 'mvcConversionService' threw exception; nested
exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'customerRepository' defined in
org.cloudwheel.files.configuration.customer.persistence.CustomerRepository
defined in #EnableJpaRepositories declared on
JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot
resolve reference to bean 'jpaMappingContext' while setting bean
property 'mappingContext'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'jpaMappingContext': Invocation of init method
failed; nested exception is javax.persistence.PersistenceException:
[PersistenceUnit: default] Unable to build Hibernate SessionFactory;
nested exception is
org.hibernate.tool.schema.spi.SchemaManagementException:
Schema-validation: missing table [my_files]
How can I debug this? I see many such issues, but none of the solutions worked for me.
NOTE: The table my_files is present. I can verify this both via IntelliJ and MySQL Workbench. Also, I don't want to downgrade if possible.
UPDATE:
I am sure that a database isn't a problem:
2020-12-01 14:24:04.795 INFO 23295 --- [ restartedMain]
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with
port(s): 8080 (http) 2020-12-01 14:24:04.800 INFO 23295 --- [
restartedMain] o.apache.catalina.core.StandardService : Starting
service [Tomcat] 2020-12-01 14:24:04.800 INFO 23295 --- [
restartedMain] org.apache.catalina.core.StandardEngine : Starting
Servlet engine: [Apache Tomcat/9.0.35] 2020-12-01 14:24:04.895 INFO
23295 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] :
Initializing Spring embedded WebApplicationContext 2020-12-01
14:24:04.895 INFO 23295 --- [ restartedMain]
o.s.web.context.ContextLoader : Root WebApplicationContext:
initialization completed in 1762 ms 2020-12-01 14:24:07.982 INFO
23295 --- [ restartedMain] o.f.c.internal.license.VersionPrinter :
Flyway Community Edition 6.4.1 by Redgate 2020-12-01 14:24:07.986
INFO 23295 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource
: HikariPool-1 - Starting... 2020-12-01 14:24:08.090 INFO 23295 --- [
restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1
Start completed. 2020-12-01 14:24:08.113 INFO 23295 --- [ restartedMain] o.f.c.internal.database.DatabaseFactory : Database:
jdbc:mysql://localhost:3307/files (MySQL 5.7) 2020-12-01 14:24:08.186
INFO 23295 --- [ restartedMain] o.f.core.internal.command.DbValidate
: Successfully validated 13 migrations (execution time 00:00.029s)
2020-12-01 14:24:08.199 INFO 23295 --- [ restartedMain]
o.f.core.internal.command.DbMigrate : Current version of schema
files: 1.13 2020-12-01 14:24:08.200 INFO 23295 --- [
restartedMain] o.f.core.internal.command.DbMigrate : Schema
files is up to date. No migration necessary. 2020-12-01
14:24:08.268 INFO 23295 --- [ restartedMain]
o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing
ExecutorService 'applicationTaskExecutor' 2020-12-01 14:24:08.281
INFO 23295 --- [ restartedMain] o.s.s.c.ThreadPoolTaskScheduler
: Initializing ExecutorService 'taskScheduler' 2020-12-01 14:24:08.330
INFO 23295 --- [ task-1]
o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing
PersistenceUnitInfo [name: default] 2020-12-01 14:24:08.374 INFO
23295 --- [ task-1] org.hibernate.Version :
HHH000412: Hibernate ORM core version 5.4.22.Final
The exception says org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [my_files].
You say that the database my_files is present, but hibernate needs a table my_files to be present - for example you used annotation #Table(name = "my_files") or you have entity with name MyFiles.
Check whether the database contains the table my_files.
As #M.Deinum mentioned in his comments Flyway and Hibernate might not have been connected to the same datasource. In my case, it was because of hibernate.temp.use_jdbc_metadata_defaults=true. As soon as I removed this property, everything started working.

Application is working as expected but when i conterize app with Docker it cannot access Cassandra container

I got a problem with my application. Everything has been working fine till I conterized App with Docker.
I Have Docker container with Cassandra instance in there docker run -p 9042:9042 --name cassandra cassandra:latest
*When I run my app in IntelliJ or run by cmd java -jar myjar.jar it works fine. The problem occurs when
I trying to use Docker or Docker-compose to start the app docker run -p 8080:8080 --name api {image here} or docker-compose up
Docker File:
FROM openjdk:8
COPY . /target/myjar.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","target/myjar.jar"]
Docker-Compose
version: '3'
services:
app:
build: ./app
ports:
- "8080:8080"
depends-on:
-cassandra
cassandra:
container_name 'cassandra'
image: cassandra
ports:
- "9042:9042"
What I have tried to solve the problem:
changing application ports
building docker and docker-compose file in diffrent way.
application.properties
spring.data.cassandra.keyspace-name=message
spring.data.cassandra.schema-action=create_if_not_exists
spring.data.cassandra.contact-points=127.0.0.1
spring.data.cassandra.port=9042
the error when I try to run container from image (Fragment)
2020-06-13 11:42:53.320 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Reactive Cassandra repositories in DEFAULT mode.
2020-06-13 11:42:53.379 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 51ms. Found 0 Reactive Cassandra repository interfaces.
2020-06-13 11:42:53.387 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Cassandra repositories in DEFAULT mode.
2020-06-13 11:42:53.406 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 18ms. Found 1 Cassandra repository interfaces.
2020-06-13 11:42:54.030 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-06-13 11:42:54.050 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-06-13 11:42:54.050 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.35]
2020-06-13 11:42:54.146 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-06-13 11:42:54.146 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1734 ms
2020-06-13 11:42:54.611 INFO 1 --- [ main] c.d.o.d.i.core.DefaultMavenCoordinates : DataStax Java driver for Apache Cassandra(R) (com.datastax.oss:java-driver-core) version 4.6.1
2020-06-13 11:42:55.364 INFO 1 --- [ s0-admin-0] c.d.oss.driver.internal.core.time.Clock : Using native clock for microsecond precision
2020-06-13 11:42:55.371 INFO 1 --- [ s0-admin-0] c.d.o.d.i.core.metadata.MetadataManager : [s0] No contact points provided, defaulting to /127.0.0.1:9042
2020-06-13 11:42:55.567 WARN 1 --- [ s0-admin-1] c.d.o.d.i.c.control.ControlConnection : [s0] Error connecting to Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=530346a1), trying next node (ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (java.nio.channels.ClosedChannelException))
2020-06-13 11:42:55.586 WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageApi' defined in URL [jar:file:/asrecruitment-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/mycompany/asrecruitment/api/MessageApi.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageService' defined in URL [jar:file:/asrecruitment-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/mycompany/asrecruitment/service/MessageService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageRepo' defined in com.mycompany.asrecruitment.repository.MessageRepo defined in #EnableCassandraRepositories declared on CassandraRepositoriesRegistrar.EnableCassandraRepositoriesConfiguration: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig': Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=530346a1): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (java.nio.channels.ClosedChannelException)]
2020-06-13 11:42:55.590 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-06-13 11:42:55.613 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-13 11:42:55.636 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageApi' defined in URL [jar:file:/asrecruitment-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/mycompany/asrecruitment/api/MessageApi.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageService' defined in URL [jar:file:/asrecruitment-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/mycompany/asrecruitment/service/MessageService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageRepo' defined in com.mycompany.asrecruitment.repository.MessageRepo defined in #EnableCassandraRepositories declared on CassandraRepositoriesRegistrar.EnableCassandraRepositoriesConfiguration: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig': Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=530346a1): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (java.nio.channels.ClosedChannelException)]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:228) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:895) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at com.mycompany.asrecruitment.app.main(app.java:12) [classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_212]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [asrecruitment-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:109) [asrecruitment-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [asrecruitment-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [asrecruitment-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageService' defined in URL [jar:file:/asrecruitment-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/mycompany/asrecruitment/service/MessageService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageRepo' defined in com.mycompany.asrecruitment.repository.MessageRepo defined in #EnableCassandraRepositories declared on CassandraRepositoriesRegistrar.EnableCassandraRepositoriesConfiguration: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig': Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=530346a1): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (java.nio.channels.ClosedChannelException)]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:228) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1306) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1226) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
... 28 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageRepo' defined in com.mycompany.asrecruitment.repository.MessageRepo defined in #EnableCassandraRepositories declared on CassandraRepositoriesRegistrar.EnableCassandraRepositoriesConfiguration: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig': Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=530346a1): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (java.nio.channels.ClosedChannelException)]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:342) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1699) ~[spr
** Proper run java -jar **
2020-06-13 13:35:19.461 INFO 12088 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Reactive Cassandra repositories in DEFAULT mode.
2020-06-13 13:35:19.593 INFO 12088 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 116ms. Found 0 Reactive Cassandra repository interfaces.
2020-06-13 13:35:19.609 INFO 12088 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Cassandra repositories in DEFAULT mode.
2020-06-13 13:35:19.630 INFO 12088 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 23ms. Found 1 Cassandra repository interfaces.
2020-06-13 13:35:21.111 INFO 12088 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-06-13 13:35:21.134 INFO 12088 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-06-13 13:35:21.134 INFO 12088 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.35]
2020-06-13 13:35:21.296 INFO 12088 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-06-13 13:35:21.296 INFO 12088 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3376 ms
2020-06-13 13:35:21.945 INFO 12088 --- [ main] c.d.o.d.i.core.DefaultMavenCoordinates : DataStax Java driver for Apache Cassandra(R) (com.datastax.oss:java-driver-core) version 4.6.1
2020-06-13 13:35:22.985 INFO 12088 --- [ s0-admin-0] c.d.oss.driver.internal.core.time.Clock : Using native clock for microsecond precision
2020-06-13 13:35:22.985 INFO 12088 --- [ s0-admin-0] c.d.o.d.i.core.metadata.MetadataManager : [s0] No contact points provided, defaulting to /127.0.0.1:9042
2020-06-13 13:35:23.961 INFO 12088 --- [ s0-io-0] c.d.o.d.i.core.channel.ChannelFactory : [s0] Failed to connect with protocol DSE_V2, retrying with DSE_V1
2020-06-13 13:35:23.979 INFO 12088 --- [ s0-io-1] c.d.o.d.i.core.channel.ChannelFactory : [s0] Failed to connect with protocol DSE_V1, retrying with V4
2020-06-13 13:35:24.387 INFO 12088 --- [ s0-io-2] c.d.oss.driver.api.core.uuid.Uuids : PID obtained through native call to getpid(): 12088
2020-06-13 13:35:26.186 INFO 12088 --- [ s1-admin-0] c.d.oss.driver.internal.core.time.Clock : Using native clock for microsecond precision
2020-06-13 13:35:26.186 INFO 12088 --- [ s1-admin-0] c.d.o.d.i.core.metadata.MetadataManager : [s1] No contact points provided, defaulting to /127.0.0.1:9042
2020-06-13 13:35:26.214 INFO 12088 --- [ s1-io-0] c.d.o.d.i.core.channel.ChannelFactory : [s1] Failed to connect with protocol DSE_V2, retrying with DSE_V1
2020-06-13 13:35:26.231 INFO 12088 --- [ s1-io-1] c.d.o.d.i.core.channel.ChannelFactory : [s1] Failed to connect with protocol DSE_V1, retrying with V4
2020-06-13 13:35:30.078 INFO 12088 --- [ s2-admin-0] c.d.oss.driver.internal.core.time.Clock : Using native clock for microsecond precision
2020-06-13 13:35:31.698 INFO 12088 --- [ s2-admin-0] c.d.o.d.i.core.metadata.MetadataManager : [s2] No contact points provided, defaulting to /127.0.0.1:9042
2020-06-13 13:35:31.720 INFO 12088 --- [ s2-io-0] c.d.o.d.i.core.channel.ChannelFactory : [s2] Failed to connect with protocol DSE_V2, retrying with DSE_V1
2020-06-13 13:35:31.732 INFO 12088 --- [ s2-io-1] c.d.o.d.i.core.channel.ChannelFactory : [s2] Failed to connect with protocol DSE_V1, retrying with V4
2020-06-13 13:35:32.618 INFO 12088 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-06-13 13:35:32.943 INFO 12088 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-06-13 13:35:32.946 INFO 12088 --- [ main] com.mycompany.asrecruitment.app : Started app in 16.206 seconds (JVM running for 17.064)
The problem here is your application isn't connecting with the Cassadra's DB image.
2020-06-13 11:42:55.567 WARN 1 --- [ s0-admin-1]
c.d.o.d.i.c.control.ControlConnection : [s0] Error connecting to
Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=530346a1), trying
next node (ConnectionInitException: [s0|control|connecting...]
Protocol initialization request, step 1 (OPTIONS): failed to send
request (java.nio.channels.ClosedChannelException))
Fist, in your docker-compose.yml, you need to create an environment variable to be the cassandra host and then set your application.properties.
Docker-compose.yml
version: '3'
services:
app:
build: ./app
ports:
- "8086:8080"
depends-on:
-cassandra
cassandra:
container_name 'cassandra'
image: cassandra
ports:
- "9044:9042"
environment:
- CASSANDRA_HOST=cassandra
P.S. You can change the first port number to not confuse, but it's not a mistake.
application.properties
spring.data.cassandra.keyspace-name=message
spring.data.cassandra.schema-action=create_if_not_exists
spring.data.cassandra.contact-points=${CASSANDRA_HOST}
spring.data.cassandra.port=9042
It is important to check the cluster's name (spring.data.cassandra.cluster = <name>) in the cassandra.yaml inside the cassandra's image. It should be the same as in your application's image.

Spring Boot Start Up

Im trying to learn spring and the tutorial asked me to run mvn spring-boot:run.
However, i have the following error message(I attached a snippet). Please advise. All i have done is create a project from spring.io 's website then run mvn spring-boot:run
2019-11-30 14:45:03.338 INFO 14260 --- [ restartedMain] com.portal.VPortal.VPortalApplication : Starting VPortalApplication on Max with PID 14260 (C:\Users\Max\Documents\VPortal\target\classes started
by Max in C:\Users\Max\Documents\VPortal)
2019-11-30 14:45:03.338 INFO 14260 --- [ restartedMain] com.portal.VPortal.VPortalApplication : No active profile set, falling back to default profiles: default
2019-11-30 14:45:03.368 INFO 14260 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-11-30 14:45:03.368 INFO 14260 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-11-30 14:45:04.029 INFO 14260 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.spri
ngframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-11-30 14:45:04.329 INFO 14260 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-11-30 14:45:04.335 INFO 14260 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-11-30 14:45:04.335 INFO 14260 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.27]
2019-11-30 14:45:04.386 INFO 14260 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-11-30 14:45:04.386 INFO 14260 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1018 ms
2019-11-30 14:45:04.477 ERROR 14260 --- [ restartedMain] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message:
Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServle
tEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframewo
rk.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error c
reating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through metho
d 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/sprin
gframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed
to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.Unsatisfie
dDependencyException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthContributorAutoConfiguration': Unsatisfied dependency expressed through constructor par
ameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/Da
taSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariData
Source]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: org.postgres.Driver
2019-11-30 14:45:04.493 INFO 14260 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-11-30 14:45:04.500 WARN 14260 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.conte
xt.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2019-11-30 14:45:04.510 INFO 14260 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-11-30 14:45:04.520 ERROR 14260 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
I found the error. In my application.yml, file I changed the org.postgres.Driver to org.postgresql.Driver .

java.lang.IllegalArgumentException: ResourceLoader must not be null in Spring

I want to run https://github.com/spring-projects/spring-security-kerberos on my machine (via Intellij idea). The module I am trying to build and run is sec-server-spnego-form-auth, but I keep getting java.lang.IllegalArgumentException: ResourceLoader must not be null as well as java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context, which comes because of the first error, I guess.
Any ideas what might be wrong here?
Stacktrace:
2017-08-22 13:28:44.457 ERROR 15064 --- [ main] o.s.boot.SpringApplication : Application startup failed
java.lang.IllegalArgumentException: ResourceLoader must not be null
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.boot.autoconfigure.AutoConfigurationSorter.<init>(AutoConfigurationSorter.java:53)
at org.springframework.boot.autoconfigure.EnableAutoConfigurationImportSelector.selectImports(EnableAutoConfigurationImportSelector.java:72)
at org.springframework.context.annotation.ConfigurationClassParser.processImport(ConfigurationClassParser.java:393)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:205)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:164)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:139)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:284)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:225)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:632)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at demo.app.Application.main(Application.java:13)
2017-08-22 13:28:44.457 INFO 15064 --- [ main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#ec4505: startup date [Tue Aug 22 13:28:44 EEST 2017]; root of context hierarchy
2017-08-22 13:28:44.458 WARN 15064 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#ec4505: startup date [Tue Aug 22 13:28:44 EEST 2017]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1051)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:150)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1012)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:343)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at demo.app.Application.main(Application.java:13)
2017-08-22 13:28:44.459 WARN 15064 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#ec4505: startup date [Tue Aug 22 13:28:44 EEST 2017]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1059)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:150)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1012)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:343)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at demo.app.Application.main(Application.java:13)
Exception in thread "main" java.lang.IllegalArgumentException: ResourceLoader must not be null
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.boot.autoconfigure.AutoConfigurationSorter.<init>(AutoConfigurationSorter.java:53)
at org.springframework.boot.autoconfigure.EnableAutoConfigurationImportSelector.selectImports(EnableAutoConfigurationImportSelector.java:72)
at org.springframework.context.annotation.ConfigurationClassParser.processImport(ConfigurationClassParser.java:393)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:205)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:164)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:139)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:284)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:225)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:632)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at demo.app.Application.main(Application.java:13)
2017-08-22 13:28:44.459 INFO 15064 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#192cfe: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,application,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,mvcConfig,webSecurityConfig]; root of factory hierarchy
Process finished with exit code 1
Well, I solved it just by taking only the module I need and copying it to a fresh project. Also, I had to use application.properties instead of .yml file, and it worked like a charm.
Not the best solution but it worked.

Embedded Tomcat won't listen to port 80 in AWS Elastic Beanstalk

I'm launching a Spring Boot .jar with Embedded Tomcat to an Elastic Beanstalk (Java) instance.
server.port=80 in the configuration file, however EB won't let Tomcat bind to port 80.
What's preventing Tomcat from listening to port 80 and how do I fix it?
Here's the pertinent section of the logs:
Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat"; Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1000) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
... 21 common frames omitted
Caused by: java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_121]
at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_121]
at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_121]
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_121]
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_121]
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:210) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:980) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:573) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
at org.apache.catalina.connector.Connector.startInternal(Connector.java:993) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
... 22 common frames omitted
2017-02-09 09:05:28.126 INFO 2451 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2017-02-09 09:05:28.156 INFO 2451 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-02-09 09:05:28.167 ERROR 2451 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 80 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 80, or configure this application to listen on another port.
2017-02-09 09:05:28.175 INFO 2451 --- [ main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#5387f9e0: startup date [Thu Feb 09 09:05:19 UTC 2017]; root of context hierarchy
2017-02-09 09:05:28.178 INFO 2451 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
I assume topic starter already resolved this problem, but I'll post my solution here for the new people who'll be stuck on the same issue.
I've made my Spring Boot application accessible from port 80 on AWS Elastic Beanstalk by setting environment property SERVER_PORT to 5000 (you can set it in "Configuration" > "Software Configuration").
Idea taken from here

Categories