DAO test case getting failed - java

DAO test cases getting failed due to below error:
Caused by: java.lang.ClassNotFoundException: de.flapdoodle.embed.process.config.RuntimeConfig
we are using spring boot 2.7.3 version , Spring data mongoDB :3.4.2, MongoDB :4.2,
de.flaodoodle.embeded.mongo-2.2.0, de.flaodoodle.embeded.process-2.1.2
Please help for the same

Try adding this to your spring boot application:
#SpringBootApplication(exclude = EmbeddedMongoAutoConfiguration.class)
It will disable auto configuration as that causes issues. You can use your own configuration in this case.

Related

Upgrading spring-boot version to 2.7.5, migrating to springdoc

While upgrading my spring-boot project to 2.7.5 i got some incompaitability issues with springfox and actuator, for that i made changes by following this link...
Spring Boot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'
Im using Actuator in my project, with the above changes actuator endpoints like /health not working fine, so i decided to migrate to springdoc.. i made the changes but im unable to open my swagger.. getting the below error
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'requestMappingHandlerMapping' defined
in class path resource
[org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]
I have added spring.mvc.pathmatch.matching-strategy=ant_path_matcher, im not getting the error but swagger was not opening and the actuator endpoints also not working as expected getting status as DOWN while checking the health..

Upgrading Springboot to 2.5.12 Causing build failure while Overriding Mock Cassandra

I have a springboot application which uses Cassandra Connection.Also my testClasses has mocked Cassandra Connection.
The following mocks worked till i was using Sprinboot 2.3.3.Release CqlSession,CqlSessionFactoryBean,CassandraProperties,InterfaceRepos,CassandraConverter,DriverContextCodecRegistryCassandraMappingContextReactiveCassandraTemplate
Now I am trying to upgrade Springboot application
from 2.3.3.Release to 2.5.12,
The following are upgraded because of springboot upgrade
Springjars upgraded from 5.2.8.Release to 5.3.18,
Spring-data-Cassandra from 3.0.3.Release to 3.2.10
java-driver-core from 4.6.1 to 4.11.3
com.datastax.cassandra:cassandra-driver-core:jar is still 3.11.0
My main application is able to connect with cassandra without issues, whereas my testCases fails while overriding the Cassandra Connection.Now when i run my testCases, it fails with the below error:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.data.cassandra.ReactiveSession]: Factory method 'reactiveCassandraSession' threw exception;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.datastax.oss.driver.api.core.CqlSession' available
Troubleshooting measure i did:
i)After i upgrade spring boot 2.5.12 , if i downgrade spring-context-5.3.18.Release to 5.2.8.Release i am able to run test cases without issues , so even when i increment to 5.2.9.Release i am getting the above issue , but i believe downgrading to spring-context:5.2.8 is not a good solution.
ii)I have downgraded Spring-data-Cassandra & java-driver-core with different combinations but it didn't provide any fix.
iii)I tried replacing #Mock annotations with mock()

Failed to read candidate component class in spring mvc & spring boot

i add spring boot project as dependency in spring mvc project , application can run successfully but when i call service i faced below error
Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed
to read candidate component class: nested exception is
org.springframework.core.annotation.AnnotationConfigurationException:
Attribute 'proxyBeanMethods' in annotation
[org.springframework.boot.SpringBootConfiguration] is declared as an
#AliasFor nonexistent attribute 'proxyBeanMethods' in annotation
[org.springframework.context.annotation.Configuration].; nested
exception is java.lang.NoSuchMethodException:
org.springframework.context.annotation.Configuration.proxyBeanMethods()
Attribute 'proxyBeanMethods' in annotation
[org.springframework.boot.SpringBootConfiguration] is declared as an
#AliasFor nonexistent attribute 'proxyBeanMethods' in annotation
[org.springframework.context.annotation.Configuration].; nested
exception is java.lang.NoSuchMethodException:
org.springframework.context.annotation.Configuration.proxyBeanMethods()
It mainly complains about your #Configuration does not have an attribute called proxyBeanMethods. Checking from the javadoc , this attribute is added since Spring 5.2.
Most probably it is because you are messing up the spring version with your spring-boot version. Your spring version is too old (before 5.2) such that the above attribute of the #Configuration is not defined.
You should use the spring framework which the version is defined by the spring-boot version that you use . Show me the pom.xml and I can help to check which <dependency> causes such version mismatch. Thanks.

JUnit is failing after upgrading to Spring boot 2.3

Upgrading my Application from Spring boot 2.1.6 to Spring boot 2.3
After adding this property in my Yaml file, I am able to run my application
Spring.main.allow-bean-definition-overriding: true
But even after same property in my yml file , getting following error , any clue will be appreciated
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:132
Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException at DefaultListableBeanFactory.java:995
for reference this is my sample Junit class
#SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
#ActiveProfiles("local,test")
#DirtiesContext
public class ControllerContextTest {
}

All beans fail autowire on startup because of a NoSuchMethodError

After upgrading my project to Spring AOP 4.3.7 I get this error trace on every bean auto-wire at Spring Boot startup:
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
at org.springframework.context.event.AbstractApplicationEventMulticaster.addApplicationListener(AbstractApplicationEventMulticaster.java:105)
at org.springframework.context.support.AbstractApplicationContext.addApplicationListener(AbstractApplicationContext.java:494)
at org.springframework.context.support.ApplicationListenerDetector.postProcessAfterInitialization(ApplicationListenerDetector.java:78)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:423)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1633)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
...Stack truncated here for privacy reasons...
I get the sense this is a mismatch in a Spring AOP Jar somewhere in the stack, but cannot find anything that references an actual object to trace.
I was able to resolve this by upgrading to Spring AOP 4.3.13
See these links for the old and new versions of these libraries in the API.

Categories