No, The exception happens when the modal is displayed.

The problem can be solved using a DetachableModel.

***Maybe***...
When u do the ajax call to open the window, the createPage of the
modal is called, but not the render. After that, wicket calls the
modal url, and this time the render method will be called, (over a
detachached entity ,once it is a new request) throwing the exception..



On Fri, Oct 2, 2009 at 7:12 PM, Marcelo Fukushima <takesh...@gmail.com> wrote:
> weird... I'd expect that the CheckboxMultipleChoice would force the
> initialization of the list before the EntityManager is closed. Is the
> exception thrown on the form submission?
>
> On Fri, Oct 2, 2009 at 8:48 AM, Pedro Santos <pedros...@gmail.com> wrote:
>> use *OpenSessionInViewFilter* to avoid lazy initialization exceptions
>>
>> On Fri, Oct 2, 2009 at 8:42 AM, Albert Romanius <a.roman...@gmail.com>wrote:
>>
>>> The line that throws the exception is below:
>>> CheckBoxMultipleChoice subMessagesCB = new CheckBoxMultipleChoice(
>>>               "subMessages", new PropertyModel(this,
>>> "selectedSubs"), showMessage.getLazyList());
>>>
>>> The problem is the showMessage.getLazyList() call. When wicket renders
>>> this combobox, spring filter have already closed the EntityManager.
>>> If I uncomment this line (ugly hack):
>>>  //showMessage.getLazyList().size();
>>> Everything works.
>>>
>>> I am using tomcat 6.0.18 (bundled with Netbeans).
>>>
>>>
>>> The stacktrace:
>>>
>>> ERROR - azyInitializationException - failed to lazily initialize a
>>> collection of role: com.mycompany.persistence.domain.Message.lazyList,
>>> no session or session was closed
>>> org.hibernate.LazyInitializationException: failed to lazily initialize
>>> a collection of role:
>>> com.mycompany.persistence.domain.Message.lazyList, no session or
>>> session was closed
>>>        at
>>> org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
>>>        at
>>> org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
>>>        at
>>> org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97)
>>>        at
>>> org.hibernate.collection.PersistentBag.size(PersistentBag.java:225)
>>>        at
>>> org.apache.wicket.markup.html.form.ListMultipleChoice.onComponentTag(ListMultipleChoice.java:246)
>>>        at
>>> org.apache.wicket.markup.html.form.CheckBoxMultipleChoice.onComponentTag(CheckBoxMultipleChoice.java:359)
>>>        at org.apache.wicket.Component.renderComponent(Component.java:2597)
>>>        at
>>> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1536)
>>>        at org.apache.wicket.Component.render(Component.java:2457)
>>>        at
>>> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1414)
>>>        at
>>> org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1601)
>>>        at
>>> org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1525)
>>>        at
>>> org.apache.wicket.markup.html.form.Form.onComponentTagBody(Form.java:1926)
>>>        at org.apache.wicket.Component.renderComponent(Component.java:2626)
>>>        at
>>> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1536)
>>>        at org.apache.wicket.markup.html.form.Form.onRender(Form.java:1997)
>>>        at org.apache.wicket.Component.render(Component.java:2457)
>>>        at
>>> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1414)
>>>        at
>>> org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1552)
>>>        at org.apache.wicket.Page.onRender(Page.java:1545)
>>>        at org.apache.wicket.Component.render(Component.java:2457)
>>>        at org.apache.wicket.Page.renderPage(Page.java:914)
>>>        at
>>> org.apache.wicket.request.target.component.PageRequestTarget.respond(PageRequestTarget.java:63)
>>>        at
>>> org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.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:545)
>>>        at
>>> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456)
>>>        at
>>> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289)
>>>        at
>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>>>        at
>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>>        at
>>> org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:112)
>>>        at
>>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
>>>        at
>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>>>        at
>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>>        at
>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>>>        at
>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>>>        at
>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>>>        at
>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>>        at
>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>>>        at
>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
>>>        at
>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
>>>        at
>>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
>>>        at
>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>>>        at java.lang.Thread.run(Thread.java:619)
>>> ERROR - RequestCycle               - Exception in rendering component:
>>> [MarkupContainer [Component id = form]]
>>> org.apache.wicket.WicketRuntimeException: Exception in rendering
>>> component: [MarkupContainer [Component id = form]]
>>>        at org.apache.wicket.Component.renderComponent(Component.java:2665)
>>>        at
>>> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1536)
>>>        at org.apache.wicket.markup.html.form.Form.onRender(Form.java:1997)
>>>        at org.apache.wicket.Component.render(Component.java:2457)
>>>        at
>>> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1414)
>>>        at
>>> org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1552)
>>>        at org.apache.wicket.Page.onRender(Page.java:1545)
>>>        at org.apache.wicket.Component.render(Component.java:2457)
>>>        at org.apache.wicket.Page.renderPage(Page.java:914)
>>>        at
>>> org.apache.wicket.request.target.component.PageRequestTarget.respond(PageRequestTarget.java:63)
>>>        at
>>> org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.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:545)
>>>        at
>>> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456)
>>>        at
>>> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289)
>>>        at
>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>>>        at
>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>>        at
>>> org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:112)
>>>        at
>>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
>>>        at
>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>>>        at
>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>>        at
>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>>>        at
>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>>>        at
>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>>>        at
>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>>        at
>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>>>        at
>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
>>>        at
>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
>>>        at
>>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
>>>        at
>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>>>        at java.lang.Thread.run(Thread.java:619)
>>> Caused by: org.hibernate.LazyInitializationException: failed to lazily
>>> initialize a collection of role:
>>> com.mycompany.persistence.domain.Message.lazyList, no session or
>>> session was closed
>>>        at
>>> org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
>>>        at
>>> org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
>>>        at
>>> org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97)
>>>        at
>>> org.hibernate.collection.PersistentBag.size(PersistentBag.java:225)
>>>        at
>>> org.apache.wicket.markup.html.form.ListMultipleChoice.onComponentTag(ListMultipleChoice.java:246)
>>>        at
>>> org.apache.wicket.markup.html.form.CheckBoxMultipleChoice.onComponentTag(CheckBoxMultipleChoice.java:359)
>>>        at org.apache.wicket.Component.renderComponent(Component.java:2597)
>>>        at
>>> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1536)
>>>        at org.apache.wicket.Component.render(Component.java:2457)
>>>        at
>>> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1414)
>>>        at
>>> org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1601)
>>>        at
>>> org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1525)
>>>        at
>>> org.apache.wicket.markup.html.form.Form.onComponentTagBody(Form.java:1926)
>>>        at org.apache.wicket.Component.renderComponent(Component.java:2626)
>>>
>>>
>>>
>>>
>>>
>>> On Thu, Oct 1, 2009 at 10:39 PM, Marcelo Fukushima <takesh...@gmail.com>
>>> wrote:
>>> > while i couldnt identify which object is throwing the
>>> > lazyInitialization, the problem is probably that the entity is not
>>> > associated with the hibernate session. On the request that opens the
>>> > ModalWindow you must either reload or reatach the entity
>>> >
>>> > On Thu, Oct 1, 2009 at 7:55 PM, Albert Romanius <a.roman...@gmail.com>
>>> wrote:
>>> >> Hi,
>>> >>
>>> >> I am working with wicket and jpa/hibernate/spring. I am trying to
>>> >> create a ModalWindow, but I get a LazyLoadingException. I tryed the
>>> >> OSIVpattern, but it did not work.
>>> >> Using the modal inside a form does not make any difference also.
>>> >>
>>> >> Has anyone else this problem?
>>> >>
>>> >>
>>> >> The page which the modalWindow is triggered has:
>>> >> ===============
>>> >>  AjaxLink link = new AjaxLink("openModal") {
>>> >>                   �...@override
>>> >>                    public void onClick(AjaxRequestTarget target) {
>>> >>                        modalWindow.setPageCreator(new
>>> >> ModalWindow.PageCreator() {
>>> >>                            public Page createPage() {
>>> >>                                return new MyModalPage(modalWindow,
>>> >> messageListModel.getObject().get(0));
>>> >>                            }
>>> >>                        });
>>> >>                        modalWindow.show(target);
>>> >>                    }
>>> >>   };
>>> >> ==============
>>> >>
>>> >> #Modal Panel
>>> >> ==============
>>> >> public class MyModalPage extends WebPage {
>>> >>
>>> >>   �...@springbean
>>> >>    GeneralRepository generalRepository;
>>> >>
>>> >>    Set<SubMessage> selectedSubs = new HashSet<SubMessage>();
>>> >>
>>> >> public MyModalPage(final ModalWindow window, Message message) {
>>> >>
>>> >>        Message showMessage = (Message)
>>> >> generalRepository.<Message>getById(message.getId(), Message.class);
>>> >>
>>> >>        //showMessage.getLazyList().size();
>>> >>
>>> >>        Form f = new Form("form");
>>> >>        add(f);
>>> >>
>>> >>        CheckBoxMultipleChoice subMessagesCB = new
>>> CheckBoxMultipleChoice(
>>> >>                "subMessages", new PropertyModel(this,
>>> >> "selectedSubs"), showMessage.getLazyList());
>>> >>        f.add(subMessagesCB);
>>> >>
>>> >>        AjaxButton saveButton = new AjaxButton("save") {
>>> >>
>>> >>           �...@override
>>> >>            protected void onSubmit(AjaxRequestTarget target, Form<?>
>>> arg1) {
>>> >>                window.close(target);
>>> >>            }
>>> >>        };
>>> >>
>>> >>        f.add(saveButton);
>>> >>
>>> >>        add(new AjaxLink("closeCancel")
>>> >>        {
>>> >>           �...@override
>>> >>            public void onClick(AjaxRequestTarget target)
>>> >>            {
>>> >>                window.close(target);
>>> >>            }
>>> >>        });
>>> >>
>>> >>
>>> >>    }
>>> >> ==========
>>> >>
>>> >>
>>> >> --
>>> >> Albert
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> >> For additional commands, e-mail: users-h...@wicket.apache.org
>>> >>
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > http://mapsdev.blogspot.com/
>>> > Marcelo Takeshi Fukushima
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> > For additional commands, e-mail: users-h...@wicket.apache.org
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> Albert
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>>
>>
>>
>> --
>> Pedro Henrique Oliveira dos Santos
>>
>
>
>
> --
> http://mapsdev.blogspot.com/
> Marcelo Takeshi Fukushima
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>



-- 
Albert

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to