I developed a Spring JPA project in eclipse which has access to the data stored in a mysql server. Now I need to import this project in a Spring @ MVC project. So:
The dependencies:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
Does the version of these (3.1.0.RELEASE) match maven variable ${spring.framework.version}. As far as I can tell that could cause a mismatch of versions and may be causing the no such field error which usually is caused by mismatching versions.
This indeed is often caused by a version mismatch somewhere. Verify all your spring jars version. And maybe upgrade your JPA provider if it still doesn't work.
In my case the conflict was caused by spring security, which was still using older versions. I put some excludes on it, and now it is ok. It may also be a good thing to put this stuff in the dependencyManagement so you don't have to repeat in every module.
I am using the following:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring.security.framework.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.framework.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.security.framework.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.0.1.Final</version>
</dependency>
</dependencies>
</dependencyManagement>
without the exclusions I had the same error as described in the beginning of this thread. The versions i was using for spring were:
<properties>
<spring.framework.version>3.1.1.RELEASE</spring.framework.version>
<spring.security.framework.version>3.1.0.RELEASE</spring.security.framework.version>
</properties>
I have had the same problem, and it turned out there was indeed a version mismatch, the problem with mine was that i used a server variable, in the form of ${server.env}, and it was this that gave the problem. Since my spring-expression version was 3.0.5 still. You should try adding these to your pom :
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${version.spring.framework}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${version.spring.framework}</version>
</dependency>