0 Replies Latest reply on Jul 28, 2007 2:06 AM by Jose Rubio

    Error when using JPA with Spring

    Jose Rubio Newbie

      I'm not sure if this is the right forum to post, but I'm running out of places. I have some Spring code that creates an EntityManager with hibernate and it's giving me an error. If I run the same code in a junit (pointing to the hibernate jars inside the jboss AS 4.2.0) it runs fine. I checked all jars and I only have that one version in the classpath.

      Is there anything known about trying to do this stuff inside JBoss? I haven't tried another container, but this is strange.

      Here's the error message:

      18:23:46,628 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [applicationContext.xml]
      18:23:50,742 INFO [LocalContainerEntityManagerFactoryBean] Building JPA container EntityManagerFactory for persistence unit 'lingraph-persistence'
      18:23:53,995 ERROR [DefaultFaultHandler] Fault occurred!
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderRepository' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Class org.hibernate.ejb.HibernatePersistence does not implement the requested interface javax.persistence.spi.PersistenceProvider
      Caused by:
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Class org.hibernate.ejb.HibernatePersistence does not implement the requested interface javax.persistence.spi.PersistenceProvider
      Caused by:
      java.lang.IncompatibleClassChangeError: Class org.hibernate.ejb.HibernatePersistence does not implement the requested interface javax.persistence.spi.PersistenceProvider
       at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:218)
       at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:251)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428)
       at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
       at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1100)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424)
       at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
       at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
       at test.numbersinsight.lingraph.order.webservices.CardOrderUpdateServiceTestImpl.getNewOrders(CardOrderUpdateServiceTestImpl.java:34)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)