Hmm, OK attachments are stripped here. Having gone back up through the stack
trace, WicketTester extends BaseWicketTester which then extends
MockWebApplication. Essentially MockWebApplication has the base
implementations for setting up the WebRequestCycle.
The @SpringBean is having an effect, because my exception is a
HibernateException and not a NullPointerException. I think it has something to
do with how the <tx:annotation-driven transaction-manager="txManager" />
interacts with the WicketTester that is unclear to me. The thing that has
changed is that while I had that declaration, I introduced using the
@Transactional attributes on some of my Hibernate objects. Spring is giving me
a proxied class that is supposed to take care of the hibernate sessions and
transactions for me. It's having a hard time in the JUnit environment. I'm
using the following TransactionManager:
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
-----Original Message-----
From: Loritsch, Berin C. [mailto:[email protected]]
Sent: Tuesday, November 17, 2009 4:15 PM
To: [email protected]
Subject: RE: Spring/Wicket/Hibernate testing driving me banana nuts
I've got the part that injects a Spring WebApplicationContext into the
WicketTester already (Source attached). I should be using the application
class, if I'm not then something has changed unbeknownst to me. Is there any
place it would swap out what I told it to use for what it decided on its own to
use?
-----Original Message-----
From: Igor Vaynberg [mailto:[email protected]]
Sent: Tuesday, November 17, 2009 4:05 PM
To: [email protected]
Subject: Re: Spring/Wicket/Hibernate testing driving me banana nuts
i see you are using MockWebApplication in your tests. this application does not
install the SpringComponentInjector and so @SpringBean has no effect.
you should either give wickettester an instance of your actual application
class, or create a mock one that installs springcomponentinjector.
-igor
On Tue, Nov 17, 2009 at 1:00 PM, Loritsch, Berin C.
<[email protected]> wrote:
> <<application.xml>> I initially had a setup that worked with both a
> Web context and a JUnit context. The problem was the amount of hand
> coding and adjusting of the Spring context the approach needed. I
> finally got the Spring's transaction interceptor working with the
> auto-wiring (the key is using an interface). So now my problem is
> that while I've saved myself the headache of making changes to a bunch
> of files every time I add a new service, my unit tests are now failing.
>
> I've traced the failure to a specific class that is decorated with the
> InjectorHolder--although I believe that is merely because it is the
> first component that does any Hibernate requests. I'll include the
> stacktrace at the bottom of the message.
>
> I had to remove the line that specified that sessions would be thread
> bound in Hibernate to take advantage of the Spring managed
> transactions, and adding that configuration item back in makes no
> difference for the tests. I'm hoping I'm just missing something
> simple, but all my Googling is turning up dead ends. Any help out there?
>
>
>
>
>
>
>
>
> org.apache.wicket.WicketRuntimeException: Error attaching this
> container for rendering: [MarkupContainer [Component id = content]]
> at
> org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContain
> er
> .java:1739)
> at
> org.apache.wicket.Component.onBeforeRender(Component.java:3854)
> at
> org.apache.wicket.Component.internalBeforeRender(Component.java:1061)
> at
> org.apache.wicket.Component.beforeRender(Component.java:1095)
> at
> org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContain
> er
> .java:1727)
> at
> org.apache.wicket.Component.onBeforeRender(Component.java:3854)
> at org.apache.wicket.Page.onBeforeRender(Page.java:1501)
> at
> com.gdais.incidents.view.SiteTemplate.onBeforeRender(SiteTemplate.java
> :3
> 3)
> at
> org.apache.wicket.Component.internalBeforeRender(Component.java:1061)
> at
> org.apache.wicket.Component.beforeRender(Component.java:1095)
> at
> org.apache.wicket.Component.prepareForRender(Component.java:2223)
> at
> org.apache.wicket.Component.prepareForRender(Component.java:2260)
> at org.apache.wicket.Page.renderPage(Page.java:893)
> at
> org.apache.wicket.request.target.component.BookmarkablePageRequestTarg
> et
> .respond(BookmarkablePageRequestTarget.java:262)
> at
> org.apache.wicket.request.AbstractRequestCycleProcessor.respond(Abstra
> ct
> RequestCycleProcessor.java:105)
> at
> org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.ja
> va
> :1258)
> at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
> at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
> at
> org.apache.wicket.RequestCycle.request(RequestCycle.java:594)
> at
> org.apache.wicket.protocol.http.MockWebApplication.processRequestCycle
> (M
> ockWebApplication.java:478)
> at
> org.apache.wicket.protocol.http.MockWebApplication.processRequestCycle
> (M
> ockWebApplication.java:390)
> at
> org.apache.wicket.util.tester.BaseWicketTester.startPage(BaseWicketTes
> te
> r.java:301)
> at
> com.gdais.incidents.view.TestTriagePanel.assertTriageNotAvailableFor(T
> es
> tTriagePanel.java:33)
> at
> com.gdais.incidents.view.TestTriagePanel.testTriagePanelNotForAdminist
> ra
> tor(TestTriagePanel.java:27)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> av
> a:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> or
> Impl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at junit.framework.TestCase.runTest(TestCase.java:164)
> at junit.framework.TestCase.runBare(TestCase.java:130)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:120)
> at junit.framework.TestSuite.runTest(TestSuite.java:230)
> at junit.framework.TestSuite.run(TestSuite.java:225)
> at
> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(J
> Un
> it3TestReference.java:130)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.
> ja
> va:38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> Te
> stRunner.java:460)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remote
> Te
> stRunner.java:673)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestR
> un
> ner.java:386)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTest
> Ru
> nner.java:196)
> Caused by: org.hibernate.HibernateException: No Hibernate Session
> bound to thread, and configuration does not allow creation of
> non-transactional one here
> at
> org.springframework.orm.hibernate3.SpringSessionContext.currentSession
> (S
> pringSessionContext.java:63)
> at
> org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactory
> Im
> pl.java:622)
> at
> com.gdais.incidents.util.SessionFactoryAware.getCurrentSession(Session
> Fa
> ctoryAware.java:31)
> at
> com.gdais.incidents.util.SessionFactoryAware.findAll(SessionFactoryAwa
> re
> .java:61)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> av
> a:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> or
> Impl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflectio
> n(
> AopUtils.java:307)
> at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamic
> Ao
> pProxy.java:198)
> at $Proxy15.findAll(Unknown Source)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> av
> a:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> or
> Impl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyIni
> tP
> roxyFactory.java:416)
> at org.apache.wicket.proxy.$Proxy19.findAll(Unknown Source)
> at
> com.gdais.incidents.view.model.TriageListModel.load(TriageListModel.ja
> va
> :26)
> at
> com.gdais.incidents.view.model.TriageListModel.load(TriageListModel.ja
> va
> :1)
> at
> org.apache.wicket.model.LoadableDetachableModel.getObject(LoadableDeta
> ch
> ableModel.java:122)
> at
> org.apache.wicket.Component.getDefaultModelObject(Component.java:1655)
> at
> org.apache.wicket.markup.html.list.ListView.getViewSize(ListView.java:
> 22
> 1)
> at
> org.apache.wicket.markup.html.list.ListView.onPopulate(ListView.java:5
> 25
> )
> at
> org.apache.wicket.markup.repeater.AbstractRepeater.onBeforeRender(Abst
> ra
> ctRepeater.java:131)
> at
> org.apache.wicket.Component.internalBeforeRender(Component.java:1061)
> at
> org.apache.wicket.Component.beforeRender(Component.java:1095)
> at
> org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContain
> er
> .java:1727)
> ... 41 more
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]