Dean
Dean

Reputation: 887

java.lang.NoClassDefFoundError for org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor

Folks I am getting the following compilation error:

 May 11, 2014 1:30:41 PM org.apache.catalina.core.ApplicationContext log
 SEVERE: StandardWrapper.Throwable
 org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration    problem: Failed to import bean definitions from URL location [classpath*:META-  INF/spring/context.xml]
 Offending resource: ServletContext resource [/WEB-INF/spring/appServlet/servlet-  context.xml]; nested exception is  org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing   XML document from URL [jar:file:/C:/Users/Dean/Downloads/springsource/vfabric-tc-server-  developer-2.9.5.SR1/base-instance/wtpwebapps/cointraders-api/WEB-INF/lib/data-core-1.0.0-  SNAPSHOT.jar!/META-INF/spring/context.xml]; nested exception is    org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class  [org.springframework.data.jpa.repository.config.JpaRepositoryNameSpaceHandler] for namespace  [http://www.springframework.org/schema/data/jpa]: problem with handler class file or dependent  class; nested exception is java.lang.NoClassDefFoundError:  org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor

I am running spring 3.1.1.RELEASE. I have been trying to figure out this problem and there's little help from previous searches. My stack trace here link

Upvotes: 3

Views: 12895

Answers (5)

Adrian Redgers
Adrian Redgers

Reputation: 394

Following on from the extremely useful answer by Jay Paulynice above, my build.gradle file contains this (Spring versions are managed by our own BOM elsewhere) :-

dependencies {
  // Handle spring-aop conflict affecting AopInfrastructureBean (used by spring-security-core PermissionEvaluator).
  // Only use spring-aop from spring-security-core, and exclude any other instances of it.
  def withoutSpringAop = {
    exclude group: 'org.springframework', module: 'spring-aop'
  }
  implementation group: 'org.springframework.security', name: 'spring-security-core'
  implementation group: 'org.flywaydb', name: 'flyway-core', version: '5.1.4', withoutSpringAop
  implementation group: 'org.springframework.security', name: 'spring-security-web', withoutSpringAop
  implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', withoutSpringAop
  ...
}

This simple answer belies a lot of pain; I found it useful/necessary to search for 'aop' in the (fully expanded) dependency tree in my Intellij gradle window.

Upvotes: 0

Frank_Shi
Frank_Shi

Reputation: 11

If you use maven,you can use command 'mvn dependency tree' to check you project all jar dependencies,find depend on spring3.1.x and exclusion that.

Upvotes: 1

user1750873
user1750873

Reputation:

I ran into this issue as well. You need to exclude the spring-aop and spring-asm that come with spring-data and specify the spring-aop version you want. I'm using gradle, here is a snippet:

compile group: 'org.springframework', name: 'spring-aop', version:'3.2.8.RELEASE'
compile (group: 'org.springframework.data', name: 'spring-data-jpa', version:'1.3.4.RELEASE'){
    exclude(module: 'spring-aop')
    exclude(module: 'spring-tx')
    exclude(module: 'spring-asm')
}

Upvotes: 2

geoand
geoand

Reputation: 63991

The documentation for AbstractAdvisingBeanPostProcessor says that it exists since version 3.2, not Spring 3.1. Also from here where you can see all the classes in the spring-aop artifact from Spring 3.1.4, that class does not seem to exist.

I suggest you upgrade to Spring 3.2 and make sure that there are no Spring 3.1 dependencies on your classpath

Upvotes: 1

Elbek
Elbek

Reputation: 3484

After seeing your stack trace I noticed it saying Caused by: java.lang.ClassNotFoundException: org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor

This is the cause for No class def found exception. Add spring-aop jar to your run time class path. That jar must be missing now.

Upvotes: 2

Related Questions