title: java.lang.IncompatibleClassChangeError using Spring and hibernate in glassfish
body: <p>I'm using spring(3.0.4.RELEASE) and hibernate (3.4.0.GA) and deploying into a glassfish (web_3.1) container.</p>
  
  <p>I have 2 wars and I want them to share the same cache via JNDI (this is very important to me, I've already used terracotta but it is too heavy weight for our needs), so I've added the hibernate and ehcache jars to domains/domain1/lib/ext/</p>
  
  <pre>
  
      antlr-2.7.6.jar        
      dom4j-1.6.1.jar         
      ejb3-persistence-1.0.2.GA.jar       
      hibernate-commons-annotations-3.1.0.GA.jar  
      hibernate-entitymanager-3.4.0.GA.jar  
      jta-1.1.jar       
      postgresql-8.4-701.jdbc4.jar  
      slf4j-log4j12-1.6.1.jar
      commons-collections-3.1.jar  
      ehcache-core-2.4.2.jar  
      hibernate-annotations-3.4.0.GA.jar  
      hibernate-core-3.3.0.SP1.jar                
      javassist-3.4.GA.jar                  
      log4j-1.2.16.jar  
      slf4j-api-1.6.1.jar           
      xml-apis-1.0.b2.jar
  
  </pre>
  
  <p>The spring libs and dependencies are being included in both wars using maven to manage dependencies.</p>
  
  <pre>
  
      activation-1.1.jar       
      cglib-nodep-2.2.2.jar             
      commons-validator-1.3.1.jar                 
      hsqldb-2.2.4.jar         
      jsp-api-2.2.jar               
      slf4j-api-1.6.0.jar                       
      spring-orm-3.0.4.RELEASE.jar
      aopalliance-1.0.jar
      commons-beanutils-1.8.3.jar
      dwr-2.0.3.jar
      itext-2.1.7.jar
      jstl-1.2.jar
      spring-aop-3.0.4.RELEASE.jar
      spring-oxm-3.0.4.RELEASE.jar
      aspectjweaver-1.6.9.jar
      commons-codec-1.3.jar
      ehcache-core-2.2.0.jar
      itransact.jar
      jta-1.1.jar
      spring-asm-3.0.4.RELEASE.jar
      spring-tx-3.0.4.RELEASE.jar
      bcmail-jdk14-1.38.jar
      commons-collections-3.2.1.jar
      ehcache-spring-annotations-1.1.3.jar
      jakarta-oro-2.0.8.jar
      jtelnet-1.0.jar
      spring-beans-3.0.4.RELEASE.jar
      spring-web-3.0.4.RELEASE.jar
      bcmail-jdk14-138.jar
      commons-digester-1.7.jar
      eodsql-2.1.jar
      jasperreports-3.7.6.jar
      mail-1.4.3.jar
      spring-context-3.0.4.RELEASE.jar
      spring-webmvc-3.0.4.RELEASE.jar
      bcmail-jdk16-1.46.jar
      commons-fileupload-1.2.1.jar
      freemarker-2.3.17.jar
      jcommon-1.0.15.jar
      netty-3.2.5.Final.jar
      spring-context-support-3.0.6.RELEASE.jar
      terracotta-toolkit-1.3-runtime-3.2.0.jar
      bcprov-jdk14-1.38.jar
      commons-io-2.1.jar
      guava-r07.jar
      jdtcore-3.1.0.jar
      postgresql-8.4-701.jdbc4.jar
      spring-core-3.0.4.RELEASE.jar
      webappenhance-0.0.0.20.jar
      bcprov-jdk14-138.jar
      commons-lang-2.5.jar
      hornetq-core-2.2.7.Final.jar
      jfreechart-1.0.12.jar
      quartz-1.8.5.jar
      spring-expression-3.0.4.RELEASE.jar
      xml-apis-1.3.02.jar
      bcprov-jdk16-1.46.jar
      commons-logging-1.1.1.jar
      hornetq-jms-2.2.7.Final.jar
      jms-1.1.jar
      README.txt
      spring-jdbc-3.0.4.RELEASE.jar
      xpp3_min-1.1.4c.jar
      bctsp-jdk14-1.38.jar
      commons-pool-20030825.183949.jar
      hornetq-spring-integration-2.2.7.Final.jar
      js-1.7R2.jar
      satso-core.jar
      spring-jms-3.0.4.RELEASE.jar
      xstream-1.3.1.jar
  
  </pre>
  
  <p>When I deploy either of the wars I get the following exception:</p>
  
  <pre>
  
      org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [core-application-context-jpa.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
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:5328)
          at com.sun.enterprise.web.WebModule.start(WebModule.java:500)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1980)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1630)
          at com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
          at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
          at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
          at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
          at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
          at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
          at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
          at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)
          at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)
          at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
          at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
          at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
          at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
          at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
          at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
          at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
          at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
          at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
          at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
          at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
          at java.lang.Thread.run(Thread.java:662)
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [core-application-context-jpa.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
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
          at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
          at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
          at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
          at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4690)
          at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:534)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:5305)
          ... 38 more
      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:225)
          at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
          ... 53 more
  
  </pre>
  
  <p>I've scoured the web and most of the problems involve a clash between ejb3-persistence-1.0.2.GA.jar and the javax.persistence.jar provided with the application server.</p>
  
  <p>But I can't find any other javax.persistence.jar in the deployed wars or in any lib folders that are on my classpath. To double check that this error is not being caused by a duplicate classes on the classpath, I removed ejb3-persistence-1.0.2.GA.jar from the lib/ext directory and got the following error:</p>
  
  <pre>
  
      org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [core-application-context-jpa.xml]: Cannot create inner bean 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#104bc3' of type [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter] while setting bean property 'jpaVendorAdapter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#104bc3' defined in class path resource [core-application-context-jpa.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax/persistence/spi/PersistenceProvider
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:5328)
          at com.sun.enterprise.web.WebModule.start(WebModule.java:500)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1980)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1630)
          at com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
          at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
          at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
          at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
          at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
          at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
          at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
          at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
          at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)
          at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)
          at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
          at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
          at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
          at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
          at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
          at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
          at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
          at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
          at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
          at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
          at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
          at java.lang.Thread.run(Thread.java:662)
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [core-application-context-jpa.xml]: Cannot create inner bean 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#104bc3' of type [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter] while setting bean property 'jpaVendorAdapter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#104bc3' defined in class path resource [core-application-context-jpa.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax/persistence/spi/PersistenceProvider
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
          at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
          at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
          at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
          at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4690)
          at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:534)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:5305)
          ... 38 more
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#104bc3' defined in class path resource [core-application-context-jpa.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax/persistence/spi/PersistenceProvider
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
          at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
          ... 56 more
      Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax/persistence/spi/PersistenceProvider
          at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
          at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)
          ... 60 more
      Caused by: java.lang.NoClassDefFoundError: javax/persistence/spi/PersistenceProvider
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
          at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
          at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
          at com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader.loadClass(APIClassLoaderServiceImpl.java:196)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
          at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1465)
          at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1368)
          at org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.(HibernateJpaVendorAdapter.java:57)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
          at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
          ... 62 more
      Caused by: java.lang.ClassNotFoundException: javax.persistence.spi.PersistenceProvider
          at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
          at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
          ... 86 more
  
  </pre>
  
  <p>This leads me to assume that the previous error is not caused by duplicate javax/persistence/spi/PersistenceProvider classes on the classpath. I've toyed with the idea that spring and hibernate were compiled with different versions of javax.persistence.spi.PersistenceProvider but this theory seems incorrect as I'm using the version as stated on the maven repository site:</p>
  
  <p><a href="http://mvnrepository.com/artifact/org.springframework/spring-orm/3.0.4.RELEASE" rel="nofollow">http://mvnrepository.com/artifact/org.springframework/spring-orm/3.0.4.RELEASE</a></p>
  
  <p>but using spring-orm-3.1.0 does not fix the problem and I imagine if the documentation on the maven repository was incorrect, I would be finding a long more people with a similar problem.</p>
  
  <p>Any helpful advice on how to resolve this problem would be much appreciated.</p>