Re: Lazy load exception wicket and hibernate
On Sat, Mar 29, 2008 at 8:04 PM, James Carman [EMAIL PROTECTED] wrote: So, I think you just have it backwards. The OpenEntityManagerInViewFilter should be mapped before the WicketFilter. i dont know if my english is broken or what, but i believe that is exactly what ive been saying all along... -igor - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
Sorry, my bad. I made a typo earlier what may have caused the confusion: On Sat, Mar 29, 2008 at 7:15 AM, lars vonk [EMAIL PROTECTED] wrote: IIRC you should put the OpenEntityManagerInViewFilter definition in the filter-mapping after the WicketFilter otherwise the WicketFilter will come first. I of course meant *before the WicketFilter*, because like I stated later on in the mail that it's the definition of the *filter-mapping* element that depicts the order of execution. So we are all on the same page here :-). Lars On Sun, Mar 30, 2008 at 8:17 AM, Igor Vaynberg [EMAIL PROTECTED] wrote: On Sat, Mar 29, 2008 at 8:04 PM, James Carman [EMAIL PROTECTED] wrote: So, I think you just have it backwards. The OpenEntityManagerInViewFilter should be mapped before the WicketFilter. i dont know if my english is broken or what, but i believe that is exactly what ive been saying all along... -igor - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
On Sun, Mar 30, 2008 at 6:01 AM, lars vonk [EMAIL PROTECTED] wrote: IIRC you should put the OpenEntityManagerInViewFilter definition in the filter-mapping after the WicketFilter otherwise the WicketFilter will come first. I of course meant *before the WicketFilter*, because like I stated later on in the mail that it's the definition of the *filter-mapping* element that depicts the order of execution. So we are all on the same page here :-). Yes, that's what I was originally questioning. I figured it was a typo, but I wanted to make sure, because I always thought it was the other way around. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
What is the order of the filters you defined in your filter-mapping element in the web.xml. IIRC you should put the OpenEntityManagerInViewFilter definition in the filter-mapping after the WicketFilter otherwise the WicketFilter will come first. Lars On Fri, Mar 28, 2008 at 9:11 PM, cjlyth [EMAIL PROTECTED] wrote: I have been getting the same error. I feel like im missing something. Maybe I am doing something horibly wrong but I haven't been able to figure out what it is. I am using spring 2.5, Wicket 1.3.2, and I have put the OpenEntityManagerInViewFilter in my web xml. The filter is loading ok, im not sure what to do next... If anyone can help please let me know what you need to see. I even have an example application i can upload. I am using a DataView, I have tried to inject the spring beans into every part (data provider, etc) and I always get the same result... For now I will include the wicket stuff: public class Home extends WebPage { @SpringBean private TestService testService; public Home() { init(); } public Home(PageParameters parameters) { super(parameters); init(); } private void init() { add(new DataView(container, new ListOwnerProvider()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(Item item) { /*ListOwner owner = (ListOwner)item.getModelObject();*/ item.add(new Label(name)); item.add(new ListView(entries){ private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem item) { item.add(new Label(value)); } }); } }); } class ListOwnerProvider implements IDataProvider { private static final long serialVersionUID = 1L; @Override public void detach() { } @Override public Iterator iterator(int first, int count) { return testService.getListOwners (first,count).iterator(); } @Override public IModel model(Object object) { return new CompoundPropertyModel(new ListOwnerModel((ListOwner)object)); } @Override public int size() { return testService.getListOwners().size(); } } class ListOwnerModel extends LoadableDetachableModel { private static final long serialVersionUID = 1L; private Integer id; public ListOwnerModel(ListOwner listOwner) { this.id = listOwner.getId(); } @Override protected Object load() { return testService.getListOwner(id); } } } Mathias P.W Nilsson wrote: I'm using wicket with hibernate and spring. In my web.xml I have OpenEntityManagerInViewFilter. But when trying to add a dataview to my wicket page I get the org.hibernate.LazyInitializationException -- View this message in context: http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p16361116.html Sent from the Wicket - User mailing list archive at Nabble.com.
Re: Lazy load exception wicket and hibernate
erm, i thought filters were executed in the order they were defined in web.xml. so open..inview should be declared before wicket. and its not the filter-mapping but the filter element... -igor On Sat, Mar 29, 2008 at 4:15 AM, lars vonk [EMAIL PROTECTED] wrote: What is the order of the filters you defined in your filter-mapping element in the web.xml. IIRC you should put the OpenEntityManagerInViewFilter definition in the filter-mapping after the WicketFilter otherwise the WicketFilter will come first. Lars On Fri, Mar 28, 2008 at 9:11 PM, cjlyth [EMAIL PROTECTED] wrote: I have been getting the same error. I feel like im missing something. Maybe I am doing something horibly wrong but I haven't been able to figure out what it is. I am using spring 2.5, Wicket 1.3.2, and I have put the OpenEntityManagerInViewFilter in my web xml. The filter is loading ok, im not sure what to do next... If anyone can help please let me know what you need to see. I even have an example application i can upload. I am using a DataView, I have tried to inject the spring beans into every part (data provider, etc) and I always get the same result... For now I will include the wicket stuff: public class Home extends WebPage { @SpringBean private TestService testService; public Home() { init(); } public Home(PageParameters parameters) { super(parameters); init(); } private void init() { add(new DataView(container, new ListOwnerProvider()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(Item item) { /*ListOwner owner = (ListOwner)item.getModelObject();*/ item.add(new Label(name)); item.add(new ListView(entries){ private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem item) { item.add(new Label(value)); } }); } }); } class ListOwnerProvider implements IDataProvider { private static final long serialVersionUID = 1L; @Override public void detach() { } @Override public Iterator iterator(int first, int count) { return testService.getListOwners (first,count).iterator(); } @Override public IModel model(Object object) { return new CompoundPropertyModel(new ListOwnerModel((ListOwner)object)); } @Override public int size() { return testService.getListOwners().size(); } } class ListOwnerModel extends LoadableDetachableModel { private static final long serialVersionUID = 1L; private Integer id; public ListOwnerModel(ListOwner listOwner) { this.id = listOwner.getId(); } @Override protected Object load() { return testService.getListOwner(id); } } } Mathias P.W Nilsson wrote: I'm using wicket with hibernate and spring. In my web.xml I have OpenEntityManagerInViewFilter. But when trying to add a dataview to my wicket page I get the org.hibernate.LazyInitializationException -- View this message in context: http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p16361116.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
They are initialized in the order they are defined, but executed in the order of filter-mapping: Quote from servlet spec 2.4: The order the container uses in building the chain of filters to be applied for a particular request URI is as follows: 1. First, the url-pattern matching filter mappings in the same order that these elements appear in the deployment descriptor. I tested (in jetty) this to be sure and it's correct. So it's the filter-mapping, not the filter definition. Lars On Sat, Mar 29, 2008 at 5:48 PM, Igor Vaynberg [EMAIL PROTECTED] wrote: erm, i thought filters were executed in the order they were defined in web.xml. so open..inview should be declared before wicket. and its not the filter-mapping but the filter element... -igor On Sat, Mar 29, 2008 at 4:15 AM, lars vonk [EMAIL PROTECTED] wrote: What is the order of the filters you defined in your filter-mapping element in the web.xml. IIRC you should put the OpenEntityManagerInViewFilter definition in the filter-mapping after the WicketFilter otherwise the WicketFilter will come first. Lars On Fri, Mar 28, 2008 at 9:11 PM, cjlyth [EMAIL PROTECTED] wrote: I have been getting the same error. I feel like im missing something. Maybe I am doing something horibly wrong but I haven't been able to figure out what it is. I am using spring 2.5, Wicket 1.3.2, and I have put the OpenEntityManagerInViewFilter in my web xml. The filter is loading ok, im not sure what to do next... If anyone can help please let me know what you need to see. I even have an example application i can upload. I am using a DataView, I have tried to inject the spring beans into every part (data provider, etc) and I always get the same result... For now I will include the wicket stuff: public class Home extends WebPage { @SpringBean private TestService testService; public Home() { init(); } public Home(PageParameters parameters) { super(parameters); init(); } private void init() { add(new DataView(container, new ListOwnerProvider()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(Item item) { /*ListOwner owner = (ListOwner)item.getModelObject();*/ item.add(new Label(name)); item.add(new ListView(entries){ private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem item) { item.add(new Label(value)); } }); } }); } class ListOwnerProvider implements IDataProvider { private static final long serialVersionUID = 1L; @Override public void detach() { } @Override public Iterator iterator(int first, int count) { return testService.getListOwners (first,count).iterator(); } @Override public IModel model(Object object) { return new CompoundPropertyModel(new ListOwnerModel((ListOwner)object)); } @Override public int size() { return testService.getListOwners().size(); } } class ListOwnerModel extends LoadableDetachableModel { private static final long serialVersionUID = 1L; private Integer id; public ListOwnerModel(ListOwner listOwner) { this.id = listOwner.getId(); } @Override protected Object load() { return testService.getListOwner(id); } } } Mathias P.W Nilsson wrote: I'm using wicket with hibernate and spring. In my web.xml I have OpenEntityManagerInViewFilter. But when trying to add a dataview to my wicket page I get the org.hibernate.LazyInitializationException -- View this message in context: http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p16361116.html Sent from the Wicket - User mailing list archive at
Re: Lazy load exception wicket and hibernate
thanks. i always thought it was the other way, probably because i googled it at the time instead of reading the spec. if you google web.xml filter order the first hit you get is http://www.onjava.com/pub/a/onjava/2001/05/10/servlet_filters.html?page=3 which states that it is the order they are defined... -igor On Sat, Mar 29, 2008 at 12:24 PM, lars vonk [EMAIL PROTECTED] wrote: They are initialized in the order they are defined, but executed in the order of filter-mapping: Quote from servlet spec 2.4: The order the container uses in building the chain of filters to be applied for a particular request URI is as follows: 1. First, the url-pattern matching filter mappings in the same order that these elements appear in the deployment descriptor. I tested (in jetty) this to be sure and it's correct. So it's the filter-mapping, not the filter definition. Lars On Sat, Mar 29, 2008 at 5:48 PM, Igor Vaynberg [EMAIL PROTECTED] wrote: erm, i thought filters were executed in the order they were defined in web.xml. so open..inview should be declared before wicket. and its not the filter-mapping but the filter element... -igor On Sat, Mar 29, 2008 at 4:15 AM, lars vonk [EMAIL PROTECTED] wrote: What is the order of the filters you defined in your filter-mapping element in the web.xml. IIRC you should put the OpenEntityManagerInViewFilter definition in the filter-mapping after the WicketFilter otherwise the WicketFilter will come first. Lars On Fri, Mar 28, 2008 at 9:11 PM, cjlyth [EMAIL PROTECTED] wrote: I have been getting the same error. I feel like im missing something. Maybe I am doing something horibly wrong but I haven't been able to figure out what it is. I am using spring 2.5, Wicket 1.3.2, and I have put the OpenEntityManagerInViewFilter in my web xml. The filter is loading ok, im not sure what to do next... If anyone can help please let me know what you need to see. I even have an example application i can upload. I am using a DataView, I have tried to inject the spring beans into every part (data provider, etc) and I always get the same result... For now I will include the wicket stuff: public class Home extends WebPage { @SpringBean private TestService testService; public Home() { init(); } public Home(PageParameters parameters) { super(parameters); init(); } private void init() { add(new DataView(container, new ListOwnerProvider()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(Item item) { /*ListOwner owner = (ListOwner)item.getModelObject();*/ item.add(new Label(name)); item.add(new ListView(entries){ private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem item) { item.add(new Label(value)); } }); } }); } class ListOwnerProvider implements IDataProvider { private static final long serialVersionUID = 1L; @Override public void detach() { } @Override public Iterator iterator(int first, int count) { return testService.getListOwners (first,count).iterator(); } @Override public IModel model(Object object) { return new CompoundPropertyModel(new ListOwnerModel((ListOwner)object)); } @Override public int size() { return testService.getListOwners().size(); } } class ListOwnerModel extends LoadableDetachableModel { private static final long serialVersionUID = 1L; private Integer id; public ListOwnerModel(ListOwner listOwner) { this.id = listOwner.getId(); }
Re: Lazy load exception wicket and hibernate
On Sat, Mar 29, 2008 at 7:15 AM, lars vonk [EMAIL PROTECTED] wrote: What is the order of the filters you defined in your filter-mapping element in the web.xml. IIRC you should put the OpenEntityManagerInViewFilter definition in the filter-mapping after the WicketFilter otherwise the WicketFilter will come first. I don't understand what you mean here. Are you saying that if I do this: filter-mapping filter-nameoemiv/filter-name url-pattern/*/url-pattern /filter-mapping filter-mapping filter-namewicket/filter-name url-pattern/*/url-pattern /filter-mapping then the WicketFilter will execute first and the oemiv filter won't ever execute? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
it will execute _after_ the wicket filter. which is no good because you need lazy loading to work inside wicket filter, so you need oemiv to execute before. and possibly, if wicket filter never calls chain.dofilter it will never execute. -igor On Sat, Mar 29, 2008 at 7:02 PM, James Carman [EMAIL PROTECTED] wrote: On Sat, Mar 29, 2008 at 7:15 AM, lars vonk [EMAIL PROTECTED] wrote: What is the order of the filters you defined in your filter-mapping element in the web.xml. IIRC you should put the OpenEntityManagerInViewFilter definition in the filter-mapping after the WicketFilter otherwise the WicketFilter will come first. I don't understand what you mean here. Are you saying that if I do this: filter-mapping filter-nameoemiv/filter-name url-pattern/*/url-pattern /filter-mapping filter-mapping filter-namewicket/filter-name url-pattern/*/url-pattern /filter-mapping then the WicketFilter will execute first and the oemiv filter won't ever execute? - 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]
Re: Lazy load exception wicket and hibernate
On Sat, Mar 29, 2008 at 10:14 PM, Igor Vaynberg [EMAIL PROTECTED] wrote: it will execute _after_ the wicket filter. which is no good because you need lazy loading to work inside wicket filter, so you need oemiv to execute before. and possibly, if wicket filter never calls chain.dofilter it will never execute. I mean, are you sure it will execute after? I just did a simple test: public class Filter1 implements Filter { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { System.out.println(Entering Filter1...); filterChain.doFilter(servletRequest, servletResponse); System.out.println(Exiting Filter1...); } } public class Filter2 implements Filter { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { System.out.println(Entering Filter2...); filterChain.doFilter(servletRequest, servletResponse); System.out.println(Exiting Filter2...); } } filter filter-namefilter1/filter-name filter-classcom.mycompany.Filter1/filter-class /filter filter filter-namefilter2/filter-name filter-classcom.mycompany.Filter2/filter-class /filter filter-mapping filter-namefilter1/filter-name url-pattern/*/url-pattern /filter-mapping filter-mapping filter-namefilter2/filter-name url-pattern/*/url-pattern /filter-mapping filter-mapping filter-namewicket.myproject/filter-name url-pattern/*/url-pattern /filter-mapping When I access my HomePage, it prints out: Entering Filter1... Entering Filter2... Exiting Filter2... Exiting Filter1... So, I think you just have it backwards. The OpenEntityManagerInViewFilter should be mapped before the WicketFilter. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
I have been getting the same error. I feel like im missing something. Maybe I am doing something horibly wrong but I haven't been able to figure out what it is. I am using spring 2.5, Wicket 1.3.2, and I have put the OpenEntityManagerInViewFilter in my web xml. The filter is loading ok, im not sure what to do next... If anyone can help please let me know what you need to see. I even have an example application i can upload. I am using a DataView, I have tried to inject the spring beans into every part (data provider, etc) and I always get the same result... For now I will include the wicket stuff: public class Home extends WebPage { @SpringBean private TestService testService; public Home() { init(); } public Home(PageParameters parameters) { super(parameters); init(); } private void init() { add(new DataView(container, new ListOwnerProvider()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(Item item) { /*ListOwner owner = (ListOwner)item.getModelObject();*/ item.add(new Label(name)); item.add(new ListView(entries){ private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem item) { item.add(new Label(value)); } }); } }); } class ListOwnerProvider implements IDataProvider { private static final long serialVersionUID = 1L; @Override public void detach() { } @Override public Iterator iterator(int first, int count) { return testService.getListOwners(first,count).iterator(); } @Override public IModel model(Object object) { return new CompoundPropertyModel(new ListOwnerModel((ListOwner)object)); } @Override public int size() { return testService.getListOwners().size(); } } class ListOwnerModel extends LoadableDetachableModel { private static final long serialVersionUID = 1L; private Integer id; public ListOwnerModel(ListOwner listOwner) { this.id = listOwner.getId(); } @Override protected Object load() { return testService.getListOwner(id); } } } Mathias P.W Nilsson wrote: I'm using wicket with hibernate and spring. In my web.xml I have OpenEntityManagerInViewFilter. But when trying to add a dataview to my wicket page I get the org.hibernate.LazyInitializationException -- View this message in context: http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p16361116.html Sent from the Wicket - User mailing list archive at Nabble.com.
Re: Lazy load exception wicket and hibernate
On 3/11/08, Mathias P.W Nilsson [EMAIL PROTECTED] wrote: Hi! I'm using wicket with hibernate and spring. In my web.xml I have OpenEntityManagerInViewFilter. But when trying to add a dataview to my wicket page I get the org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed. Anyone? Are you using a detachable model or is the entity being stored with the page (serialized)? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
Not exactly sure what you mean here since this is my first time trying wicket and hibernate, spring. I have spring annoted daos that I use ex. myDao().getList(); returns a list that has lazy object references. When I try to evoke a method on the lazy object I get the exception. I have solved i right now with DTO but it seam total meaningless to have dto when all my entities can be used in the wicket page. -- View this message in context: http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p15988359.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy load exception wicket and hibernate
Show us some code, please. How are you setting things up? On 3/11/08, Mathias P.W Nilsson [EMAIL PROTECTED] wrote: Not exactly sure what you mean here since this is my first time trying wicket and hibernate, spring. I have spring annoted daos that I use myDao().getList(); returns a list that has lazy object references. When I try to evoke a method on the lazy object i get the exception. I have solved i right now with DTO but it seam total meaningless to have dto when all my entities can be used in the wicket page. -- View this message in context: http://www.nabble.com/Lazy-load-exception-wicket-and-hibernate-tp15976668p15988359.html Sent from the Wicket - User mailing list archive at Nabble.com. - 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]