Problem Statement
We are using SpringBoot 2.0.5 with default redis starter and jedis 2.9.0 . Application is working fine (we are getting data from redis store) but existing integration tests are failing when executing gradle command and tests are running fine with intelliJ. See below for the stack trace. RedisConnectionFactoy class is available. Could not figure out the root cause. Appreciate any leads to figure out the exact issue.
Dependencies
implementation ('org.springframework.boot:spring-boot-starter-data-redis') {
exclude group: 'io.lettuce', module: 'lettuce-core'
}
implementation 'redis.clients:jedis:2.9.0'
Stack Trace
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwa reContextLoaderDelegate.java:125)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
at org.springframework.cloud.contract.stubrunner.provider.wiremock.StubRunnerWireMockTestExecutionListener.beforeTestClass(StubRunnerWireMockTestExecutionListener.java:31)
at org.springframework.test.context.TestContextManager.beforeTestClass(TestContextManager.java:215)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:60)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:106)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:180)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:271)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:91)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:333)
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:139)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
... 37 more
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.config.RedisConfig] from ClassLoader [sun.misc.Launcher$AppClassLoader#73d16e93]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:659)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:556)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:541)
at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:718)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:659)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:627)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1489)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1012)
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:194)
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:170)
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanType(BeanTypeRegistry.java:163)
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.lambda$updateTypesIfNecessary$2(BeanTypeRegistry.java:150)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.updateTypesIfNecessary(BeanTypeRegistry.java:148)
at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.getNamesForType(BeanTypeRegistry.java:114)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:265)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:254)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:196)
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:116)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
... 53 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/data/redis/connection/RedisConnectionFactory
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:641)
... 73 more
Caused by: java.lang.ClassNotFoundException: org.springframework.data.redis.connection.RedisConnectionFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 77 more
In build.gradle file I changed from implementation to compile . It worked :)
I try to run my application but there is this error which prevents me from doing that here is the error:
> java.sql.SQLException: Unable to load class: org.mariadb.jdbc.Driver from ClassLoader:java.net.URLClassLoader#2626b418;ClassLoader:java.net.URLClassLoader#2626b418
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:292)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:212)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:744)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:676)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:483)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107)
at org.apache.tomcat.jdbc.pool.DataSourceFactory.createDataSource(DataSourceFactory.java:560)
at org.apache.tomcat.jdbc.pool.DataSourceFactory.getObjectInstance(DataSourceFactory.java:244)
at org.apache.naming.factory.FactoryBase.getObjectInstance(FactoryBase.java:96)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:857)
at org.apache.naming.NamingContext.lookup(NamingContext.java:160)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:174)
at org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1017)
at org.apache.catalina.core.NamingContextListener.createNamingContext(NamingContextListener.java:557)
at org.apache.catalina.core.NamingContextListener.lifecycleEvent(NamingContextListener.java:253)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:922)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:343)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
Caused by: java.lang.ClassNotFoundException: Unable to load class: org.mariadb.jdbc.Driver from ClassLoader:java.net.URLClassLoader#2626b418;ClassLoader:java.net.URLClassLoader#2626b418
at org.apache.tomcat.jdbc.pool.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:56)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:281)
... 28 more
Caused by: java.lang.ClassNotFoundException: org.mariadb.jdbc.Driver
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.tomcat.jdbc.pool.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:38)
... 29 more
Feb 18, 2020 10:36:48 AM org.apache.naming.NamingContext lookup
WARNING: Unexpected exception resolving reference
java.sql.SQLException: Unable to load class: org.mariadb.jdbc.Driver from ClassLoader:java.net.URLClassLoader#2626b418;ClassLoader:java.net.URLClassLoader#2626b418
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:292)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:212)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:744)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:676)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:483)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107)
at org.apache.tomcat.jdbc.pool.DataSourceFactory.createDataSource(DataSourceFactory.java:560)
at org.apache.tomcat.jdbc.pool.DataSourceFactory.getObjectInstance(DataSourceFactory.java:244)
at org.apache.naming.factory.FactoryBase.getObjectInstance(FactoryBase.java:96)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:857)
at org.apache.naming.NamingContext.lookup(NamingContext.java:160)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:174)
at org.apache.catalina.core.NamingContextListener.addResource(NamingContextListener.java:1017)
I already added the jar mariadb here:
jar mariadb
and also the dependecy:
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.5.4</version>
</dependency>
and this is my file properties :
label.firstname=First Name
label.lastname=Last Name
label.email=Email
label.telephone=Telephone
label.add=Add Employee
label.nom= NOM
label.addp=Add Personne
label.menu=Actions
label.title=Employee Form
label.footer=© www.HowToDoInJava.com
spring.production.datasource.jndi-name=java:/global/production_gateway
spring.production.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.production.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
spring.production.jpa.show-sql = true
spring.production.jpa.hibernate.ddl-auto = update
help me please
I've been trying to start the application for 2 hours but without success, I think there is something missing that prevents me from doing this.
Your help will be very precious to me, I look forward to your response !!
I am using H2 database with Spring Boot project. I have runtime dependency on h2 in build.gradle.kts file, but it is not able to find the driver.
Caused by: java.lang.IllegalStateException: Driver for test database type [H2] is not available
at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseConfigurerFactory.getConfigurer(EmbeddedDatabaseConfigurerFactory.java:57) ~[spring-jdbc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.setDatabaseType(EmbeddedDatabaseFactory.java:132) ~[spring-jdbc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder.setType(EmbeddedDatabaseBuilder.java:121) ~[spring-jdbc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at com.example.datarestdemo.DataRestDemoApplication.dataSource(DataRestDemoApplication.kt:24) ~[main/:na]
at com.example.datarestdemo.DataRestDemoApplication$$EnhancerBySpringCGLIB$$3e09cdea.CGLIB$dataSource$0(<generated>) ~[main/:na]
at com.example.datarestdemo.DataRestDemoApplication$$EnhancerBySpringCGLIB$$3e09cdea$$FastClassBySpringCGLIB$$1a09d5e.invoke(<generated>) ~[main/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at com.example.datarestdemo.DataRestDemoApplication$$EnhancerBySpringCGLIB$$3e09cdea.dataSource(<generated>) ~[main/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_211]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_211]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
... 217 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.h2.Driver
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_211]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_211]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_211]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_211]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_211]
at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_211]
at org.springframework.util.ClassUtils.forName(ClassUtils.java:282) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jdbc.datasource.embedded.H2EmbeddedDatabaseConfigurer.getInstance(H2EmbeddedDatabaseConfigurer.java:51) ~[spring-jdbc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseConfigurerFactory.getConfigurer(EmbeddedDatabaseConfigurerFactory.java:49) ~[spring-jdbc-5.2.4.RELEASE.jar:5.2.4.RELEASE]
... 230 common frames omitted
This is how I added the runtime dependency
runtimeOnly("com.h2database:h2")
and this is plugin configuration
plugins {
id("org.springframework.boot") version "2.2.5.RELEASE"
id("io.spring.dependency-management") version "1.0.9.RELEASE"
kotlin("jvm") version "1.3.61"
kotlin("plugin.spring") version "1.3.61"
}
Am I missing something ?
Did anyone get Apache Shiro to work with Spring Boot 2?
Shiro depends on an old version of Spring and is causing some of my beans to be proxied, resulting in errors like the one below.
2019-01-01 16:15:20,713 DEBUG [restartedMain] org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter: Application failed to start due to an exception
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'prescriptionService' is expected to be of type 'com.nusrcraft.flexinics.feature.clinic.prescription.PrescriptionService' but was actually of type 'com.sun.proxy.$Proxy92'
Can work around this error with a hack: creating interfaces for the beans that are proxied - but will not apply this solution in production.
Using org.apache.shiro:shiro-spring-boot-starter:1.4.0
2019-01-01 16:15:20,713 DEBUG [restartedMain] org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter: Application failed to start due to an exception
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'prescriptionService' is expected to be of type 'com.nusrcraft.flexinics.feature.clinic.prescription.PrescriptionService' but was actually of type 'com.sun.proxy.$Proxy92'
full trace:
2019-01-01 16:15:20,711 DEBUG [restartedMain] org.springframework.boot.diagnostics.FailureAnalyzers: FailureAnalyzer org.springframework.boot.autoconfigure.jdbc.HikariDriverConfigurationFailureAnalyzer#f0a4f33 failed
java.lang.TypeNotPresentException: Type org.springframework.jdbc.CannotGetJdbcConnectionException not present
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.repository.ClassRepository.getSuperclass(ClassRepository.java:90)
at java.lang.Class.getGenericSuperclass(Class.java:777)
at org.springframework.core.ResolvableType.getSuperType(ResolvableType.java:466)
at org.springframework.core.ResolvableType.as(ResolvableType.java:455)
at org.springframework.core.ResolvableType.forClass(ResolvableType.java:1037)
at org.springframework.boot.diagnostics.AbstractFailureAnalyzer.getCauseType(AbstractFailureAnalyzer.java:58)
at org.springframework.boot.diagnostics.AbstractFailureAnalyzer.analyze(AbstractFailureAnalyzer.java:34)
at org.springframework.boot.diagnostics.FailureAnalyzers.analyze(FailureAnalyzers.java:114)
at org.springframework.boot.diagnostics.FailureAnalyzers.reportException(FailureAnalyzers.java:107)
at org.springframework.boot.SpringApplication.reportFailure(SpringApplication.java:848)
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:832)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.nusrcraft.flexinics.FlexinicsWebApplication.main(FlexinicsWebApplication.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.CannotGetJdbcConnectionException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
... 25 common frames omitted
2019-01-01 16:15:20,713 DEBUG [restartedMain] org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter: Application failed to start due to an exception
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'prescriptionService' is expected to be of type 'com.nusrcraft.flexinics.feature.clinic.prescription.PrescriptionService' but was actually of type 'com.sun.proxy.$Proxy92'
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1247)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1164)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.nusrcraft.flexinics.FlexinicsWebApplication.main(FlexinicsWebApplication.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
After adding 2 dependencies shown below to my application everything works fine my session data is written to my local redis server, but when i try to specify different address of redis server i got an error. I assume that error is connected with some dependencies problem, but i dont know how to tackle this issue.
compile "org.springframework.boot:spring-boot-starter-data-redis-reactive:${springVersion}"
compile "org.springframework.session:spring-session-data-redis:${springVersion}"
Error during startup
java.lang.IllegalStateException: Error processing condition on
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer
at
org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:180)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:61)
~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
pl.bk.pizza.store.Initializer.main(Initializer.java:11) [classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class
[org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration]
from ClassLoader [sun.misc.Launcher$AppClassLoader#18b4aac2] at
org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:659)
~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:556)
~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:569)
~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:541)
~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:599)
~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:724)
~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:665)
~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:633)
~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1489)
~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1012)
~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:164)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanType(BeanTypeRegistry.java:153)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.updateTypesIfNecessary(BeanTypeRegistry.java:203)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.getNamesForType(BeanTypeRegistry.java:115)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:265)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:254)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:196)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:116)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] ... 17
common frames omitted Caused by: java.lang.NoClassDefFoundError:
javax/servlet/Filter at java.lang.ClassLoader.defineClass1(Native
Method) ~[na:1.8.0-internal] at
java.lang.ClassLoader.defineClass(ClassLoader.java:763)
~[na:1.8.0-internal] at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
~[na:1.8.0-internal] at
java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
~[na:1.8.0-internal] at
java.net.URLClassLoader.access$100(URLClassLoader.java:73)
~[na:1.8.0-internal] at
java.net.URLClassLoader$1.run(URLClassLoader.java:368)
~[na:1.8.0-internal] at
java.net.URLClassLoader$1.run(URLClassLoader.java:362)
~[na:1.8.0-internal] at
java.security.AccessController.doPrivileged(Native Method)
~[na:1.8.0-internal] at
java.net.URLClassLoader.findClass(URLClassLoader.java:361)
~[na:1.8.0-internal] at
java.lang.ClassLoader.loadClass(ClassLoader.java:424)
~[na:1.8.0-internal] at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
~[na:1.8.0-internal] at
java.lang.ClassLoader.loadClass(ClassLoader.java:357)
~[na:1.8.0-internal] at java.lang.ClassLoader.defineClass1(Native
Method) ~[na:1.8.0-internal] at
java.lang.ClassLoader.defineClass(ClassLoader.java:763)
~[na:1.8.0-internal] at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
~[na:1.8.0-internal] at
java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
~[na:1.8.0-internal] at
java.net.URLClassLoader.access$100(URLClassLoader.java:73)
~[na:1.8.0-internal] at
java.net.URLClassLoader$1.run(URLClassLoader.java:368)
~[na:1.8.0-internal] at
java.net.URLClassLoader$1.run(URLClassLoader.java:362)
~[na:1.8.0-internal] at
java.security.AccessController.doPrivileged(Native Method)
~[na:1.8.0-internal] at
java.net.URLClassLoader.findClass(URLClassLoader.java:361)
~[na:1.8.0-internal] at
java.lang.ClassLoader.loadClass(ClassLoader.java:424)
~[na:1.8.0-internal] at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
~[na:1.8.0-internal] at
java.lang.ClassLoader.loadClass(ClassLoader.java:357)
~[na:1.8.0-internal] at java.lang.Class.getDeclaredMethods0(Native
Method) ~[na:1.8.0-internal] at
java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
~[na:1.8.0-internal] at
java.lang.Class.getDeclaredMethods(Class.java:1975)
~[na:1.8.0-internal] at
org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:641)
~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] ... 35 common frames
omitted Caused by: java.lang.ClassNotFoundException:
javax.servlet.Filter at
java.net.URLClassLoader.findClass(URLClassLoader.java:381)
~[na:1.8.0-internal] at
java.lang.ClassLoader.loadClass(ClassLoader.java:424)
~[na:1.8.0-internal] at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
~[na:1.8.0-internal] at
java.lang.ClassLoader.loadClass(ClassLoader.java:357)
~[na:1.8.0-internal] ... 63 common frames omitted
RedisConfig
#Configuration
#EnableRedisHttpSession
public class RedisConfig
{
#Bean
LettuceConnectionFactory jedisConnectionFactory()
{
final RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
config.setHostName("redis-19999.c14.us-east-1-2.ec2.cloud.redislabs.com");
config.setPort(19999);
config.setPassword(RedisPassword.of("***"));
return new LettuceConnectionFactory();
}
}
build.gradle file
buildscript {
ext.springVersion = '2.0.2.RELEASE'
ext.gradleDocker = '1.2'
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "se.transmode.gradle:gradle-docker:$gradleDocker"
classpath "org.springframework.boot:spring-boot-gradle-plugin:$springVersion"
}
}
plugins {
id "org.sonarqube" version "2.6.2"
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'groovy'
apply plugin: 'org.springframework.boot'
apply plugin: 'docker'
apply plugin: 'jacoco'
dependencies {
// spring
compile "org.springframework.boot:spring-boot-starter-webflux:${springVersion}"
compile "org.springframework.boot:spring-boot-starter-data-mongodb-reactive:${springVersion}"
compile "org.springframework.boot:spring-boot-starter-security:${springVersion}"
testCompile "org.springframework.security:spring-security-test:${springSecurityTest}"
testCompile "org.springframework.boot:spring-boot-starter-test:${springVersion}"
compile "org.springframework.boot:spring-boot-starter-data-redis-reactive:${springVersion}"
compile "org.springframework.session:spring-session-data-redis:${springVersion}"
// utils
testCompile "org.assertj:assertj-core:${assertJ}"
compile "com.google.guava:guava:${guava}"
compile "io.projectreactor:reactor-core:${reactor}"
compile "io.reactivex.rxjava2:rxjava:${rxjava}"
compile "commons-lang:commons-lang:${commonsLang}"
compile "commons-validator:commons-validator:${commonsLangValidator}"
compileOnly "org.projectlombok:lombok:${lombok}"
// embedded mongo for tests
testCompile "de.flapdoodle.embed:de.flapdoodle.embed.mongo:${embeddedMongo}"
// spock
compile "org.codehaus.groovy:groovy-all:${groovy}"
testCompile "org.spockframework:spock-core:${spockCore}"
testCompile "org.spockframework:spock-spring:${spockSpring}"
}
There are several thing going on here.
The log you've supplied indicates javax.servlet.Filter is missing from the classpath while your build script and dependencies suggest your building a Spring WebFlux app. I suspect this is due to you explicitly configuring Spring Session's Servlet support using #EnableRedisHttpSession (notice HttpSession in there?) rather than #EnableRedisWebSession. Even better, you should leave Spring Session configuration to Spring Boot to auto-configure it - see Spring Session dedicated section of Spring Boot's reference manual.
The same advice (avoid explicit config, rely on auto-config) applies to your Redis configuration i.e. no need for that explicit LettuceConnectionFactory bean.
Furthermore, with Spring Boot, it's highly recommended to use its dependency management, rather then providing the versions of your dependency explicitly, at least for the dependencies that are covered by Spring Boot's dependency management. Refer to dependency management and dependency versions appendix sections of Boot's reference manual. On top of that, you should also strongly consider using Boot's starters to make sure all the required dependencies are pulled in - see starters dedicated section.
This same error message presents if you create an application via spring initializr , specify Session as a dependency, create a #RestController and then use #EnableSpringHttpSession.
Without using #EnableSpringHttpSession, the application will start and exit, with no stack trace. This gives the appearance that perhaps there is something wrong with the HttpSession configuration.
The actual cause of the error condition is due to not having included Web as an application dependency (or implementation('org.springframework.boot:spring-boot-starter-web' in build.gradle)
For me ,Everything is perfect but it still throws the exception-Propertyplaceholderautoconfiguration
I just tried maven reload and project reload ,still it throws this error and shows some red lines on dependency Class which is I used to import and used it in my project files
Just closed IntelliJ and opened the project again,Then Everything works fine.
Thumbs up,If it is useful to you