0

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.

    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)

In spring-app.xml I have

<!-- DataSource -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="jndi.dataSource"/>
    <property name="persistenceUnitName" value="adminPersistenceUnit"/>
    <property name="persistenceUnitManager" ref="persistenceUnitManager"></property>
    <property name="jpaVendorAdapter">
       <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
           <property name="showSql" value="true" />
           <property name="generateDdl" value="true" />
           <property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect" />
       </bean>
    </property>
</bean>

And in persistence.xml I have

<?xml version="1.0" encoding="UTF-8"?>
<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">

   <persistence-unit name="adminPersistenceUnit" transaction-type="RESOURCE_LOCAL">
       <class>com.cubeia.games.poker.tournament.configuration.payouts.PayoutStructure</class>
       <class>com.cubeia.games.poker.tournament.configuration.payouts.Payouts</class>
       <class>com.cubeia.games.poker.tournament.configuration.payouts.Payout</class>
       <class>com.cubeia.games.poker.tournament.configuration.payouts.IntRange</class>
       <class>com.cubeia.games.poker.tournament.configuration.blinds.BlindsStructure</class>
       <class>com.cubeia.games.poker.tournament.configuration.blinds.Level</class>
       <class>com.cubeia.games.poker.tournament.configuration.TournamentSchedule</class>
       <class>com.cubeia.games.poker.tournament.configuration.ScheduledTournamentConfiguration</class>
       <class>com.cubeia.games.poker.tournament.configuration.SitAndGoConfiguration</class>
       <class>com.cubeia.games.poker.tournament.configuration.TournamentConfiguration</class>
       <class>com.cubeia.games.poker.tournament.configuration.RebuyConfiguration</class>
       <class>com.cubeia.games.poker.entity.TableConfigTemplate</class>
       <class>com.cubeia.poker.timing.TimingProfile</class>
       <class>com.cubeia.poker.settings.RakeSettings</class>


       <properties>
        <!-- property name="hibernate.hbm2ddl.auto" value="create-drop"/-->
      </properties>
   </persistence-unit>
</persistence>

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)

Would appreciate any input / suggestions. Thank you!

Nick M
  • 2,424
  • 5
  • 34
  • 57
  • Possible duplicate http://stackoverflow.com/questions/7914363/injection-of-autowired-dependencies-failed – victorantunes Aug 27 '13 at 20:04
  • 1
    Nope, have checked that, @ComponentScan will not work, the stack is different (getting errors about the DAO, table does not get created) – Nick M Aug 27 '13 at 20:06

1 Answers1

0

Turns out there was a problem with the code, some changes within the classes that were not propagated through the rest of the code that was using the implicit DB tables.

After forking before the commit in question, the error was gone completely.

broken code here

this helped

Seems this is somehow also connected to a bug in the hibernate implementation, got rid of it with some annotations

Nick M
  • 2,424
  • 5
  • 34
  • 57