Spring Boot: 2.0.3.RELEASE
org.apache.kafka.kafka-streams: 1.0.0
org.apache.kafka.kafka-clients: 1.0.0
org.springframwork.kafka:spring-kafka-test:2.1.7.RELEASE
I have a working Spring boot application with Kafka. I am trying to follow https://blog.mimacom.com/testing-apache-kafka-with-spring-boot/ to create an integration test.
When I add the #EmbeddedKafka annotation I get the error when I run
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kafkaEmbedded': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/kafka/common/record/RecordFormat
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1699) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:407) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
There are a few google results on this error however they are all on old kafka-client versions and they should be fixed in the version I use.
This looks like a version mismatch but it is not clear to me what I am supposed to me.
As indicated in comments errors like these are always due to library version incompatibilities. The following combination worked
spring boot: 2.1
spring-streams/spring-client: 2.0.1 (Using 2.2.0 creates some compatibility issues)
spring-kafka: 2.2.5.RELEASE
Related
I am using SpringBoot 2.7.2 in my project. And using springfox version 3.0.0 for swagger documentation.
The exception thrown is org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException.
What is the solution for it? Please assist.
spring fox behaves like a stranger in the new version of spring boot. you can try spring doc openapi
it works fine with spring boot 2.7.*.
I was upgrading spring 3.x to 5.3.x version in my project. Done some spring 5.3.x specific changes and deployed the build. Then following exception came:
Exception:"Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax.persistence.Converter"
Solution applied: added hibernate-jpa-2.1-api-1.0.0.Final as a solution.
Next following exception came:
"java.lang.ClassNotFoundException: org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter"
In spring docs, I could see ,OpenJpaVendorAdaptor is removed from spring5.x and jpa 2.1 compliant persistence provider is needed. when searching, could see using eclipselink is one of the solution instead of OpenJpa.
For which I have changed, org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter to org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter and in persistence.xml added org.eclipse.persistence.jpa.PersistenceProvider as provider tag.Then eclipselink-2.6.4 dependency added as gradle dependency.
could see jar is getting generated , but classes from jar is not picking up. getting following error on code compilation:
"Starting the enhancement task
[ant:openjpac] WARNING: Unable to load persistence provider "org.eclipse.persistence.jpa.PersistenceProvider" due to "java.lang.ClassNotFoundException: org.eclipse.persistence.jpa.PersistenceProvider""
Please help.
I am facing below error while deploying spring boot microservice on cloud foundry:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/ge/pd/reports/config/HibernateConfig.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
As I checked many resolution on stack overflow and many other portals for the solution, All the solution are related to jar version conflicts.
I have eliminated all the conflicts jar from the application and updated with all the jar versions which is required.
I am using below jar and its version:
hibernate-core-5.0.12.Final.jar - 5.0.12
hibernate-jpa-2.1-api-1.0.0.Final.jar - 2.1
hibernate-entitymanager-5.0.12.Final.jar - 5.0.12
openjpa-2.4.0.jar - 2.4.0
Please Provide the Solution.
This indeed looks like a dependency conflict, more specifically, between Hibernate 5.0.12 (which uses JPA 2.1) and OpenJPA 2.4.0 (which uses JPA 2.0). Try removing the OpenJPA dependency.
As this SO thread shows, the said method was introduced in JPA 2.1.
I am building a Spring project in Spring Tool Suite(3.6.4.RELEASE).
I am trying to upgrade spring framework version from 4.0.3.RELEASE to 4.2.7.RELEASE using maven.
Before upgradation there was no error and everything running smoothly. Now project is compiling and running without error but login page is not showing and also I am getting error in my spring security configuration xml.
Error in spring-security.xml:
Showing following error on STS hovering:
Multiple annotations found at this line:
- Factory bean 'org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser
$DefaultWebSecurityExpressionHandlerBeanFactory' not found [config set: mcare-dashboard-web/web-context]
- Factory bean 'org.springframework.security.config.http.HttpConfigurationBuilder
$SecurityContextHolderAwareRequestFilterBeanFactory' not found [config set: mcare-dashboard-web/web-context]
Project Hierarchy:
My pom.xml was like following:
Then I just changed the version number like this:
After that spring-security.xml was showing the error.
Can anybody explain why is this happening?
You state that you are upgrading Spring from version 4.0.3.RELEASE to 4.2.7.RELEASE. However effectively you are upgrading both Spring and Spring Security. This due to having a single version property, named org.springframework-version, to manage both the version of the Spring and Spring Security dependencies.
So changing org.springframework-version to 4.2.7.RELEASE effectively upgrades Spring Security as well.
To fix this you want to have two distinct version properties one for Spring and another for Spring Security. You can than upgrade only Spring or Spring Security.
I'm getting the below exception when deploying through tomcat version 7.0.4. I'm using java 1.7. Seems like it is working with jdk 1.6 properly though.
2013-09-26 13:03:58,154 ERROR [org.springframework.web.context.ContextLoader] -
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'cxf' defined in class path resource [META-INF/cxf/cxf.xml]: Initializati
on of bean failed; nested exception is java.lang.reflect.MalformedParameterizedT
ypeException
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
getBeansOfType(DefaultListableBeanFactory.java:308)
at org.springframework.context.support.AbstractApplicationContext.getBea
nsOfType(AbstractApplicationContext.java:947)
at org.springframework.context.support.AbstractApplicationContext.regist
erListeners(AbstractApplicationContext.java:701)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:377)
Had googled and found out that it has to do with version conflicts with spring jars.
I'm using the following spring jars.
spring-2.5.5 - tried with 2.5.6 also
spring-aop-2.5.6
spring-beans-2.5.6
spring-context-2.5.6
spring-core-2.5.6
spring-jdbc-3.1.1.RELEASE - tried with 2.5.6 also
spring-orm-3.1.1.RELEASE - tried with 2.5.6 also
spring-transaction-3.1.1.RELEASE - tried with 2.5.6 also
spring-tx-3.1.1.RELEASE - tried with 2.5.6 also
Following are the cxf jars used.
cxf-api-2.6.0
cxf-bundle-jaxrs-2.6.0
cxf-rt-bindings-soap-2.6.0
cxf-rt-bindings-xml-2.6.0
cxf-rt-core-2.6.0
cxf-rt-databinding-jaxb-2.6.0
cxf-rt-frontend-jaxws-2.6.0
cxf-rt-frontend-simple-2.6.0
cxf-rt-transports-http-2.6.0
cxf-rt-ws-addr-2.6.0
cxf-rt-ws-policy-2.6.0
Tried by replacing spring-aop-2.5.6, spring-beans-2.5.6, spring-context-2.5.6
,spring-core-2.5.6 with 3.1.1 also. Didnt help.
Had tried deleting metadata and checking out fresh project, clean build, etc.. but nothing seems to work. Could someone show me the way out of this. Stuck with it for two days.
I got the same exception at running time. After one day of research, I found my project is using spring 2.5.6. , which is the latest revision while my spring-jdbc is on 3.2.2.RELEASE. I am not able to use spring-jdbc 2.5.6 as I am using some of features that are not available in 2.5.6. The way I solved this problem is simply moving spring-jdbc-3.2.2.RELEASE.jar ahead of spring-2.5.6.jar in CLASSPATH. The exception went way. Hope this is helpful to some folks out there.
We had this exact same issue when moving from java 6 -> 7 and it turned out to be the commons-pool version.
Changed it from
commons-pool-1.5.7.jar
to
commons-pool-1.6.jar
and all was fine.