title: AppFuse + wicket: No qualifying bean of type [org.hibernate.SessionFactory]
body: <p>I have a small application written in AppFuse (multi-modular project). I want to try to use the Apache Wicket to make some kind of UI. Since AppFuse is based on Spring I found a <a href="http://www.mkyong.com/wicket/wicket-spring-integration-example/" rel="nofollow" title="tutorial">tutorial</a> for using Spring and Wicket together. I setted up the Wicket project using quickstart from the <a href="http://wicket.apache.org/start/quickstart.html" rel="nofollow" title="wicket">Wicket page</a>.
  Whenever I try to run the Wicket app I get this error (full stack trace is at the end of the post):</p>
  
  <pre class="lang-java prettyprint-override"><code>org.springframework.beans.factory.BeanCreationException: 
  Error creating bean with name 'personClubDao': 
  Injection of resource dependencies failed; 
  nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
  No qualifying bean of type [org.hibernate.SessionFactory] found for dependency: 
  expected at least 1 bean which qualifies as autowire candidate for this dependency.
  </code></pre>
  
  <p>Here is my AppFuse project structure</p>
  
  <pre><code>Hello (pom)
  +--core (jar) - generated by AppFuse
     +--org.microapp.hello.model
     +--org.microapp.hello.dao
  +--web (war)- generated by Appfuse
     +--org.microapp.hello.service
  +--wicket (war)- Wicket application
     +--org.microapp.hello
  </code></pre>
  
  <p>There are four entities in the core module - <strong>Person</strong>, <strong>Club</strong>, <strong>House</strong> and <strong>PersonClub</strong>. DAOs for Person, Club and House are registered in core/src/main/resources/applicationContext.xml (as shown <a href="http://appfuse.org/display/APF/Using+Hibernate" rel="nofollow" title="appfuse-hib">here</a>) and DAO for PersonClub entity is in org.microapp.hello.dao.PersonClubDaoHibernate.java.</p>
  
  <p>Here is <strong>PersonClubDao</strong> interface:</p>
  
  <pre class="lang-java prettyprint-override"><code>public interface PersonClubDao extends GenericDao&lt;PersonClub, Long&gt; {
      //some methods
  }
  </code></pre>
  
  <p>And here is <strong>PersonClubDaoHibernate</strong> class:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Repository("personClubDao")
  public class PersonClubDaoHibernate extends
      GenericDaoHibernate&lt;PersonClub, Long&gt; implements PersonClubDao {
  
      public PersonClubDaoHibernate() {
          super(PersonClub.class);
          // TODO Auto-generated constructor stub
      }
  
      //some methods
  }
  </code></pre>
  
  <p>What I'm trying to do now, is to autowire PersonClubDao (or any other DAO) in <strong>HomePage</strong> class in wicket module and display some data from the database.</p>
  
  <p>Here is the <strong>HomePage</strong> class:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class HomePage extends WebPage {
      private static final long serialVersionUID = 1L;
  
      @SpringBean
      private PersonClubDao personClubDao;
  
      public HomePage(final PageParameters parameters) {
          super(parameters);
          // TODO Add your page's components here
          //no code here so far
      }
  }
  </code></pre>
  
  <p>and the wicket/src/main/webapp/WEB-INF/applicationContext.xml </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
      &lt;context:component-scan base-package="org.microapp.hello.dao" /&gt;    
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>If I try to make some dummy interface and dummy class and wire it using <code>@SpringBean</code>, it works just fine. But when I try to wire any of my DAOs, the application crashes. I'm not quite sure what to do, I tried to add dependecies for hibernate packages into my pom.xml, but without luck and googling also didn't help.</p>
  
  <p>Here is the full stack trace:</p>
  
  <pre class="lang-java prettyprint-override"><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personClubDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.hibernate.SessionFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
  at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:311)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
  at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
  at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:800)
  at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:444)
  at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791)
  at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:294)
  at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349)
  at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp(JettyWebAppContext.java:296)
  at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
  at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
  at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
  at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:365)
  at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
  at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
  at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
  at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
  at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:163)
  at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
  at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
  at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
  at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
  at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
  at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
  at org.eclipse.jetty.server.Server.start(Server.java:387)
  at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
  at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
  at org.eclipse.jetty.server.Server.doStart(Server.java:354)
  at org.eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.java:73)
  at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
  at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:534)
  at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:357)
  at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:167)
  at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
  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:116)
  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
  at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
  at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
  at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
  at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
  at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
  at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
  at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
  at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.hibernate.SessionFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
  at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:508)
  at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:486)
  at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:615)
  at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)
  at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
  at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:308)
  ... 65 more
  </code></pre>