spring cloud gateway exception Illegal character in authority at index error - spring

I'm trying to setup spring cloud gateway for a api, but seeing an illegal argument exception with the route uri. Any help is appreciated.
Running this app on Ubuntu and I got the same exception with both Spring boot 2.1.4 and 2.1.5.
This is how configured my application.properties file in the gateway app.
eureka.client.serviceUrl.defaultZone = http://localhost:8761/eureka
spring.application.name= api-gateway
spring.cloud.gateway.discovery.locator.enabled=true
spring.cloud.gateway.discovery.locator.lowerCaseServiceId=true
spring.cloud.gateway.routes[0].id=reporting-service
spring.cloud.gateway.routes[0].uri = lb://reporting-service
spring.cloud.gateway.routes[0].predicates[0]=Path=/api/reporting/**
This is the exception that I see.
2019-06-06 09:56:17.304 WARN 4561 --- [ main] onfigReactiveWebServerApplicationContext : Exception encountered during context initializ ation - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Illegal character in authority at in dex 5: lb://REPORTING-SERVICE
2019-06-06 09:56:17.316 INFO 4561 --- [ main] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2019-06-06 09:56:20.317 INFO 4561 --- [ main] com.netflix.discovery.DiscoveryClient : Unregistering ...
2019-06-06 09:56:20.324 INFO 4561 --- [ main] com.netflix.discovery.DiscoveryClient : DiscoveryClient_API-GATEWAY/apitest.****.*****.com:api-gateway:8080 - deregister status: 200
2019-06-06 09:56:20.342 INFO 4561 --- [ main] com.netflix.discovery.DiscoveryClient : Completed shut down of DiscoveryClient
2019-06-06 09:56:20.353 INFO 4561 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-06 09:56:20.365 ERROR 4561 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is reactor.core.Ex ceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Illegal character in authority at index 5: lb://REPORTING-SERVICE
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.1.6.RELEAS E.jar!/:5.1.6.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.1.6.RELE ASE.jar!/:5.1.6.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context -5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.1.6.REL EASE.jar!/:5.1.6.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.1.6.RELE ASE.jar!/:5.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:893) ~[spring-context-5.1. 6.RELEASE.jar!/:5.1.6.RELEASE]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.finishRefresh(ReactiveWebServerApplicationContext.jav a:121) ~[spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.1.6.RELE ASE.jar!/:5.1.6.RELEASE]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:67) ~[spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.4.RELEASE.jar!/:2.1.4.RELEASE]

Fix the property:
spring.cloud.gateway.routes[0].predicates=Path=/api/reporting/**
spring.cloud.gateway.routes[0].uri=lb://reporting-service
Reference : issue-56480485

Related

Bugs started how do I fix? Error (Spring Boot + Thymeleaf)

ERROR 8164 --- [ restartedMain] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
2021-01-24 16:55:32.459 ERROR 8164 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
2021-01-24 16:55:32.606 ERROR 8164 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
Bugs started how do I fix?

Failed creating bean flywayInitializer - SpringBoot 2.3.0

I am trying to migrate a project from spring boot 2.0.0 to 2.3.0 with H2 database and Hibernate and I keep getting an error
on bean creation for flywayInitializer:
2020-11-20 14:05:51.999 INFO 4632 --- [ main] c.z.h.HikariDataSource : HikariPool-1 - Starting...
2020-11-20 14:05:53.125 INFO 4632 --- [ main] c.z.h.HikariDataSource : HikariPool-1 - Start completed.
2020-11-20 14:05:53.157 INFO 4632 --- [ main] o.s.b.a.h.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:D:/Workspace/username/projectName_db/projectName_db'
2020-11-20 14:05:53.313 INFO 4632 --- [ main] w.s.s.SecurityFilterProviderCollection : using 'waffle.servlet.spi.NegotiateSecurityFilterProvider'
2020-11-20 14:05:53.453 INFO 4632 --- [ main] s.s.l.DefaultSpringSecurityContextSource : URL 'ldaps://0200P-CDC201.banst-s.banst-pt.int:636/', root DN is ''
2020-11-20 14:05:53.641 INFO 4632 --- [ main] o.s.b.w.s.RegistrationBean : Filter negotiateSecurityFilter was not registered (disabled)
2020-11-20 14:05:53.922 INFO 4632 --- [ main] o.f.c.i.l.VersionPrinter : Flyway Community Edition 6.4.1 by Redgate
2020-11-20 14:05:53.953 INFO 4632 --- [ main] o.f.c.i.d.DatabaseFactory : Database: jdbc:h2:D:/Workspace/username/projectName_db/projectName_db (H2 1.4)
2020-11-20 14:05:54.203 INFO 4632 --- [ main] o.f.c.i.c.DbMigrate : Current version of schema "FLAYWAY": 1.18.0
2020-11-20 14:05:54.219 WARN 4632 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Schema "FLAYWAY" contains a failed migration to version 1.18.0 !
2020-11-20 14:05:54.219 INFO 4632 --- [ main] c.z.h.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-11-20 14:05:54.266 INFO 4632 --- [ main] c.z.h.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-11-20 14:05:54.282 INFO 4632 --- [ main] o.a.c.c.StandardService : Stopping service [Tomcat]
2020-11-20 14:05:54.297 INFO 4632 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-11-20 14:05:54.328 ERROR 4632 --- [ main] o.s.b.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Schema "FLAYWAY" contains a failed migration to version 1.18.0 !
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
Caused by: org.flywaydb.core.api.FlywayException: Schema "FLAYWAY" contains a failed migration to version 1.18.0 !
at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:227) ~[flyway-core-6.4.1.jar:?]
... 19 more
My application.yml has the following configurations
spring:
main:
banner-mode: "off"
allow-bean-definition-overriding: true
h2:
console:
enabled: true
settings:
web-allow-others: true
jackson:
serialization:
WRITE_DATES_AS_TIMESTAMPS: false
jpa:
hibernate:
ddl-auto: validate
database: default
show-sql: false
quartz:
job-store-type: memory
jdbc:
initialize-schema: never
flyway:
locations: "classpath:database/projectName/migrations/{vendor}/"
schemas: "FLAYWAY"
table: "schema_version"
baseline-on-migrate: true
validate-on-migrate: false
Does anyone know what I can I do in this case?
The error states that there is a failed migration:
Schema "FLAYWAY" contains a failed migration to version 1.18.0 !
Try deleting the failed entry and run again.
Or try to run:
mvn flyway:validate -Dflyway.configFile=myFlywayConfig.properties
to validate everything first.

Spring Boot WSDL SOAP web service application does not start

I am trying to start a WSDL-SOAP web service application but it doesn't start. Gives the below exception:
2020-11-30 22:28:12.521 INFO 97564 --- [ main] c.c.ws.soap.SpringBootApplicationRun : Starting SpringBootApplicationRun on Ramazans-MacBook-Pro.local with PID 97564 (started by rdemir in /Users/rdemir/Projects/METU/SM704/Project Phase 2)
2020-11-30 22:28:12.525 INFO 97564 --- [ main] c.c.ws.soap.SpringBootApplicationRun : No active profile set, falling back to default profiles: default
2020-11-30 22:28:13.304 INFO 97564 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$6d2d075b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-11-30 22:28:13.330 INFO 97564 --- [ main] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2020-11-30 22:28:13.597 INFO 97564 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-11-30 22:28:13.623 INFO 97564 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-11-30 22:28:13.623 INFO 97564 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.13
2020-11-30 22:28:13.639 INFO 97564 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/rdemir/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2020-11-30 22:28:13.757 INFO 97564 --- [ main] o.a.c.c.C.[.[localhost].[/wsdlfirstws] : Initializing Spring embedded WebApplicationContext
2020-11-30 22:28:13.758 INFO 97564 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1165 ms
2020-11-30 22:28:14.064 INFO 97564 --- [ main] o.a.c.w.s.f.ReflectionServiceFactoryBean : Creating Service {http://soap.ws.ckranz.com/}BankingServiceImplementationService from class com.banking.BankingPortType
2020-11-30 22:28:14.145 WARN 97564 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'endpoint' defined in class path resource [com/ckranz/ws/soap/config/WebServiceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.xml.ws.Endpoint]: Factory method 'endpoint' threw exception; nested exception is javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
2020-11-30 22:28:14.148 INFO 97564 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-11-30 22:28:14.158 INFO 97564 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-11-30 22:28:14.164 ERROR 97564 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'endpoint' defined in class path resource [com/ckranz/ws/soap/config/WebServiceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.xml.ws.Endpoint]: Factory method 'endpoint' threw exception; nested exception is javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
Here is some code:
https://www.codepile.net/pile/Ym773bm2

spring-boot-starter-quartz jdbc example

Starting with spring-boot 2.x.x they started offering spring-boot-starter-quartz which is great! Out of the box it does an in-memory store. I want to change it to be a clustered environment but I'm having issues with the configuration I think mostly because I need to put the qrtz_ tables in a different schema than my default data source. Does anyone have an example of using an alternate datasource? I'm currently attempting to set the properties field (as you can see below) but its like they are not being picked up by the configuration bean. Any help is appreciated.
Configuration
spring:
quartz:
job-store-type: jdbc
jdbc:
initialize-schema: never
properties:
scheduler:
instanceName : MyClusteredScheduler
instanceId : AUTO
threadPool:
class : org.quartz.simpl.SimpleThreadPool
threadCount : 25
threadPriority : 5
jobStore:
misfireThreshold : 60000
class : org.quartz.impl.jdbcjobstore.JobStoreTX
driverDelegateClass : org.quartz.impl.jdbcjobstore.StdJDBCDelegate
useProperties : false
dataSource : myDS
tablePrefix : QRTZ_
isClustered : true
clusterCheckinInterval : 20000
dataSource:
myDS:
driver : com.mysql.jdbc.Driver
URL : jdbc:mysql://127.0.0.1:3306/quartz
user : removed
password : removed
maxConnections : 5
validationQuery : select 0 from dual
Output from log
2017-11-06 13:33:02.853 INFO 7082 --- [ main] org.quartz.core.QuartzScheduler : Quartz Scheduler v.2.3.0 created.
2017-11-06 13:33:02.856 INFO 7082 --- [ main] o.s.s.quartz.LocalDataSourceJobStore : Using db table-based data access locking (synchronization).
2017-11-06 13:33:02.858 INFO 7082 --- [ main] o.s.s.quartz.LocalDataSourceJobStore : JobStoreCMT initialized.
2017-11-06 13:33:02.859 INFO 7082 --- [ main] org.quartz.core.QuartzScheduler : Scheduler meta-data: Quartz Scheduler (v2.3.0) 'quartzScheduler' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.springframework.scheduling.quartz.LocalDataSourceJobStore' - which supports persistence. and is not clustered.
2017-11-06 13:33:02.859 INFO 7082 --- [ main] org.quartz.impl.StdSchedulerFactory : Quartz scheduler 'quartzScheduler' initialized from an externally provided properties instance.
2017-11-06 13:33:02.860 INFO 7082 --- [ main] org.quartz.impl.StdSchedulerFactory : Quartz scheduler version: 2.3.0
2017-11-06 13:33:02.860 INFO 7082 --- [ main] org.quartz.core.QuartzScheduler : JobFactory set to: org.springframework.boot.autoconfigure.quartz.AutowireCapableBeanJobFactory#21132086
2017-11-06 13:33:03.214 INFO 7082 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-11-06 13:33:03.216 INFO 7082 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2017-11-06 13:33:03.223 INFO 7082 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2017-11-06 13:33:03.227 INFO 7082 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
2017-11-06 13:33:03.227 INFO 7082 --- [ main] o.s.s.quartz.SchedulerFactoryBean : Starting Quartz Scheduler now
2017-11-06 13:33:05.250 WARN 7082 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'quartzScheduler'; nested exception is org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: No database selected [See nested exception: java.sql.SQLException: No database selected]]
2017-11-06 13:33:05.250 INFO 7082 --- [ main] o.s.s.quartz.SchedulerFactoryBean : Shutting down Quartz Scheduler
2017-11-06 13:33:05.251 INFO 7082 --- [ main] org.quartz.core.QuartzScheduler : Scheduler quartzScheduler_$_NON_CLUSTERED shutting down.
2017-11-06 13:33:05.251 INFO 7082 --- [ main] org.quartz.core.QuartzScheduler : Scheduler quartzScheduler_$_NON_CLUSTERED paused.
2017-11-06 13:33:05.251 INFO 7082 --- [ main] org.quartz.core.QuartzScheduler : Scheduler quartzScheduler_$_NON_CLUSTERED shutdown complete.
2017-11-06 13:33:05.252 INFO 7082 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2017-11-06 13:33:05.253 INFO 7082 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
2017-11-06 13:33:05.254 INFO 7082 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-11-06 13:33:05.255 INFO 7082 --- [ main] com.zaxxer.hikari.HikariDataSource : testdb - Shutdown initiated...
2017-11-06 13:33:05.264 INFO 7082 --- [ main] com.zaxxer.hikari.HikariDataSource : testdb - Shutdown completed.
2017-11-06 13:33:05.265 INFO 7082 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2017-11-06 13:33:05.283 INFO 7082 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-11-06 13:33:05.293 ERROR 7082 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.context.ApplicationContextException: Failed to start bean 'quartzScheduler'; nested exception is org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: No database selected [See nested exception: java.sql.SQLException: No database selected]]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:186) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:52) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:358) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:159) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:884) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.0.0.M5.jar:2.0.0.M5]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122) ~[spring-boot-2.0.0.M5.jar:2.0.0.M5]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
at com.tci.reader.incident.parser.IncidentParserApplication.main(IncidentParserApplication.java:18) [classes/:na]
Caused by: org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: No database selected [See nested exception: java.sql.SQLException: No database selected]]
at org.springframework.scheduling.quartz.SchedulerFactoryBean.start(SchedulerFactoryBean.java:738) ~[spring-context-support-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:183) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
... 14 common frames omitted
Caused by: org.quartz.SchedulerConfigException: Failure occured during job recovery.
at org.quartz.impl.jdbcjobstore.JobStoreSupport.schedulerStarted(JobStoreSupport.java:697) ~[quartz-2.3.0.jar:na]
at org.quartz.core.QuartzScheduler.start(QuartzScheduler.java:539) ~[quartz-2.3.0.jar:na]
at org.quartz.impl.StdScheduler.start(StdScheduler.java:142) ~[quartz-2.3.0.jar:na]
at org.springframework.scheduling.quartz.SchedulerFactoryBean.startScheduler(SchedulerFactoryBean.java:664) ~[spring-context-support-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.scheduling.quartz.SchedulerFactoryBean.start(SchedulerFactoryBean.java:735) ~[spring-context-support-5.0.0.RELEASE.jar:5.0.0.RELEASE]
... 15 common frames omitted
Caused by: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: No database selected
at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:157) ~[quartz-2.3.0.jar:na]
at org.quartz.impl.jdbcjobstore.DBSemaphore.obtainLock(DBSemaphore.java:113) ~[quartz-2.3.0.jar:na]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3842) ~[quartz-2.3.0.jar:na]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.recoverJobs(JobStoreSupport.java:839) ~[quartz-2.3.0.jar:na]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.schedulerStarted(JobStoreSupport.java:695) ~[quartz-2.3.0.jar:na]
... 19 common frames omitted
Caused by: java.sql.SQLException: No database selected
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2487) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1966) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52) ~[HikariCP-2.7.2.jar:na]
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java) ~[HikariCP-2.7.2.jar:na]
at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:96) ~[quartz-2.3.0.jar:na]
... 23 common frames omitted
You have to use the correct properties for the quartz properties.
Your properties are missing ...org.quartz...
For the none-yml notation, try this for the threadCount:
spring.quartz.properties.org.quartz.threadPool.threadCount=25
For the yml notation:
Add two layers under the 'properties', e.g.
spring:
quartz:
properties:
org:
quartz:
threadPool:
threadCount : 25
Application.yml file:
spring:
jpa:
hibernate:
ddl-auto: none
datasource:
url: jdbc:mysql://127.0.0.1:3306/Quartz
username: Your Username
password: Your Password
quartz:
scheduler:
instanceName: Scheduler
threadPool:
class: org.quartz.simpl.SimpleThreadPool
threadCount: 3
context:
key:
QuartzTopic: QuartzPorperties
jobStore:
driver: com.mysql.jdbc.Driver
class: org.quartz.impl.jdbcjobstore.JobStoreTX
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
misfireThreshold: 6000
tablePrefix: QRTZ_
Next create a Configuration class which reads these properties from the yml file and then creates a Scheduler Bean:
#Configuration
public class SchedulerConfig {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
#Value("${quartz.scheduler.instanceName}")
private String instanceName;
#Value("${quartz.threadPool.class}")
private String threadClass;
#Value("${quartz.threadPool.threadCount}")
private String threadCount;
#Value("${quartz.context.key.QuartzTopic}")
private String quartzTopic;
#Value("${quartz.jobStore.class}")
private String jobStoreClass;
#Value("${quartz.jobStore.driverDelegateClass}")
private String driverDelegateClass;
#Value("${quartz.jobStore.misfireThreshold}")
private String misfireThreshold;
#Value("${quartz.jobStore.tablePrefix}")
private String tablePrefix;
#Value("${quartz.jobStore.driver}")
private String dataSourceDriver;
#Value("${spring.datasource.url}")
private String dataSourceUrl;
#Value("${spring.datasource.username}")
private String dataSourceUsername;
#Value("${spring.datasource.password}")
private String databasePassword;
#Bean({"Scheduler"})
public Scheduler getScheduler() {
Scheduler scheduler = null;
try {
StdSchedulerFactory factory = new StdSchedulerFactory();
Properties props = new Properties();
props.put("org.quartz.scheduler.instanceName", instanceName);
props.put("org.quartz.threadPool.class", threadClass);
props.put("org.quartz.threadPool.threadCount", threadCount);
props.put("org.quartz.context.key.QuartzTopic", quartzTopic);
props.put("org.quartz.jobStore.class", jobStoreClass);
props.put("org.quartz.jobStore.driverDelegateClass", driverDelegateClass);
props.put("quartz.jobStore.misfireThreshold", misfireThreshold);
props.put("org.quartz.jobStore.tablePrefix", tablePrefix);
props.put("org.quartz.jobStore.dataSource", "myDS");
props.put("org.quartz.dataSource.myDS.driver", dataSourceDriver);
props.put("org.quartz.dataSource.myDS.URL", dataSourceUrl);
props.put("org.quartz.dataSource.myDS.user", dataSourceUsername);
props.put("org.quartz.dataSource.myDS.password", databasePassword);
props.put("org.quartz.dataSource.myDS.maxConnections", "10");
factory.initialize(props);
scheduler = factory.getScheduler();
scheduler.start();
scheduler.resumeAll(); // This is to resume the entire scheduler when a new build is deployed
} catch (Exception e) {
logger.error("{} - SchedulerConfig class - getScheduler() - Error creating Scheduler instance: {}",
appName, e);
}
return scheduler;
}
}
Finally, use the Bean as below in any class you want:
#Autowired
private Scheduler scheduler;

JHipster and mongodb : Error creating bean with name 'mongobee'

I am rather new to JHipster and I followed their instructions in order to create a new app.
The app was created, imported into STS as a Maven project and I updated it.
However as soon as I try to start it via the Boot Dashboard I get this output :
2016-12-07 16:43:14.887 INFO 6396 --- [ restartedMain] com.mycompany.myapp.MdcApp : Starting MdcApp on PC981 with PID 6396 (C:\Users\lvuillaume\Desktop\mdc\target\classes started by lvuillaume in C:\Users\lvuillaume\Desktop\mdc)
2016-12-07 16:43:14.890 DEBUG 6396 --- [ restartedMain] com.mycompany.myapp.MdcApp : Running with Spring Boot v1.4.2.RELEASE, Spring v4.3.4.RELEASE
2016-12-07 16:43:14.891 INFO 6396 --- [ restartedMain] com.mycompany.myapp.MdcApp : The following profiles are active: swagger,dev
2016-12-07 16:43:14.972 DEBUG 6396 --- [kground-preinit] org.jboss.logging : Logging Provider: org.jboss.logging.Slf4jLoggerProvider found via system property
2016-12-07 16:43:18.499 DEBUG 6396 --- [ restartedMain] c.m.myapp.config.AsyncConfiguration : Creating Async Task Executor
2016-12-07 16:43:19.041 DEBUG 6396 --- [ restartedMain] c.m.myapp.config.MetricsConfiguration : Registering JVM gauges
2016-12-07 16:43:19.059 DEBUG 6396 --- [ restartedMain] c.m.myapp.config.MetricsConfiguration : Initializing Metrics JMX reporting
2016-12-07 16:43:19.960 WARN 6396 --- [ restartedMain] io.undertow.websockets.jsr : UT026009: XNIO worker was not set on WebSocketDeploymentInfo, the default worker will be used
2016-12-07 16:43:19.961 WARN 6396 --- [ restartedMain] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
2016-12-07 16:43:20.436 INFO 6396 --- [ restartedMain] c.mycompany.myapp.config.WebConfigurer : Web application configuration, using profiles: [swagger, dev]
2016-12-07 16:43:20.437 DEBUG 6396 --- [ restartedMain] c.mycompany.myapp.config.WebConfigurer : Initializing Metrics registries
2016-12-07 16:43:20.442 DEBUG 6396 --- [ restartedMain] c.mycompany.myapp.config.WebConfigurer : Registering Metrics Filter
2016-12-07 16:43:20.442 DEBUG 6396 --- [ restartedMain] c.mycompany.myapp.config.WebConfigurer : Registering Metrics Servlet
2016-12-07 16:43:20.445 INFO 6396 --- [ restartedMain] c.mycompany.myapp.config.WebConfigurer : Web application fully configured
2016-12-07 16:43:20.491 INFO 6396 --- [ restartedMain] com.mycompany.myapp.MdcApp : Running with Spring profile(s) : [swagger, dev]
2016-12-07 16:43:20.579 DEBUG 6396 --- [ restartedMain] c.m.myapp.config.CacheConfiguration : No cache
2016-12-07 16:43:24.805 DEBUG 6396 --- [ restartedMain] c.m.m.c.apidoc.SwaggerConfiguration : Starting Swagger
2016-12-07 16:43:24.816 DEBUG 6396 --- [ restartedMain] c.m.m.c.apidoc.SwaggerConfiguration : Started Swagger in 10 ms
2016-12-07 16:43:24.849 DEBUG 6396 --- [ restartedMain] c.m.myapp.config.DatabaseConfiguration : Configuring Mongobee
2016-12-07 16:43:24.854 INFO 6396 --- [ restartedMain] com.github.mongobee.Mongobee : Mongobee has started the data migration sequence..
2016-12-07 16:43:54.876 WARN 6396 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongobee' defined in class path resource [com/mycompany/myapp/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]
2016-12-07 16:43:54.883 INFO 6396 --- [ restartedMain] c.m.myapp.config.CacheConfiguration : Closing Cache Manager
2016-12-07 16:43:54.905 ERROR 6396 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongobee' defined in class path resource [com/mycompany/myapp/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:754)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at com.mycompany.myapp.MdcApp.main(MdcApp.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]
at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:369)
at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71)
at com.mongodb.binding.ClusterBinding.getReadConnectionSource(ClusterBinding.java:63)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:210)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:482)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:79)
at com.mongodb.Mongo.execute(Mongo.java:772)
at com.mongodb.Mongo$2.execute(Mongo.java:759)
at com.mongodb.DBCollection.findOne(DBCollection.java:777)
at com.mongodb.DBCollection.findOne(DBCollection.java:747)
at com.mongodb.DBCollection.findOne(DBCollection.java:694)
at com.github.mongobee.dao.ChangeEntryIndexDao.findRequiredChangeAndAuthorIndex(ChangeEntryIndexDao.java:26)
at com.github.mongobee.dao.ChangeEntryDao.ensureChangeLogCollectionIndex(ChangeEntryDao.java:75)
at com.github.mongobee.dao.ChangeEntryDao.connectMongoDb(ChangeEntryDao.java:34)
at com.github.mongobee.Mongobee.execute(Mongobee.java:135)
at com.github.mongobee.Mongobee.afterPropertiesSet(Mongobee.java:117)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579)
... 19 common frames omitted
I tried to create a similar project but without a Mongodb and it worked.
This error means that there was an error connecting to your database, it confirms this in your stacktrace:
Timed out after 30000 ms while waiting for a server
Please double check your database configuration in the application-dev.properties or application-dev.yml file under src/main/resources/config/.
Depending on whether you use YAML or JSON as the property definition file, double check the database configuration:
YAML:
spring:
data:
mongodb:
host: <your_host_address>
port: <your_port>
database: <database_name>
JSON:
spring.data.mongodb.host=<your_host_address>
spring.data.mongodb.port=<your_port>
spring.data.mongodb.database=<database_name>
After creating a new JHipster project with MongoDb I had the same error.
Before running mvnw (on Windows) I forgot to run the MongoDb itself.
So running mongod.exe in the new command prompt, and then running mvnw solved the issue for me.
This was able to solve my problem:
"Answered my own question...removing the #Bean definition from public
Mongobee mongobee(...) in DatabaseConfiguration.java seems to do the
trick. Haven't done any thorough testing, but the apps starts and I
can create new users."
Link: https://github.com/jhipster/generator-jhipster/issues/8665

Resources