title: NullPointerException in HibernateDaoSupport.getSession()
body: <p>I'm using <strong>Wicket-1.5.x</strong>, <strong>Spring-3.2</strong>, and <strong>Hibernate-3.6</strong>.  My application successfully starts and reads from the database, however when I try to actually load a page I get the exception pasted below.</p>
  
  <p>Why can't it find the session?  From what I can tell its not even the dreaded <code>LazyLoadInitializationException</code> so I'm not even sure where to begin, I'm not sure its gotten far enough in the page render process to tell whether or not if OpenSessionInViewFilter would even have helped.</p>
  
  <pre><code>org.apache.wicket.WicketRuntimeException: Exception in rendering component: [TooltipContainer [Component id = firstNameTip]]
      at org.apache.wicket.Component.internalRenderComponent(Component.java:2590)
      at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1530)
      at org.apache.wicket.Component.internalRender(Component.java:2393)
      at org.apache.wicket.Component.render(Component.java:2321)
      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1428)
      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1592)
      at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1567)
      at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1521)
      at org.apache.wicket.markup.html.form.Form.onComponentTagBody(Form.java:1656)
      at org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:72)
      at org.apache.wicket.Component.internalRenderComponent(Component.java:2563)
      at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1530)
      at org.apache.wicket.Component.internalRender(Component.java:2393)
      at org.apache.wicket.Component.render(Component.java:2321)
      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1428)
      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1592)
      at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1567)
      at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1521)
      at org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:72)
      at org.apache.wicket.Component.internalRenderComponent(Component.java:2563)
      at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1530)
      at org.apache.wicket.Component.internalRender(Component.java:2393)
      at org.apache.wicket.Component.render(Component.java:2321)
      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1428)
      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1592)
      at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1567)
      at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1521)
      at org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:72)
      at org.apache.wicket.Component.internalRenderComponent(Component.java:2563)
      at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1530)
      at org.apache.wicket.Component.internalRender(Component.java:2393)
      at org.apache.wicket.Component.render(Component.java:2321)
      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1428)
      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1592)
      at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1567)
      at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1521)
      at org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:72)
      at org.apache.wicket.Component.internalRenderComponent(Component.java:2563)
      at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1530)
      at org.apache.wicket.Component.internalRender(Component.java:2393)
      at org.apache.wicket.Component.render(Component.java:2321)
      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1428)
      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1592)
      at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1567)
      at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1521)
      at org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:72)
      at org.apache.wicket.Component.internalRenderComponent(Component.java:2563)
      at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1530)
      at org.apache.wicket.Component.internalRender(Component.java:2393)
      at org.apache.wicket.Component.render(Component.java:2321)
      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1428)
      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1592)
      at org.apache.wicket.Page.onRender(Page.java:907)
      at org.apache.wicket.markup.html.WebPage.onRender(WebPage.java:140)
      at org.apache.wicket.Component.internalRender(Component.java:2393)
      at org.apache.wicket.Component.render(Component.java:2321)
      at org.apache.wicket.Page.renderPage(Page.java:1035)
      at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:118)
      at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:246)
      at org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:167)
      at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:784)
      at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
      at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:255)
      at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:212)
      at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:283)
      at org.apache.wicket.util.tester.BaseWicketTester.processRequest(BaseWicketTester.java:696)
      at org.apache.wicket.util.tester.BaseWicketTester.processRequest(BaseWicketTester.java:624)
      at org.apache.wicket.util.tester.BaseWicketTester.processRequest(BaseWicketTester.java:596)
      at org.apache.wicket.util.tester.BaseWicketTester.startPage(BaseWicketTester.java:1257)
      at org.apache.wicket.util.tester.BaseWicketTester.startPage(BaseWicketTester.java:1230)
      at us.ak.state.revenue.cssd.Personnel.Pages.MaintenanceForms.Employee.TestChangeRequestMaintenance.__CLR3_1_11lo23k3ciu(TestChangeRequestMaintenance.java:52)
      at us.ak.state.revenue.cssd.Personnel.Pages.MaintenanceForms.Employee.TestChangeRequestMaintenance.testLoadPageLoggedIn_DO(TestChangeRequestMaintenance.java:49)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
      at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
      at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
  Caused by: java.lang.RuntimeException: An error occurred while getting the model object for Component: [TextField [Component id = firstName, page = us.ak.state.revenue.cssd.Personnel.Pages.MaintenanceForms.Employee.ChangeRequestMaint, path = 0:emp_info_maint:firstNameTip:firstName.TextField, isVisible = true, isVersioned = false, markup = [markup = file:/C:/Users/tfburton/Documents/JavaProjects/SVN/Personnel/trunk/target/classes/us/ak/state/revenue/cssd/Personnel/Pages/MaintenanceForms/Employee/ChangeRequestMaint.html
  &lt;input wicket:id="firstName" type="text" class="noChange"/&gt;, index = 0, current =  '&lt;input wicket:id="firstName" type="text" class="noChange"/&gt;' (line 0, column 0)]]]
      at org.apache.wicket.Component.getDefaultModelObject(Component.java:1679)
      at org.apache.wicket.Component.getDefaultModelObjectAsString(Component.java:1701)
      at org.apache.wicket.markup.html.form.FormComponent.getModelValue(FormComponent.java:1211)
      at org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:837)
      at org.apache.wicket.markup.html.form.TextField.onComponentTag(TextField.java:108)
      at org.apache.wicket.Component.internalRenderComponent(Component.java:2534)
      at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1530)
      at org.apache.wicket.Component.internalRender(Component.java:2393)
      at org.apache.wicket.Component.render(Component.java:2321)
      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1428)
      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1592)
      at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1567)
      at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1521)
      at org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:72)
      at org.apache.wicket.Component.internalRenderComponent(Component.java:2563)
      ... 104 more
  Caused by: org.apache.wicket.WicketRuntimeException: Error calling method: public java.lang.String us.ak.state.revenue.cssd.Personnel.dao.Employee.Employee.getFirstName() on object: null
      at org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.getValue(PropertyResolver.java:1127)
      at org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.getValue(PropertyResolver.java:648)
      at org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:102)
      at org.apache.wicket.model.AbstractPropertyModel.getObject(AbstractPropertyModel.java:134)
      at org.apache.wicket.Component.getDefaultModelObject(Component.java:1674)
      ... 118 more
  Caused by: java.lang.NullPointerException
      at org.springframework.orm.hibernate3.support.HibernateDaoSupport.getSession(HibernateDaoSupport.java:143)
      at us.ak.state.revenue.cssd.Personnel.dao.NameTableHome.findByPcn(NameTableHome.java:555)
      at WICKET_us.ak.state.revenue.cssd.Personnel.dao.NameTableHome$$FastClassByCGLIB$$bd58bb2e.invoke(&lt;generated&gt;)
      at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
      at org.apache.wicket.proxy.LazyInitProxyFactory$CGLibInterceptor.intercept(LazyInitProxyFactory.java:333)
      at WICKET_us.ak.state.revenue.cssd.Personnel.dao.NameTableHome$$EnhancerByCGLIB$$e12a569d.findByPcn(&lt;generated&gt;)
      at us.ak.state.revenue.cssd.Personnel.dao.PcnTable.getNameTable(PcnTable.java:198)
      at us.ak.state.revenue.cssd.Personnel.dao.Employee.Employee.getNameTable(Employee.java:697)
      at us.ak.state.revenue.cssd.Personnel.dao.Employee.Employee.getFirstName(Employee.java:67)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.getValue(PropertyResolver
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>My Test Classes extend the following class:  </p>
  
  <pre><code>@ContextConfiguration(locations = { "classpath:testApplicationContext.xml" })
  @TransactionConfiguration(transactionManager = "txManager")
  @RunWith(SpringJUnit4ClassRunner.class)
  public abstract class AbstractWebPageTests implements ApplicationContextAware
  </code></pre>
  
  <p>I'm using annotations to wire up my Test classes. But I'm trying to stick to using XML as much as possible to wire-up my actual Web Application which gets loaded via <code>new WicketTester(new MockLoggedInApplication(user));</code> at the beginning of my tests. <code>MockLoggedInApplication extends QuickstartApplication</code> and my application does a lot of database reads inside of <code>QuickStartApplication.init()</code>.</p>
  
  <p>should I paste my <code>applicationContext.xml</code>?</p>
  
  <p><strong>NOTE:</strong></p>
  
  <p>I think I've narrowed down the problem.</p>
  
  <p>If you look closely at the bottom <code>Caused By:</code>  </p>
  
  <pre><code>Caused by: java.lang.NullPointerException
      at org.springframework.orm.hibernate3.support.HibernateDaoSupport.getSession(HibernateDaoSupport.java:143)
      at us.ak.state.revenue.cssd.Personnel.dao.NameTableHome.findByPcn(NameTableHome.java:555)
      at WICKET_us.ak.state.revenue.cssd.Personnel.dao.NameTableHome$$FastClassByCGLIB$$bd58bb2e.invoke(&lt;generated&gt;)
      at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
      at org.apache.wicket.proxy.LazyInitProxyFactory$CGLibInterceptor.intercept(LazyInitProxyFactory.java:333)
      at WICKET_us.ak.state.revenue.cssd.Personnel.dao.NameTableHome$$EnhancerByCGLIB$$e12a569d.findByPcn(&lt;generated&gt;)
      at us.ak.state.revenue.cssd.Personnel.dao.PcnTable.getNameTable(PcnTable.java:198)
      at us.ak.state.revenue.cssd.Personnel.dao.Employee.Employee.getNameTable(Employee.java:697)
      at us.ak.state.revenue.cssd.Personnel.dao.Employee.Employee.getFirstName(Employee.java:67)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.getValue(PropertyResolver
  </code></pre>
  
  <p>My DAO is <em>processed</em> by my Wicket proxy <code>WICKET_us.ak.state.revenue.cssd.Personnel.dao.NameTableHome$$FastClassByCGLIB$$bd58bb2e.invoke(&lt;generated&gt;)</code>.  However, even though wicket proxies it for me it never appears to get grabbed by Springs Transaction Management.</p>
  
  <p>My Transaction Management config:  </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;bean id="sessionFactory"
        class="us.ak.state.revenue.cssd.Personnel.utils.SessionFactoryBean" &gt;
    &lt;property name="configLocation" value="classpath:hibernate.cfg.xml"&gt;
    &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="txManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
    &lt;property name="sessionFactory"&gt;
      &lt;ref bean="sessionFactory" /&gt;
    &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;tx:advice id="txAdvice" transaction-manager="txManager"&gt;
      &lt;tx:attributes&gt;
        &lt;tx:method name="find*"     propagation="REQUIRED"/&gt;
        &lt;!-- others omitted for brevity --&gt;
      &lt;/tx:attributes&gt;
  &lt;/tx:advice&gt;
  
  &lt;aop:config proxy-target-class="true" &gt;
       &lt;aop:advisor advice-ref="txAdvice"
            pointcut="execution(* *..BaseHibernateDAO+.find*(..))" /&gt;
       &lt;!-- omitted for brevity --&gt;
  &lt;/aop:config&gt; 
  
  &lt;bean id="NameTableHome"
        class="us.ak.state.revenue.cssd.Personnel.dao.NameTableHome" &gt;
    &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
  &lt;/bean&gt;
  &lt;!-- other dao beans omitted for brevity --&gt;
  </code></pre>
  
  <p><code>NameTableHome</code> is declared similar to this:</p>
  
  <pre><code>public class NameTableHome extends BaseHibernateDAO
  </code></pre>