0

我正在使用Wicket-1.5.xSpring-3.2Hibernate-3.6。我的应用程序成功启动并从数据库中读取,但是当我尝试实际加载页面时,我在下面粘贴了异常。

为什么找不到会话?据我所知,它甚至不是可怕的LazyLoadInitializationException,所以我什至不确定从哪里开始,我不确定它在页面渲染过程中是否已经足够远,无法判断 OpenSessionInViewFilter 是否会有所帮助。

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
<input wicket:id="firstName" type="text" class="noChange"/>, index = 0, current =  '<input wicket:id="firstName" type="text" class="noChange"/>' (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(<generated>)
    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(<generated>)
    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

更新

我的测试类扩展了以下类:

@ContextConfiguration(locations = { "classpath:testApplicationContext.xml" })
@TransactionConfiguration(transactionManager = "txManager")
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class AbstractWebPageTests implements ApplicationContextAware

我正在使用注释来连接我的测试类。但我试图坚持尽可能多地使用 XML 来连接我的实际 Web 应用程序,该应用程序new WicketTester(new MockLoggedInApplication(user));在我的测试开始时通过加载。MockLoggedInApplication extends QuickstartApplication我的应用程序在QuickStartApplication.init().

我应该粘贴我的applicationContext.xml吗?

笔记:

我想我已经缩小了问题的范围。

如果你仔细看底部Caused By:

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(<generated>)
    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(<generated>)
    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

我的 DAO由我的 Wicket 代理处理WICKET_us.ak.state.revenue.cssd.Personnel.dao.NameTableHome$$FastClassByCGLIB$$bd58bb2e.invoke(<generated>)。然而,尽管 wicket 为我代理了它,但它似乎从未被 Springs Transaction Management 抓住。

我的交易管理配置:

<bean id="sessionFactory"
      class="us.ak.state.revenue.cssd.Personnel.utils.SessionFactoryBean" >
  <property name="configLocation" value="classpath:hibernate.cfg.xml">
  </property>
</bean>

<bean id="txManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory">
    <ref bean="sessionFactory" />
  </property>
</bean>

<tx:advice id="txAdvice" transaction-manager="txManager">
    <tx:attributes>
      <tx:method name="find*"     propagation="REQUIRED"/>
      <!-- others omitted for brevity -->
    </tx:attributes>
</tx:advice>

<aop:config proxy-target-class="true" >
     <aop:advisor advice-ref="txAdvice"
          pointcut="execution(* *..BaseHibernateDAO+.find*(..))" />
     <!-- omitted for brevity -->
</aop:config> 

<bean id="NameTableHome"
      class="us.ak.state.revenue.cssd.Personnel.dao.NameTableHome" >
  <property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- other dao beans omitted for brevity -->

NameTableHome声明类似于:

public class NameTableHome extends BaseHibernateDAO
4

1 回答 1

0

根据 HibernateDaoSupport:143 的代码(至少在我的版本 spring-orm 3.2.2 中),我怀疑 HibernateDaoSupport 的 hibernateTemplate 字段为空。您确定模板设置正确吗?

于 2013-06-05T05:55:24.707 回答