Java.lang.NoClassDefFoundError: org / springframework / core / DefaultParameterNameDiscoverer

I am trying to work out spring hibernation with maven dependencies.

My server does not start and throws this error:

java.lang.NoClassDefFoundError: org/springframework/core/DefaultParameterNameDiscoverer 

I do not know if this is a problem for my dependencies or my server. Let me know if you need anything from my project. Here are the dependencies that I added in my pom.xml file. I am using maven 4.0.0.

 <properties> <spring.version>3.0.5.RELEASE</spring.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <!-- Spring 3 dependencies --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <!-- <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.2.3.RELEASE</version> </dependency> --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>4.0.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.3.5.Final</version> <type>jar</type> <scope>compile</scope> </dependency> <!-- Hibernate annotation --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-ehcache</artifactId> <version>4.3.5.Final</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.31</version> </dependency> </dependencies> <repositories> <repository> <id>abc</id> <url>http://repo1.maven.org/maven2</url> </repository> </repositories> 
+7
spring hibernate
source share
3 answers

It is not wise to mix Spring versions in one project.

Error: you have a spring -core module working with 3.0.5, and the rest of the modules with 4.0.6

+6
source share

The resolution of this problem will depend on your pom.xml and the spring library. Some rejig from spring banners, including and excluding java files in maven, will allow this.

 I added the following to resolve the mongo-db spring-data jar related issue. <properties> <spring.version>3.2.4.RELEASE</spring.version> <spring.data.version>1.6.1.RELEASE</spring.data.version> <spring.core.version>4.1.4.RELEASE</spring.core.version> </properties> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.core.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>4.1.4.RELEASE</version> </dependency> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>${mongo.driver.version}</version> </dependency> <dependency> <groupId>org.jongo</groupId> <artifactId>jongo</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-mongodb</artifactId> <version>${spring.data.version}</version> </dependency> 
+2
source share

As Manuel Jordan said, this is because of the difference in versions. I just got this error and solved it by installing the same version of org.springframework: spring -core in each of my modules.

My project structure is as follows:

 projectname module1 module2 module3 

I wrote a test in module2:

 projectname module1 module2 test <package>/TestClass.java module3 

When I ran this test, I got this error:

  java.lang.NoClassDefFoundError: org/springframework/core/ErrorCoded 

After ensuring that each module has the same version of the org.springframework: spring -core dependency , the test runs .

0
source share

All Articles