patka / cassandra-migration

Schema migration library for Cassandra
MIT License
152 stars 47 forks source link

Caused by: java.nio.file.NoSuchFileException: cassandra/migration #73

Closed Afzalkhan644 closed 1 year ago

Afzalkhan644 commented 1 year ago

HI, I have used Cassandra- migration in one of my project. i have facing issue with the migration script when i deployed it in aws-server. in my local its able to find but facing issue in dev-server. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraSession' defined in class path resource [com/rishabh/saas/audit/config/AuditLogConsumerConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.datastax.oss.driver.api.core.CqlSession]: Factory method 'cassandraSession' threw exception; nested exception is org.cognitor.cassandra.migration.MigrationException: Error while scanning script folder for new scripts. at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:64) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:745) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:420) at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) at com.rishabh.saas.audit.Application.main(Application.java:14) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.datastax.oss.driver.api.core.CqlSession]: Factory method 'cassandraSession' threw exception; nested exception is org.cognitor.cassandra.migration.MigrationException: Error while scanning script folder for new scripts. at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ... 27 common frames omitted Caused by: org.cognitor.cassandra.migration.MigrationException: Error while scanning script folder for new scripts. at org.cognitor.cassandra.migration.MigrationRepository.(MigrationRepository.java:137) at org.cognitor.cassandra.migration.MigrationRepository.(MigrationRepository.java:118) at org.cognitor.cassandra.migration.MigrationRepository.(MigrationRepository.java:106) at org.cognitor.cassandra.migration.MigrationRepository.(MigrationRepository.java:93) at com.rishabh.saas.audit.config.AuditLogConsumerConfig.cassandraMigrationCqlSession(AuditLogConsumerConfig.java:55) at com.rishabh.saas.audit.config.AuditLogConsumerConfig.cassandraSession(AuditLogConsumerConfig.java:64) at com.rishabh.saas.audit.config.AuditLogConsumerConfig$$EnhancerBySpringCGLIB$$4303e232.CGLIB$cassandraSession$2() at com.rishabh.saas.audit.config.AuditLogConsumerConfig$$EnhancerBySpringCGLIB$$4303e232$$FastClassBySpringCGLIB$$b8203b9b.invoke() at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) at com.rishabh.saas.audit.config.AuditLogConsumerConfig$$EnhancerBySpringCGLIB$$4303e232.cassandraSession() at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ... 28 common frames omitted Caused by: java.nio.file.NoSuchFileException: cassandra/migration at jdk.zipfs/jdk.nio.zipfs.ZipPath.getAttributes(Unknown Source) at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.readAttributes(Unknown Source) at java.base/java.nio.file.Files.readAttributes(Unknown Source) at java.base/java.nio.file.FileTreeWalker.getAttributes(Unknown Source) at java.base/java.nio.file.FileTreeWalker.visit(Unknown Source) at java.base/java.nio.file.FileTreeWalker.walk(Unknown Source) at java.base/java.nio.file.FileTreeIterator.(Unknown Source) at java.base/java.nio.file.Files.walk(Unknown Source) at java.base/java.nio.file.Files.walk(Unknown Source) at org.cognitor.cassandra.migration.scanner.JarLocationScanner.findResourceNames(JarLocationScanner.java:34) at org.cognitor.cassandra.migration.MigrationRepository.scanForScripts(MigrationRepository.java:189) at org.cognitor.cassandra.migration.MigrationRepository.(MigrationRepository.java:135)

patka commented 1 year ago

Hi,

I am not sure how I can help here. I do not know the environment in which you are working or what your dev server is. All I can see here is that you get a NoSuchFileException that states that it cannot find the cassandra/migration folder. You seem to be using the JarLocationScanner, so the scripts should be included in a jar file that is part of the classpath and that has a cassandra-migration folder inside the root path. So something like classpath:/cassandra/migration

Cheers

Afzalkhan644 commented 1 year ago

thanks for the help.