title: ClassCastException InjectedDataSourceConnectionProvider Spring 3.1.0, Hibernate 4, JPA EntityManagerFactory
body: <p>Using:</p>
  
  <ul>
  <li>Spring 3.1.0</li>
  <li>Hibernate 4</li>
  <li>JPA 2</li>
  <li>GWT 2.3.0.</li>
  </ul>
  
  <p>[Similar to <a href="https://stackoverflow.com/questions/8891467/exception-in-spring-3-1-hibernate-4-0-1">Exception in GWT Dev Mode + Spring 3.1 + Hibernate 4.0.1</a> ]</p>
  
  <p>When running a very simple GWT application (using the Greeting Service) and adding a spring configuration to the application (via web.xml and related spring configuration files), an exception occurs when the system is brought up in gwt dev mode (from within Eclipse and from the command-line (mvn gwt:run)).</p>
  
  <p>The exception is shown below:</p>
  
  <blockquote>
    <p>[WARN] Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jgkgwtclasscastissueEntityManagerFactory' defined in ServletContext resource [/WEB-INF/classes/spring-main-config.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: jgkgwtclasscastissue-PU] Unable to build EntityManagerFactory: java.lang.ClassCastException: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider cannot be cast to org.hibernate.service.jdbc.connections.spi.ConnectionProvider</p>
  </blockquote>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  
      &lt;!-- POM file generated with GWT webAppCreator --&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.gs&lt;/groupId&gt;
      &lt;artifactId&gt;jgkgwtclasscastissue&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;GWT Maven Archetype&lt;/name&gt;
  
      &lt;properties&gt;
          &lt;gwtVersion&gt;2.3.0&lt;/gwtVersion&gt;
          &lt;maven.compiler.source&gt;1.6&lt;/maven.compiler.source&gt;
          &lt;maven.compiler.target&gt;1.6&lt;/maven.compiler.target&gt;
          &lt;webappDirectory&gt;${project.build.directory}/${project.build.finalName}    &lt;/webappDirectory&gt;
          &lt;antlr.version&gt;2.7.6&lt;/antlr.version&gt;
          &lt;aopalliance.version&gt;1.0&lt;/aopalliance.version&gt;
          &lt;c3p0.version&gt;0.9.1.2&lt;/c3p0.version&gt;
          &lt;cglib.version&gt;2.2.2&lt;/cglib.version&gt;
          &lt;commons-beanutils.version&gt;1.8.3&lt;/commons-beanutils.version&gt;
          &lt;commons-collections.version&gt;3.1&lt;/commons-collections.version&gt;
          &lt;commons-logging.version&gt;1.1.1&lt;/commons-logging.version&gt;
          &lt;ojdbc6.version&gt;11.1.0.7.0&lt;/ojdbc6.version&gt;
          &lt;commons-dbcp.version&gt;1.4&lt;/commons-dbcp.version&gt;
          &lt;dom4j.version&gt;1.6.1&lt;/dom4j.version&gt;
          &lt;ehcache.version&gt;2.4.6&lt;/ehcache.version&gt;
          &lt;javassist.version&gt;3.9.0.GA&lt;/javassist.version&gt;
          &lt;javax.inject.version&gt;1.0-PFD-1&lt;/javax.inject.version&gt;
          &lt;javax.transaction.version&gt;1.1&lt;/javax.transaction.version&gt;
          &lt;junit.version&gt;4.9&lt;/junit.version&gt;
          &lt;log4j.version&gt;1.2.16&lt;/log4j.version&gt;
          &lt;slf4j-api.version&gt;1.6.1&lt;/slf4j-api.version&gt;
          &lt;slf4j-log4j12.version&gt;1.6.1&lt;/slf4j-log4j12.version&gt;
  
          &lt;org.aspectj.version&gt;1.6.10&lt;/org.aspectj.version&gt;
          &lt;org.hibernate.version&gt;4.0.0.Final&lt;/org.hibernate.version&gt;
          &lt;org.hibernate-commons-annotations.version&gt;4.0.1.Final&lt;/org.hibernate-commons-annotations.version&gt;
              &lt;org.hibernate.hibernate-validator.version&gt;4.1.0.Final&lt;/org.hibernate.hibernate-validator.version&gt;
          &lt;org.hibernate.jpamodelgen.version&gt;1.1.1.Final&lt;/org.hibernate.jpamodelgen.version&gt;
          &lt;org.springframework.version&gt;3.1.0.RELEASE&lt;/org.springframework.version&gt;
          &lt;org.springframework.data.version&gt;1.0.1.RELEASE&lt;/org.springframework.data.version&gt;
          &lt;wagon-ssh.version&gt;1.0-beta-6&lt;/wagon-ssh.version&gt;
  
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;log4j&lt;/groupId&gt;
              &lt;artifactId&gt;log4j&lt;/artifactId&gt;
              &lt;version&gt;${log4j.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;version&gt;${slf4j-api.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
              &lt;version&gt;${slf4j-log4j12.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.gwt&lt;/groupId&gt;
              &lt;artifactId&gt;gwt-servlet&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.gwt&lt;/groupId&gt;
              &lt;artifactId&gt;gwt-user&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.7&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
              &lt;version&gt;4.1.0.Final&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate.common&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-commons-annotations&lt;/artifactId&gt;
              &lt;version&gt;${org.hibernate-commons-annotations.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
              &lt;version&gt;${org.hibernate.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;${org.hibernate.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-ehcache&lt;/artifactId&gt;
              &lt;version&gt;${org.hibernate.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-asm&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;commons-logging&lt;/groupId&gt;
                      &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-expression&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-jms&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;    
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-oxm&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;aopalliance&lt;/groupId&gt;
              &lt;artifactId&gt;aopalliance&lt;/artifactId&gt;
              &lt;version&gt;${aopalliance.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
              &lt;artifactId&gt;aspectjweaver&lt;/artifactId&gt;
              &lt;version&gt;${org.aspectj.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-instrument&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-instrument-tomcat&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
              &lt;artifactId&gt;spring-data-jpa&lt;/artifactId&gt;
              &lt;version&gt;${org.springframework.data.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
              &lt;artifactId&gt;spring-data-commons-core&lt;/artifactId&gt;
              &lt;version&gt;1.1.0.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.oracle&lt;/groupId&gt;
              &lt;artifactId&gt;ojdbc6&lt;/artifactId&gt;
              &lt;version&gt;${ojdbc6.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-beanutils&lt;/groupId&gt;
              &lt;artifactId&gt;commons-beanutils&lt;/artifactId&gt;
              &lt;version&gt;${commons-beanutils.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-jpamodelgen&lt;/artifactId&gt;
              &lt;version&gt;${org.hibernate.jpamodelgen.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
              &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
              &lt;version&gt;${commons-dbcp.version}&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;!-- Generate compiled stuff in the folder used for developing mode --&gt;
          &lt;outputDirectory&gt;${webappDirectory}/WEB-INF/classes&lt;/outputDirectory&gt;
  
          &lt;plugins&gt;
  
              &lt;!-- GWT Maven Plugin --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;gwt-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3.0&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;compile&lt;/goal&gt;
                              &lt;goal&gt;test&lt;/goal&gt;
                              &lt;goal&gt;i18n&lt;/goal&gt;
                              &lt;goal&gt;generateAsync&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;configuration&gt;
                      &lt;runTarget&gt;jgkgwtclasscastissue.html&lt;/runTarget&gt;
                      &lt;hostedWebapp&gt;${webappDirectory}&lt;/hostedWebapp&gt;
                                  &lt;i18nMessagesBundle&gt;com.gs.client.Messages&lt;/i18nMessagesBundle&gt;
                      &lt;/configuration&gt;
              &lt;/plugin&gt;
  
              &lt;!-- Copy static web files before executing gwt:run --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.1.1&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;compile&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;exploded&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;configuration&gt;
                      &lt;webappDirectory&gt;${webappDirectory}&lt;/webappDirectory&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>It is unclear where the problem is.  Any suggestions?</p>