Flyway not picking up migration file in Spring MVC - spring-mvc

I've followed a few tutorials and configured Flyway for DB initialisation.
I took a schema dump from MYSQL (no data) and named the file V1__initialSchema.sql. So this is full of specific create table, foreign keys etc. as dumped by mysql.
Then I've configured the beans:
Flyway Initiailser
#Bean(initMethod = "migrate")
protected Flyway flyway() {
Flyway flyway = new Flyway();
flyway.setBaselineOnMigrate(true);
//flyway.setLocations("classpath:db/migration");
flyway.setDataSource(dataSource());
return flyway;
}
JPA Initialiser
#Bean
#DependsOn(value = "flyway")
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
factory.setDataSource(dataSource());
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan("com.ideafactory.mvc", "com.ideafactory.plugins");
Properties jpaProperties = new Properties();
jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
//jpaProperties.put("hibernate.hbm2ddl.auto","create-drop");
jpaProperties.put("hibernate.show_sql", false);
jpaProperties.put("hibernate.format_sql", false);
jpaProperties.put("hibernate.use_sql_comments", false);
jpaProperties.put("hibnerate.connection.CharSet", "utf8");
jpaProperties.put("hibernate.connect.characterEncoding", "utf8");
jpaProperties.put("hibernate.connection.useUnicode", true);
jpaProperties.put("jadira.usertype.autoRegisterUserTypes", true);
factory.setJpaProperties(jpaProperties);
factory.afterPropertiesSet();
factory.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
return factory;
}
I switched on logging and I can see it is "skipping" my initialise file, which I'm not sure why. The schema hasn't been created.
l.util.logging.slf4j.Slf4jLog 40 debug - Scanning for classpath resources at 'db/migration' (Prefix: 'V', Suffix: '.sql')
16:35:08.272 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Scanning URL: file:/Users//Documents/Projects/MerchantX/target/java_ecommerce/WEB-INF/classes/db/migration/
16:35:08.273 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - JBoss VFS v2 available: false
16:35:08.273 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Scanning starting at classpath root in filesystem: /Users//Documents/Projects/MerchantX/target/java_ecommerce/WEB-INF/classes/
16:35:08.273 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Scanning for resources in path: /Users//Documents/Projects/MerchantX/target/java_ecommerce/WEB-INF/classes/db/migration (db/migration)
16:35:08.273 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Found resource: db/migration/V1__initialSchema.sql
16:35:08.279 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Scanning for classes at 'db/migration' (Implementing: 'org.flywaydb.core.api.migration.jdbc.JdbcMigration')
16:35:08.279 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Scanning URL: file:/Users//Documents/Projects/MerchantX/target/java_ecommerce/WEB-INF/classes/db/migration/
16:35:08.279 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - JBoss VFS v2 available: false
16:35:08.280 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Scanning starting at classpath root in filesystem: /Users//Documents/Projects/MerchantX/target/java_ecommerce/WEB-INF/classes/
16:35:08.280 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Scanning for resources in path: /Users//Documents/Projects/MerchantX/target/java_ecommerce/WEB-INF/classes/db/migration (db/migration)
16:35:08.280 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Filtering out resource: db/migration/V1__initialSchema.sql (filename: V1__initialSchema.sql)
16:35:08.281 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Scanning for classes at 'db/migration' (Implementing: 'org.flywaydb.core.api.migration.spring.SpringJdbcMigration')
16:35:08.281 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Scanning URL: file:/Users//Documents/Projects/MerchantX/target/java_ecommerce/WEB-INF/classes/db/migration/
16:35:08.282 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - JBoss VFS v2 available: false
16:35:08.282 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Scanning starting at classpath root in filesystem: /Users//Documents/Projects/MerchantX/target/java_ecommerce/WEB-INF/classes/
16:35:08.282 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Scanning for resources in path: /Users//Documents/Projects/MerchantX/target/java_ecommerce/WEB-INF/classes/db/migration (db/migration)
16:35:08.282 DEBUG org.flywaydb.core.internal.util.logging.slf4j.Slf4jLog 40 debug - Filtering out resource: db/migration/V1__initialSchema.sql (filename: V1__initialSchema.sql)
I haven't used Flyway before, can anyone explain why it filtered out my initialisation file?

AFAIK baselineOnMigrate creates first (V1) version from your actual schema in DB. And only following version will get applied (V1.1, V2, ...).
So either don't use baselineOnMigrate but you need to start with empty DB schema or start indexing your versions from (eg.) V2.

Related

How to conect a Sqlite datasource in grails 3.3.9 in intellij J 2021

i need some help: i try to connect sqlite datasource from a file in grails 3.3.9
This is my applicatiom.yml file:
hibernate:
cache:
queries: false
use_second_level_cache: false
use_query_cache: false
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password: ''
dataSources:
IkebanaUser:
dbCreate: "update"
url: "jdbc:sqlite:/home/marcos/IkebanaUser"
logSql: "true"
dialect: "SQLiteDialect"
driverClassName: "org.sqlite.JDBC"
environments:
development:
dataSource:
dbCreate: create-drop
url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: none
url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
dataSources:
IkebanaUser:
dbCreate: "update"
url: "jdbc:sqlite:/home/marcos/IkebanaUser"
logSql: "true"
dialect: "SQLiteDialect"
driverClassName: "org.sqlite.JDBC"
and this is my build.gradle file:
buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.15.1"
}
}
version "0.1"
group "ikebana.gammaversion"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"asset-pipeline"
apply plugin:"org.grails.grails-gsp"
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-i18n"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:async"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:events"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.1.16.Final"
compile "org.grails.plugins:gsp"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "org.glassfish.web:el-impl:2.1.2-b03"
runtime "com.h2database:h2"
runtime "org.apache.tomcat:tomcat-jdbc"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.15.1"
runtime 'org.xerial:sqlite-jdbc:3.6.17'
testCompile "org.grails:grails-gorm-testing-support"
testCompile "org.grails.plugins:geb"
testCompile "org.grails:grails-web-testing-support"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}
bootRun {
jvmArgs('-Dspring.output.ansi.enabled=always')
addResources = true
String springProfilesActive = 'spring.profiles.active'
systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}
assets {
minifyJs = true
minifyCss = true
}
this mis my domain class
class Usuario {
static constraints = {
}
static mapping = {
datasource 'IkebanaUser'
}
private def nombre
private def apellido
def getNombre() {
return nombre
}
......
and my "controller" is
class UsuarioController {
static scaffold= Usuario
def index() { }
}
i see too this post Grails and SQLite to create a SQlitedialect.java in a java directory(see the image) , mi S.O is Ubuntu 18.04, y think that the error is in my aplciation.yml.Help please.. thanks a lot
enter image description here
And the error is this
Running application...
2021-07-02 22:59:01.614 ERROR --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsatisfied dependency expressed through method 'methodValidationPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastoreServiceRegistry': Cannot resolve reference to bean 'hibernateDatastore' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1178)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1072)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:225)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:703)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:124)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at grails.boot.GrailsApp.run(GrailsApp.groovy:84)
at grails.boot.GrailsApp.run(GrailsApp.groovy:393)
at grails.boot.GrailsApp.run(GrailsApp.groovy:380)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
at ikebana.gammaversion.Application.main(Application.groovy:8)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastoreServiceRegistry': Cannot resolve reference to bean 'hibernateDatastore' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:648)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:145)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1198)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1100)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getSingletonFactoryBeanForTypeCheck(AbstractAutowireCapableBeanFactory.java:928)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:805)
at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:573)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:432)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:395)
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:206)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1265)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1099)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 24 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:279)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1198)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1100)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
... 40 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:122)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:271)
... 49 common frames omitted
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:228)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692)
at org.grails.orm.hibernate.cfg.HibernateMappingContextConfiguration.buildSessionFactory(HibernateMappingContextConfiguration.java:276)
at org.grails.orm.hibernate.connections.HibernateConnectionSourceFactory.create(HibernateConnectionSourceFactory.java:86)
at org.grails.orm.hibernate.connections.AbstractHibernateConnectionSourceFactory.create(AbstractHibernateConnectionSourceFactory.java:39)
at org.grails.orm.hibernate.connections.AbstractHibernateConnectionSourceFactory.create(AbstractHibernateConnectionSourceFactory.java:23)
at org.grails.datastore.mapping.core.connections.AbstractConnectionSourceFactory.create(AbstractConnectionSourceFactory.java:64)
at org.grails.datastore.mapping.core.connections.InMemoryConnectionSources.(InMemoryConnectionSources.groovy:26)
at org.grails.datastore.mapping.core.connections.ConnectionSourcesInitializer.create(ConnectionSourcesInitializer.groovy:28)
at org.grails.orm.hibernate.HibernateDatastore.(HibernateDatastore.java:201)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:1076)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
... 51 common frames omitted
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100)
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137)
at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:254)
... 77 common frames omitted
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':bootRun'.
Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error |
Failed to start server (Use --stacktrace to see the full trace)
Process finished with exit code 1
Need in the build.graddle:
compile group: 'com.zsoltfabok', name: 'sqlite-dialect', version: '1.0'
and trash this line too
runtime 'org.xerial:sqlite-jdbc:3.6.17'
and .yml look that
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password: ''
dataSources:
IkebanaUser:
pooled: true
driverClassName: "org.sqlite.JDBC"
username: ''
password: ''
environments:
development:
dataSource:
dbCreate: create-drop
url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
dataSources:
IkebanaUser:
url: jdbc:sqlite:/home/marcos/IkebanaUser
dbCreate: update
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: none
url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000; DB_CLOSE_ON_EXIT=FALSE
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED

Error: Serialization Scheme Not Supported

When I run my Spring Boot webserver inside my GCP VM using this command:
java -jar corda-webserver.jar --server.port=10055 --config.rpc.host=localhost --config.rpc.port=10003 --config.rpc.username=cordazoneservice --config.rpc.password=SOME_PASSWORD
I get this error:
W 21:56:07 26 SerializationFactoryImpl.apply - Cannot find serialization scheme for: [([636F7264610000], RPCClient), UNKNOWN MAGIC] registeredSchemes are: [net.corda.client.rpc.internal.serialization.amqp.AMQPClientSerializationScheme#72fcf0f7]
E 21:56:07 26 RPCClientProxyHandler.artemisMessageHandler - Failed to deserialize RPC body
net.corda.nodeapi.RPCApi$ServerToClient$FailedToDeserializeReply: Failed to deserialize RPC reply: Serialization scheme ([636F7264610000], RPCClient) not supported.
at net.corda.nodeapi.RPCApi$ServerToClient$Companion.fromClientMessage(RPCApi.kt:240) ~[corda-node-api-4.1.jar!/:?]
at net.corda.client.rpc.internal.RPCClientProxyHandler.artemisMessageHandler(RPCClientProxyHandler.kt:309) ~[corda-rpc-4.1.jar!/:?]
at net.corda.client.rpc.internal.RPCClientProxyHandler.access$artemisMessageHandler(RPCClientProxyHandler.kt:75) ~[corda-rpc-4.1.jar!/:?]
at net.corda.client.rpc.internal.RPCClientProxyHandler$initSessions$1.invoke(RPCClientProxyHandler.kt:519) ~[corda-rpc-4.1.jar!/:?]
at net.corda.client.rpc.internal.RPCClientProxyHandler$initSessions$1.invoke(RPCClientProxyHandler.kt:75) ~[corda-rpc-4.1.jar!/:?]
at net.corda.client.rpc.internal.RPCClientProxyHandlerKt$sam$org_apache_activemq_artemis_api_core_client_MessageHandler$0.onMessage(RPCClientProxyHandler.kt) ~[corda-rpc-4.1.jar!/:?]
at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:1002) ~[artemis-core-client-2.6.2.jar!/:2.6.2]
at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:50) ~[artemis-core-client-2.6.2.jar!/:2.6.2]
at org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1125) ~[artemis-core-client-2.6.2.jar!/:2.6.2]
at org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:42) ~[artemis-commons-2.6.2.jar!/:2.6.2]
at org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:31) ~[artemis-commons-2.6.2.jar!/:2.6.2]
at org.apache.activemq.artemis.utils.actors.ProcessorBase.executePendingTasks(ProcessorBase.java:66) ~[artemis-commons-2.6.2.jar!/:2.6.2]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118) [artemis-commons-2.6.2.jar!/:2.6.2]
Caused by: java.lang.UnsupportedOperationException: Serialization scheme ([636F7264610000], RPCClient) not supported.
at net.corda.serialization.internal.SerializationFactoryImpl$schemeFor$1.apply(SerializationScheme.kt:99) ~[corda-serialization-4.1.jar!/:?]
at net.corda.serialization.internal.SerializationFactoryImpl$schemeFor$1.apply(SerializationScheme.kt:73) ~[corda-serialization-4.1.jar!/:?]
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[?:1.8.0_222]
at net.corda.serialization.internal.SerializationFactoryImpl.schemeFor(SerializationScheme.kt:95) ~[corda-serialization-4.1.jar!/:?]
at net.corda.serialization.internal.SerializationFactoryImpl.access$schemeFor(SerializationScheme.kt:73) ~[corda-serialization-4.1.jar!/:?]
at net.corda.serialization.internal.SerializationFactoryImpl$deserialize$1$1.invoke(SerializationScheme.kt:105) ~[corda-serialization-4.1.jar!/:?]
at net.corda.core.serialization.SerializationFactory.withCurrentContext(SerializationAPI.kt:71) ~[corda-core-4.1.jar!/:?]
at net.corda.serialization.internal.SerializationFactoryImpl$deserialize$1.invoke(SerializationScheme.kt:105) ~[corda-serialization-4.1.jar!/:?]
at net.corda.serialization.internal.SerializationFactoryImpl$deserialize$1.invoke(SerializationScheme.kt:73) ~[corda-serialization-4.1.jar!/:?]
at net.corda.core.serialization.SerializationFactory.asCurrent(SerializationAPI.kt:85) ~[corda-core-4.1.jar!/:?]
at net.corda.serialization.internal.SerializationFactoryImpl.deserialize(SerializationScheme.kt:105) ~[corda-serialization-4.1.jar!/:?]
at net.corda.nodeapi.RPCApi$ServerToClient$Companion.fromClientMessage(RPCApi.kt:373) ~[corda-node-api-4.1.jar!/:?]
... 14 more
I 21:56:07 1 RPCClient.logElapsedTime - Failed Startup took 1204 msec
W 21:56:07 1 AnnotationConfigServletWebServerApplicationContext.refresh - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nodeRPCConnection': Invocation of init method failed; nested exception is java.lang.UnsupportedOperationException: Serialization scheme ([636F7264610000], RPCClient) not supported.
I 21:56:07 1 StandardService.log - Stopping service [Tomcat]
Below is the Corda version that I use in my project:
corda_release_group = 'net.corda'
corda_release_version = '4.1'
tokens_release_group = 'com.r3.corda.lib.tokens'
tokens_release_version = '1.0-RC03'
corda_gradle_plugins_version = '4.0.42'
junit_version = '4.12'
quasar_version = '0.7.10'
spring_boot_version = '2.0.2.RELEASE'
spring_boot_gradle_plugin_version = '2.0.2.RELEASE'
slf4j_version = '1.7.25'
log4j_version = '2.11.2'
corda_platform_version = '4'
My Corda node on GCP VM that I built using the script from Corda TestNet:
[INFO ] 2019-08-14T03:21:28,879Z [main] internal.Node.logStartupInfo - Vendor: Corda Open Source {}
[INFO ] 2019-08-14T03:21:28,879Z [main] internal.Node.logStartupInfo - Release: 3.3-corda {}
[INFO ] 2019-08-14T03:21:28,881Z [main] internal.Node.logStartupInfo - Platform Version: 3 {}
Btw, I don't get errors when I run that command on my local Ubuntu VM; I start the node, then the webserver and I can access it inside my browser. This error only happens when I try the same inside my GCP VM using the node that is supplied by Corda TestNet.
I upgraded my node from OS 3.3 to OS 4.1 and that solved the issue.
Make sure you update node.conf file inside your node folder to follow the new formatting (e.g. no double quotes around keys).

How to connect to Neptune using Version 4 Signing dependency

I have an EC2 instance that can connect to gremlin using the Gremlin Console, or by pulling in this repository and running the maven command.
However, when I use the recommended Version 4 signing dependency:
dependencies {
compile(
...
// neptune sigv4
[group: "com.amazonaws", name:"aws-java-sdk-core", version: "1.11.307"],
[group: "com.amazonaws", name:"amazon-neptune-sigv4-signer", version: "1.0"],
[group: "com.amazonaws", name:"amazon-neptune-gremlin-java-sigv4", version: "1.0"],
...
)
}
On a very similar hello world program:
package com.test.neptune;
import org.apache.tinkerpop.gremlin.driver.Client;
import org.apache.tinkerpop.gremlin.driver.Cluster;
import org.apache.tinkerpop.gremlin.driver.Result;
import org.apache.tinkerpop.gremlin.driver.ResultSet;
import org.apache.tinkerpop.gremlin.driver.SigV4WebSocketChannelizer;
import org.neo4j.cypher.internal.frontend.v2_3.repeat;
public class NeptuneExampleCopy {
private static final String NEPTUNE_ENDPOINT = "my.endpoint.url";
private static final int NEPTUNE_PORT = 0;
public static void main(String[] args) {
// connect to the neptune cluster
final Cluster cluster = Cluster.build()
.addContactPoint(NEPTUNE_ENDPOINT)
.port(NEPTUNE_PORT)
.channelizer(SigV4WebSocketChannelizer.class)
.create();
// run a traversal, print the results
final Client client = cluster.connect();
final ResultSet rs = client.submit("g.V().count()");
for (Result r : rs) {
System.out.println(r);
}
// close the cluster
cluster.close();
}
}
Gradle throws the following exception:
Apr 25, 2019 5:24:21 PM io.netty.channel.ChannelInitializer exceptionCaught
WARNING: Failed to initialize a channel. Closing: [id: 0xd894eb28]
com.amazon.neptune.gremlin.driver.exception.SigV4PropertiesNotFoundException: Unable to load SigV4 properties from any of the providers
at com.amazon.neptune.gremlin.driver.sigv4.ChainedSigV4PropertiesProvider.getSigV4Properties(ChainedSigV4PropertiesProvider.java:74)
at com.amazon.neptune.gremlin.driver.sigv4.AwsSigV4ClientHandshaker.loadProperties(AwsSigV4ClientHandshaker.java:102)
at com.amazon.neptune.gremlin.driver.sigv4.AwsSigV4ClientHandshaker.<init>(AwsSigV4ClientHandshaker.java:64)
at org.apache.tinkerpop.gremlin.driver.SigV4WebSocketChannelizer.createHandler(SigV4WebSocketChannelizer.java:210)
at org.apache.tinkerpop.gremlin.driver.SigV4WebSocketChannelizer.configure(SigV4WebSocketChannelizer.java:176)
at org.apache.tinkerpop.gremlin.driver.Channelizer$AbstractChannelizer.initChannel(Channelizer.java:140)
at org.apache.tinkerpop.gremlin.driver.Channelizer$AbstractChannelizer.initChannel(Channelizer.java:92)
at io.netty.channel.ChannelInitializer.initChannel(ChannelInitializer.java:113)
at io.netty.channel.ChannelInitializer.handlerAdded(ChannelInitializer.java:105)
at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:617)
at io.netty.channel.DefaultChannelPipeline.access$000(DefaultChannelPipeline.java:46)
at io.netty.channel.DefaultChannelPipeline$PendingHandlerAddedTask.execute(DefaultChannelPipeline.java:1467)
at io.netty.channel.DefaultChannelPipeline.callHandlerAddedForAllHandlers(DefaultChannelPipeline.java:1141)
at io.netty.channel.DefaultChannelPipeline.invokeHandlerAddedIfNeeded(DefaultChannelPipeline.java:666)
at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:510)
at io.netty.channel.AbstractChannel$AbstractUnsafe.access$200(AbstractChannel.java:423)
at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:482)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
at java.lang.Thread.run(Thread.java:748)
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: java.util.concurrent.TimeoutException: Timed out while waiting for an available host - check the client configuration and connectivity to the server if this message persists
at org.apache.tinkerpop.gremlin.driver.Client.submit(Client.java:214)
at org.apache.tinkerpop.gremlin.driver.Client.submit(Client.java:198)
at com.test.neptune.NeptuneExampleCopy.main(NeptuneExampleCopy.java:25)
Caused by: java.lang.RuntimeException: java.util.concurrent.TimeoutException: Timed out while waiting for an available host - check the client configuration and connectivity to the server if this message persists
at org.apache.tinkerpop.gremlin.driver.Client.submitAsync(Client.java:310)
at org.apache.tinkerpop.gremlin.driver.Client.submitAsync(Client.java:242)
at org.apache.tinkerpop.gremlin.driver.Client.submit(Client.java:212)
... 2 more
Caused by: java.util.concurrent.TimeoutException: Timed out while waiting for an available host - check the client configuration and connectivity to the server if this message persists
at org.apache.tinkerpop.gremlin.driver.Client$ClusteredClient.chooseConnection(Client.java:499)
at org.apache.tinkerpop.gremlin.driver.Client.submitAsync(Client.java:305)
... 4 more
Apr 25, 2019 5:24:22 PM io.netty.channel.ChannelInitializer exceptionCaught
WARNING: Failed to initialize a channel. Closing: [id: 0xc3ff34e0]
com.amazon.neptune.gremlin.driver.exception.SigV4PropertiesNotFoundException: Unable to load SigV4 properties from any of the providers
at com.amazon.neptune.gremlin.driver.sigv4.ChainedSigV4PropertiesProvider.getSigV4Properties(ChainedSigV4PropertiesProvider.java:74)
at com.amazon.neptune.gremlin.driver.sigv4.AwsSigV4ClientHandshaker.loadProperties(AwsSigV4ClientHandshaker.java:102)
at com.amazon.neptune.gremlin.driver.sigv4.AwsSigV4ClientHandshaker.<init>(AwsSigV4ClientHandshaker.java:64)
at org.apache.tinkerpop.gremlin.driver.SigV4WebSocketChannelizer.createHandler(SigV4WebSocketChannelizer.java:210)
at org.apache.tinkerpop.gremlin.driver.SigV4WebSocketChannelizer.configure(SigV4WebSocketChannelizer.java:176)
at org.apache.tinkerpop.gremlin.driver.Channelizer$AbstractChannelizer.initChannel(Channelizer.java:140)
at org.apache.tinkerpop.gremlin.driver.Channelizer$AbstractChannelizer.initChannel(Channelizer.java:92)
at io.netty.channel.ChannelInitializer.initChannel(ChannelInitializer.java:113)
How could this code be fixed? Is there a better Version 4 signing dependency?
SigV4 handler tries to fetch your AWS Credentials through multiple credential providers. If no credential provider was initialized, then you are bound to see this exception. How have you initialized your AWS Credentials? You could use any of the standard sources, like environment variables, or JVM system properties or the like. See the documentation below for more details:
https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth-connecting-gremlin-java.html
Update: Do make sure you are using the latest versions of all the packages and dependencies.
For example:
// neptune sigv4 [group: "com.amazonaws",
name:"aws-java-sdk-core", version: "1.11.542"],
[group: "com.amazonaws",
name:"amazon-neptune-sigv4-signer", version: "1.0.4"],
[group: "com.amazonaws",
name:"amazon-neptune-gremlin-java-sigv4", version: "1.0.5"],
// for neptune [group: "org.apache.tinkerpop",
name: "gremlin-driver", version: "3.4.1"]

Exception 504 when registering the consumer

I've been working with Symfony 2.7 and the RabbitMQBundle to handle some long processes asynchronously.
After facing the issue where the MySQL connection dies after a few minutes, I discovered rabbitmq-cli-consumer, a small app in Go that takes care of consuming the queue, and gives its content to a command.
In my case, I use it with this command: ./rabbitmq-cli-consumer -c configuration-stock.conf --include -V -e 'php app/console amqp:consume:stock --env=prod -vvv', with this configuration file:
[rabbitmq]
host = HOST
username = USERNAME
password = PASSWORD
vhost=/VHOST
port=PORT
queue=stock
compression=Off
[exchange]
name=exports
type=direct
durable=On
[queuesettings]
routingkey=stock
messagettl=10000
deadLetterExchange=exports.dl
deadLetterroutingkey=stock
priority=10
To handle errors, I intend to use RabbitMQ's x-dead-letter-exchange and x-dead-letter-routing-key configuration, to be able to retry the message later (in case something went temporarly wrong).
My issue is that, when I define my queues in RabbitMQBundle's configuration, rabbitmq-cli-consumer is unable to consume the queue, throwing this error:
2018/04/23 11:35:54 Connecting RabbitMQ...
2018/04/23 11:35:54 Connected.
2018/04/23 11:35:54 Opening channel...
2018/04/23 11:35:54 Done.
2018/04/23 11:35:54 Setting QoS...
2018/04/23 11:35:54 Succeeded setting QoS.
2018/04/23 11:35:54 Declaring queue "stock"...
2018/04/23 11:35:54 Registering consumer...
2018/04/23 11:35:54 failed to register a consumer: Exception (504) Reason: "channel/connection is not open"
Here is the configuration I use for RabbitMQBundle:
old_sound_rabbit_mq:
producers:
exports:
connection: default
exchange_options:
name: 'exports'
type: direct
exports_dl:
connection: default
exchange_options:
name: 'exports.dl'
type: direct
consumers:
stock_dead_letter:
connection: default
exchange_options:
name: exports.dl
type: direct
queue_options:
name: stock.dl
routing_keys:
- stock
arguments:
x-dead-letter-exchange: ['S', 'exports']
x-dead-letter-routing-key: ['S', 'stock']
x-message-ttl: ['I', 60000]
callback: amqp.consumers.exports.stock
multiple_consumers:
exports:
connection: default
exchange_options:
name: 'exports'
type: direct
queues:
stock:
name: stock
callback: amqp.consumers.exports.stock
routing_keys:
- stock
arguments:
x-dead-letter-exchange: ['S', 'exports.dl']
x-dead-letter-routing-key: ['S', 'stock']
Has anyone ever encountered something similar ? And how did you solve it ?

Is there a spring data redis mapping the Redisson framework

As the title says, was there a spring data redis mapping to the Redisson framework (http://redisson.org)
Short answer
There is Spring Data Redis integration
Long answer
Consider Spring Data Redis integration as another type of connector or binding (check here for the connector term). The library provides RedissonConnectionFactory (implements RedisConnectionFactory) which would be the base for working with e.g. #RedisHash and spring cache abstraction (#EnableCaching). There's also a redisson-spring-boot-starter but make sure not to have lettuce or jedis in classpath because org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration (provided by spring-boot-autoconfigure) might create a RedisConnectionFactory before org.redisson.spring.starter.RedissonAutoConfiguration (provided by redisson-spring-boot-starter)!
Add redisson-spring-boot-starter dependency into your project:
compile 'org.redisson:redisson-spring-boot-starter:3.13.5'
Add settings into application.settings file
common spring boot props:
spring:
redis:
database:
host:
port:
password:
ssl:
timeout:
cluster:
nodes:
sentinel:
master:
nodes:
redisson:
file: classpath:redisson.yaml
config: |
clusterServersConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
failedSlaveReconnectionInterval: 3000
failedSlaveCheckInterval: 60000
password: null
subscriptionsPerConnection: 5
clientName: null
loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
slaveConnectionMinimumIdleSize: 24
slaveConnectionPoolSize: 64
masterConnectionMinimumIdleSize: 24
masterConnectionPoolSize: 64
readMode: "SLAVE"
subscriptionMode: "SLAVE"
nodeAddresses:
- "redis://127.0.0.1:7004"
- "redis://127.0.0.1:7001"
- "redis://127.0.0.1:7000"
scanInterval: 1000
pingConnectionInterval: 0
keepAlive: false
tcpNoDelay: false
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.FstCodec> {}
transportMode: "NIO"
3.Use Redisson through spring bean with RedissonClient interface or RedisTemplate/ReactiveRedisTemplate objects

Resources