title: Java spring persistence error creating bean
body: <p>I'm trying to set up an open source product, getting this error, can't figure out exactly what this is about (not a java programmer). Would appreciate any input. </p>
  
  <pre><code>    2013-08-27 19:15:32,791 - ERROR org.springframework.web.context.ContextLoader - Context initialization failed
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'payoutStructureServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.f
  actory.BeanCreationException: Could not autowire field: private com.cubeia.games.poker.admin.db.AdminDAO com.cubeia.games.poker.admin.service.PayoutStructureServiceImpl.adminDAO; nested exception is org.sprin
  gframework.beans.factory.BeanCreationException: Error creating bean with name 'adminDAO' defined in class path resource [spring-app.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 [spring-a
  pp.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: adminPersistenceUnit] Unable to build EntityManagerFactory
          at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
          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:294)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
          at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
          at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
          at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
          at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:771)
          at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:411)
          at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:763)
          at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:247)
          at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1238)
          at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706)
          at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:480)
          at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:293)
          at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
          at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)
          at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:172)
          at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
          at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)
          at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
          at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
          at org.eclipse.jetty.server.Server.doStart(Server.java:277)
          at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:65)
          at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
          at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:511)
          at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:364)
          at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:516)
          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
          at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
          at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
          at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:318)
          at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
          at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
  </code></pre>
  
  <p>In spring-app.xml I have</p>
  
  <pre><code>&lt;!-- DataSource --&gt;
  &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="dataSource" ref="jndi.dataSource"/&gt;
      &lt;property name="persistenceUnitName" value="adminPersistenceUnit"/&gt;
      &lt;property name="persistenceUnitManager" ref="persistenceUnitManager"&gt;&lt;/property&gt;
      &lt;property name="jpaVendorAdapter"&gt;
         &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
             &lt;property name="showSql" value="true" /&gt;
             &lt;property name="generateDdl" value="true" /&gt;
             &lt;property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect" /&gt;
         &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>And in persistence.xml I have</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
     version="1.0"&gt;
  
     &lt;persistence-unit name="adminPersistenceUnit" transaction-type="RESOURCE_LOCAL"&gt;
         &lt;class&gt;com.cubeia.games.poker.tournament.configuration.payouts.PayoutStructure&lt;/class&gt;
         &lt;class&gt;com.cubeia.games.poker.tournament.configuration.payouts.Payouts&lt;/class&gt;
         &lt;class&gt;com.cubeia.games.poker.tournament.configuration.payouts.Payout&lt;/class&gt;
         &lt;class&gt;com.cubeia.games.poker.tournament.configuration.payouts.IntRange&lt;/class&gt;
         &lt;class&gt;com.cubeia.games.poker.tournament.configuration.blinds.BlindsStructure&lt;/class&gt;
         &lt;class&gt;com.cubeia.games.poker.tournament.configuration.blinds.Level&lt;/class&gt;
         &lt;class&gt;com.cubeia.games.poker.tournament.configuration.TournamentSchedule&lt;/class&gt;
         &lt;class&gt;com.cubeia.games.poker.tournament.configuration.ScheduledTournamentConfiguration&lt;/class&gt;
         &lt;class&gt;com.cubeia.games.poker.tournament.configuration.SitAndGoConfiguration&lt;/class&gt;
         &lt;class&gt;com.cubeia.games.poker.tournament.configuration.TournamentConfiguration&lt;/class&gt;
         &lt;class&gt;com.cubeia.games.poker.tournament.configuration.RebuyConfiguration&lt;/class&gt;
         &lt;class&gt;com.cubeia.games.poker.entity.TableConfigTemplate&lt;/class&gt;
         &lt;class&gt;com.cubeia.poker.timing.TimingProfile&lt;/class&gt;
         &lt;class&gt;com.cubeia.poker.settings.RakeSettings&lt;/class&gt;
  
  
         &lt;properties&gt;
          &lt;!-- property name="hibernate.hbm2ddl.auto" value="create-drop"/--&gt;
        &lt;/properties&gt;
     &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>Funny thing, if I switch to MySQL from within jetty-env.xml and I configure a local or remote database, the app crashes saying JDBC timeout error, which is impossible, the whole infrastructure is class A, no errors, timeouts or anything, can SSH/Telnet/mysql into the server without a problem. Same for localhost actually. Got a hunch that this is actually an error related to the stuff above as opposed to a real connection issue (thanks java for the obscurity)</p>
  
  <p>Would appreciate any input / suggestions. Thank you!</p>