You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Loritsch, Berin C." <Be...@gd-ais.com> on 2009/11/17 22:00:20 UTC
Spring/Wicket/Hibernate testing driving me banana nuts
<<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(MarkupContainer
.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(MarkupContainer
.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.BookmarkablePageRequestTarget
.respond(BookmarkablePageRequestTarget.java:262)
at
org.apache.wicket.request.AbstractRequestCycleProcessor.respond(Abstract
RequestCycleProcessor.java:105)
at
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java
: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(BaseWicketTeste
r.java:301)
at
com.gdais.incidents.view.TestTriagePanel.assertTriageNotAvailableFor(Tes
tTriagePanel.java:33)
at
com.gdais.incidents.view.TestTriagePanel.testTriagePanelNotForAdministra
tor(TestTriagePanel.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
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(JUn
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(RemoteTe
stRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
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(SessionFactoryIm
pl.java:622)
at
com.gdais.incidents.util.SessionFactoryAware.getCurrentSession(SessionFa
ctoryAware.java:31)
at
com.gdais.incidents.util.SessionFactoryAware.findAll(SessionFactoryAware
.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(
AopUtils.java:307)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAo
pProxy.java:198)
at $Proxy15.findAll(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitP
roxyFactory.java:416)
at org.apache.wicket.proxy.$Proxy19.findAll(Unknown Source)
at
com.gdais.incidents.view.model.TriageListModel.load(TriageListModel.java
:26)
at
com.gdais.incidents.view.model.TriageListModel.load(TriageListModel.java
:1)
at
org.apache.wicket.model.LoadableDetachableModel.getObject(LoadableDetach
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:525
)
at
org.apache.wicket.markup.repeater.AbstractRepeater.onBeforeRender(Abstra
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(MarkupContainer
.java:1727)
... 41 more
Re: Spring/Wicket/Hibernate testing driving me banana nuts
Posted by Jeremy Thomerson <je...@wickettraining.com>.
Attachments don't come through these lists.
--
Jeremy Thomerson
http://www.wickettraining.com
On Tue, Nov 17, 2009 at 3:14 PM, Loritsch, Berin C. <
Berin.Loritsch@gd-ais.com> wrote:
> 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:igor.vaynberg@gmail.com]
> Sent: Tuesday, November 17, 2009 4:05 PM
> To: users@wicket.apache.org
> 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.
> <Be...@gd-ais.com> 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(MarkupContainer
> > .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(MarkupContainer
> > .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.BookmarkablePageRequestTarget
> > .respond(BookmarkablePageRequestTarget.java:262)
> > at
> > org.apache.wicket.request.AbstractRequestCycleProcessor.respond(Abstract
> > RequestCycleProcessor.java:105)
> > at
> > org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java
> > :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(BaseWicketTeste
> > r.java:301)
> > at
> > com.gdais.incidents.view.TestTriagePanel.assertTriageNotAvailableFor(Tes
> > tTriagePanel.java:33)
> > at
> > com.gdais.incidents.view.TestTriagePanel.testTriagePanelNotForAdministra
> > tor(TestTriagePanel.java:27)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> > a:39)
> > at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> > 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(JUn
> > 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(RemoteTe
> > stRunner.java:460)
> > at
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
> > stRunner.java:673)
> > at
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
> > ner.java:386)
> > at
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
> > 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(SessionFactoryIm
> > pl.java:622)
> > at
> > com.gdais.incidents.util.SessionFactoryAware.getCurrentSession(SessionFa
> > ctoryAware.java:31)
> > at
> > com.gdais.incidents.util.SessionFactoryAware.findAll(SessionFactoryAware
> > .java:61)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> > a:39)
> > at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> > Impl.java:25)
> > at java.lang.reflect.Method.invoke(Method.java:597)
> > at
> > org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(
> > AopUtils.java:307)
> > at
> > org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAo
> > pProxy.java:198)
> > at $Proxy15.findAll(Unknown Source)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> > a:39)
> > at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> > Impl.java:25)
> > at java.lang.reflect.Method.invoke(Method.java:597)
> > at
> > org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitP
> > roxyFactory.java:416)
> > at org.apache.wicket.proxy.$Proxy19.findAll(Unknown Source)
> > at
> > com.gdais.incidents.view.model.TriageListModel.load(TriageListModel.java
> > :26)
> > at
> > com.gdais.incidents.view.model.TriageListModel.load(TriageListModel.java
> > :1)
> > at
> > org.apache.wicket.model.LoadableDetachableModel.getObject(LoadableDetach
> > 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:525
> > )
> > at
> > org.apache.wicket.markup.repeater.AbstractRepeater.onBeforeRender(Abstra
> > 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(MarkupContainer
> > .java:1727)
> > ... 41 more
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
RE: Spring/Wicket/Hibernate testing driving me banana nuts
Posted by "Loritsch, Berin C." <Be...@gd-ais.com>.
OK. I've got it working again. The HibernateSession was set up in a hibernate Servlet filter. I found the minimum necessary lines to get the system working using my session factory configured in Spring. For the interested parties, here they are:
SessionFactory factory = (SessionFactory) getSpringContext().getBean("sessionFactory");
Session session = SessionFactoryUtils.getSession(factory, true);
session.setFlushMode(FlushMode.AUTO);
TransactionSynchronizationManager.bindResource(factory, new SessionHolder(session));
I have them set up just after I configured the Spring container.
Thank you for pointing me in the right direction.
-----Original Message-----
From: Eelco Hillenius [mailto:eelco.hillenius@gmail.com]
Sent: Tuesday, November 17, 2009 7:06 PM
To: users@wicket.apache.org
Subject: Re: Spring/Wicket/Hibernate testing driving me banana nuts
So in typical web applications, people would install a session filter
(like https://www.hibernate.org/43.html), which would open a session
at the start of a request, and close it afterwards. You probably need
to find an alternative for that filter in your test code.
Eelco
On Tue, Nov 17, 2009 at 4:26 PM, Loritsch, Berin C.
<Be...@gd-ais.com> wrote:
> 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:Berin.Loritsch@gd-ais.com]
> Sent: Tuesday, November 17, 2009 4:15 PM
> To: users@wicket.apache.org
> 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:igor.vaynberg@gmail.com]
> Sent: Tuesday, November 17, 2009 4:05 PM
> To: users@wicket.apache.org
> 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.
> <Be...@gd-ais.com> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Spring/Wicket/Hibernate testing driving me banana nuts
Posted by Eelco Hillenius <ee...@gmail.com>.
So in typical web applications, people would install a session filter
(like https://www.hibernate.org/43.html), which would open a session
at the start of a request, and close it afterwards. You probably need
to find an alternative for that filter in your test code.
Eelco
On Tue, Nov 17, 2009 at 4:26 PM, Loritsch, Berin C.
<Be...@gd-ais.com> wrote:
> 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:Berin.Loritsch@gd-ais.com]
> Sent: Tuesday, November 17, 2009 4:15 PM
> To: users@wicket.apache.org
> 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:igor.vaynberg@gmail.com]
> Sent: Tuesday, November 17, 2009 4:05 PM
> To: users@wicket.apache.org
> 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.
> <Be...@gd-ais.com> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
RE: Spring/Wicket/Hibernate testing driving me banana nuts
Posted by "Loritsch, Berin C." <Be...@gd-ais.com>.
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:Berin.Loritsch@gd-ais.com]
Sent: Tuesday, November 17, 2009 4:15 PM
To: users@wicket.apache.org
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:igor.vaynberg@gmail.com]
Sent: Tuesday, November 17, 2009 4:05 PM
To: users@wicket.apache.org
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.
<Be...@gd-ais.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
RE: Spring/Wicket/Hibernate testing driving me banana nuts
Posted by "Loritsch, Berin C." <Be...@gd-ais.com>.
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:igor.vaynberg@gmail.com]
Sent: Tuesday, November 17, 2009 4:05 PM
To: users@wicket.apache.org
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.
<Be...@gd-ais.com> 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(MarkupContainer
> .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(MarkupContainer
> .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.BookmarkablePageRequestTarget
> .respond(BookmarkablePageRequestTarget.java:262)
> � � � �at
> org.apache.wicket.request.AbstractRequestCycleProcessor.respond(Abstract
> RequestCycleProcessor.java:105)
> � � � �at
> org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java
> :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(BaseWicketTeste
> r.java:301)
> � � � �at
> com.gdais.incidents.view.TestTriagePanel.assertTriageNotAvailableFor(Tes
> tTriagePanel.java:33)
> � � � �at
> com.gdais.incidents.view.TestTriagePanel.testTriagePanelNotForAdministra
> tor(TestTriagePanel.java:27)
> � � � �at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> � � � �at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
> � � � �at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> 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(JUn
> 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(RemoteTe
> stRunner.java:460)
> � � � �at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
> stRunner.java:673)
> � � � �at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
> ner.java:386)
> � � � �at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
> 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(SessionFactoryIm
> pl.java:622)
> � � � �at
> com.gdais.incidents.util.SessionFactoryAware.getCurrentSession(SessionFa
> ctoryAware.java:31)
> � � � �at
> com.gdais.incidents.util.SessionFactoryAware.findAll(SessionFactoryAware
> .java:61)
> � � � �at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> � � � �at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
> � � � �at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
> � � � �at java.lang.reflect.Method.invoke(Method.java:597)
> � � � �at
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(
> AopUtils.java:307)
> � � � �at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAo
> pProxy.java:198)
> � � � �at $Proxy15.findAll(Unknown Source)
> � � � �at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> � � � �at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
> � � � �at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
> � � � �at java.lang.reflect.Method.invoke(Method.java:597)
> � � � �at
> org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitP
> roxyFactory.java:416)
> � � � �at org.apache.wicket.proxy.$Proxy19.findAll(Unknown Source)
> � � � �at
> com.gdais.incidents.view.model.TriageListModel.load(TriageListModel.java
> :26)
> � � � �at
> com.gdais.incidents.view.model.TriageListModel.load(TriageListModel.java
> :1)
> � � � �at
> org.apache.wicket.model.LoadableDetachableModel.getObject(LoadableDetach
> 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:525
> )
> � � � �at
> org.apache.wicket.markup.repeater.AbstractRepeater.onBeforeRender(Abstra
> 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(MarkupContainer
> .java:1727)
> � � � �... 41 more
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Spring/Wicket/Hibernate testing driving me banana nuts
Posted by Igor Vaynberg <ig...@gmail.com>.
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.
<Be...@gd-ais.com> 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(MarkupContainer
> .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(MarkupContainer
> .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.BookmarkablePageRequestTarget
> .respond(BookmarkablePageRequestTarget.java:262)
> at
> org.apache.wicket.request.AbstractRequestCycleProcessor.respond(Abstract
> RequestCycleProcessor.java:105)
> at
> org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java
> :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(BaseWicketTeste
> r.java:301)
> at
> com.gdais.incidents.view.TestTriagePanel.assertTriageNotAvailableFor(Tes
> tTriagePanel.java:33)
> at
> com.gdais.incidents.view.TestTriagePanel.testTriagePanelNotForAdministra
> tor(TestTriagePanel.java:27)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> 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(JUn
> 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(RemoteTe
> stRunner.java:460)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
> stRunner.java:673)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
> ner.java:386)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
> 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(SessionFactoryIm
> pl.java:622)
> at
> com.gdais.incidents.util.SessionFactoryAware.getCurrentSession(SessionFa
> ctoryAware.java:31)
> at
> com.gdais.incidents.util.SessionFactoryAware.findAll(SessionFactoryAware
> .java:61)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(
> AopUtils.java:307)
> at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAo
> pProxy.java:198)
> at $Proxy15.findAll(Unknown Source)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
> a:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
> Impl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitP
> roxyFactory.java:416)
> at org.apache.wicket.proxy.$Proxy19.findAll(Unknown Source)
> at
> com.gdais.incidents.view.model.TriageListModel.load(TriageListModel.java
> :26)
> at
> com.gdais.incidents.view.model.TriageListModel.load(TriageListModel.java
> :1)
> at
> org.apache.wicket.model.LoadableDetachableModel.getObject(LoadableDetach
> 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:525
> )
> at
> org.apache.wicket.markup.repeater.AbstractRepeater.onBeforeRender(Abstra
> 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(MarkupContainer
> .java:1727)
> ... 41 more
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org