Announcement Announcement Module
Collapse
No announcement yet.
problem today: Spring Data JPA Exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem today: Spring Data JPA Exception

    When I came in this morning, my integration tests were failing with the below exception. I didn't make any changes to my codebase, and to confirm, I have checked out an old branch and I now also get this same exception. Oddly, this only happens when running maven from the command line, my tests run individually from intellij just fine.

    It seems like something must have changed in one of my dependencies, or, I have something configured incorrectly in our dependencies that would cause this to start failing in this manner. I am really stuck, does anyone have any ideas?

    Here's the full stack trace:

    java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:157)
    at org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener.injectDependencies (DependencyInjectionTestExecutionListener.java:109 )
    at org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener.prepareTestInstanc e(DependencyInjectionTestExecutionListener.java:75 )
    at org.springframework.test.context.TestContextManage r.prepareTestInstance(TestContextManager.java:321)
    at org.springframework.test.context.testng.AbstractTe stNGSpringContextTests.springTestContextPrepareTes tInstance(AbstractTestNGSpringContextTests.java:13 3)
    at org.apache.maven.surefire.testng.TestNGExecutor.ru n(TestNGExecutor.java:77)
    at org.apache.maven.surefire.testng.TestNGDirectoryTe stSuite.executeMulti(TestNGDirectoryTestSuite.java :159)
    at org.apache.maven.surefire.testng.TestNGDirectoryTe stSuite.execute(TestNGDirectoryTestSuite.java:99)
    at org.apache.maven.surefire.testng.TestNGProvider.in voke(TestNGProvider.java:106)
    at org.apache.maven.surefire.util.ReflectionUtils.inv okeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$P roviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.i nvokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runS uitesInProcess(ForkedBooter.java:113)
    at org.apache.maven.surefire.booter.ForkedBooter.main (ForkedBooter.java:75)
    Caused by: org.springframework.beans.factory.BeanDefinitionSt oreException: Unexpected exception parsing XML document from class path resource [application_context.xml]; nested exception is org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.springframework.data.jpa.repository.config.Jpa RepositoryNameSpaceHandler] 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
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:412)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:302)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:180)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:243)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadBeanDefinitions(AbstractGe nericContextLoader.java:205)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:100)
    at org.springframework.test.context.support.AbstractG enericContextLoader.loadContext(AbstractGenericCon textLoader.java:1)
    at org.springframework.test.context.support.Delegatin gSmartContextLoader.loadContext(DelegatingSmartCon textLoader.java:228)
    at org.springframework.test.context.TestContext.loadA pplicationContext(TestContext.java:124)
    at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:148)
    ... 38 more
    Caused by: org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.springframework.data.jpa.repository.config.Jpa RepositoryNameSpaceHandler] 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
    at org.springframework.beans.factory.xml.DefaultNames paceHandlerResolver.resolve(DefaultNamespaceHandle rResolver.java:139)
    at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement(BeanDefinition ParserDelegate.java:1414)
    at org.springframework.beans.factory.xml.BeanDefiniti onParserDelegate.parseCustomElement(BeanDefinition ParserDelegate.java:1409)
    at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.parseBeanDefinitions(Defau ltBeanDefinitionDocumentReader.java:184)
    at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.doRegisterBeanDefinitions( DefaultBeanDefinitionDocumentReader.java:140)
    at org.springframework.beans.factory.xml.DefaultBeanD efinitionDocumentReader.registerBeanDefinitions(De faultBeanDefinitionDocumentReader.java:111)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.registerBeanDefinitions(XmlBeanDefinit ionReader.java:493)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:390)
    ... 50 more
    Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java :791)
    at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader .java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader. java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:4 23)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 56)
    at org.springframework.data.jpa.repository.config.Jpa RepositoryConfigDefinitionParser.<clinit>(JpaRepos itoryConfigDefinitionParser.java:45)
    at org.springframework.data.jpa.repository.config.Jpa RepositoryNameSpaceHandler.init(JpaRepositoryNameS paceHandler.java:34)
    at org.springframework.beans.factory.xml.DefaultNames paceHandlerResolver.resolve(DefaultNamespaceHandle rResolver.java:130)
    ... 57 more
    Caused by: java.lang.ClassNotFoundException: org.springframework.aop.framework.AbstractAdvising BeanPostProcessor
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:4 23)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 56)
    ... 72 more

  • #2
    If you are using spring-data-jpa-1.1.0.RELEASE along with spring 3.1.3.RELEASE, it appears that since the release of Spring Framework 3.2 RC2, it is using spring-tx-3.2.0.RC2.

    spring-data-jpa-1.1.0.RELEASE.pom
    ...
    <spring.version.30>3.0.7.RELEASE</spring.version.30>
    <spring.version.40>4.0.0.RELEASE</spring.version.40>
    <spring.version.range>[${spring.version.30}, ${spring.version.40})</spring.version.range>
    ...
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-tx</artifactId>
    <version>${spring.version.range}</version>
    </dependency>
    ...

    If you are using 3.1.3.RELEASE of spring, you will need to make sure that you are not using spring-tx-3.2.0.RC2.

    The JpaRepositoryNameSpaceHandler
    registerBeanDefinitionParser("repositories", new JpaRepositoryConfigDefinitionParser());

    class JpaRepositoryConfigDefinitionParser extends
    AbstractRepositoryConfigDefinitionParser<SimpleJpa RepositoryConfiguration, JpaRepositoryConfiguration> {

    private static final Class<?> PAB_POST_PROCESSOR = PersistenceAnnotationBeanPostProcessor.class;
    private static final Class<?> PET_POST_PROCESSOR = PersistenceExceptionTranslationPostProcessor.class ;
    private static final String DEFAULT_TRANSACTION_MANAGER_BEAN_NAME = "transactionManager";

    PersistenceExceptionTranslationPostProcessor of spring-tx-3.2.0.RC2
    import org.springframework.aop.framework.AbstractAdvising BeanPostProcessor;
    which does not exist.

    Comment


    • #3
      Hey Ben James,

      I've got the same problem today. Just curious, is this a bug in spring, maven, or my project ? I find it quite puzzling that in the year 2013 software development may break overnight ?

      How do I make sure that I am not using the spring-tx-3.2.0.RC2 since apparently this gets pulled in automatically by spring-data-jpa ? Or is it better to upgrade to the new version of spring ?

      Regards,
      koen

      Comment

      Working...
      X