You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mansour <ma...@yahoo.com> on 2007/05/19 17:36:51 UTC

Hibernate headache with struts 2

I am trying to use hibernate with my struts project. The problem I keep 
on getting :


javax.servlet.ServletException: org.hibernate.SessionException: Session is closed!
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:518)
	org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
	com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119)
	com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55)


This occurs when: session.commit(something);


Is this a struts 2 issue ? IF yes, then how to get s2 to work with 
hibernate. I have googled this, and every thing suggest using spring. 
This is not an option for me.

Can any one help ?


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate headache with struts 2

Posted by Martin Gainty <mg...@hotmail.com>.
Attempting to instantiate all of your Hibernate generated Parent and Child 
classes by continously running all of your sessions together..
so referencing
http://www.hibernate.org/43.html
You *could* write your own SessionRequestServletFilter which will accomplish 
this objective for you
(ensuring the saveOrUpdate and/or merge methods would accomplish your 
objective)
There is also mention of JBoss SEAM supports OSIV pattern (but I havent seen 
any working examples thus far)

Martin--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "Martin Gilday" <ma...@imap.cc>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Saturday, May 19, 2007 11:42 AM
Subject: Re: Hibernate headache with struts 2


> Looks like you are trying to access Hibernate managed objects or perform
> session manipultion in your view.  Spring makes this easier but you can
> do it manually easily. You just need to keep your session open longer.
> Have a google for things like open session in view filter.
>
>
> ----- Original message -----
> From: "Mansour" <ma...@yahoo.com>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Date: Sat, 19 May 2007 12:36:51 -0300
> Subject: Hibernate headache with struts 2
>
> I am trying to use hibernate with my struts project. The problem I keep
> on getting :
>
>
> javax.servlet.ServletException: org.hibernate.SessionException: Session
> is closed!
> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:518)
> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
> com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119)
> com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55)
>
>
> This occurs when: session.commit(something);
>
>
> Is this a struts 2 issue ? IF yes, then how to get s2 to work with
> hibernate. I have googled this, and every thing suggest using spring.
> This is not an option for me.
>
> Can any one help ?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hibernate headache with struts 2

Posted by Martin Gilday <ma...@imap.cc>.
Looks like you are trying to access Hibernate managed objects or perform
session manipultion in your view.  Spring makes this easier but you can
do it manually easily. You just need to keep your session open longer. 
Have a google for things like open session in view filter. 


----- Original message -----
From: "Mansour" <ma...@yahoo.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Date: Sat, 19 May 2007 12:36:51 -0300
Subject: Hibernate headache with struts 2

I am trying to use hibernate with my struts project. The problem I keep 
on getting :


javax.servlet.ServletException: org.hibernate.SessionException: Session
is closed!
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:518)
	org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
	com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119)
	com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55)


This occurs when: session.commit(something);


Is this a struts 2 issue ? IF yes, then how to get s2 to work with 
hibernate. I have googled this, and every thing suggest using spring. 
This is not an option for me.

Can any one help ?


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


[OT] Re: Hibernate headache with struts 2

Posted by Dave Newton <ne...@yahoo.com>.
--- Mansour <ma...@yahoo.com> wrote:
> Is this a struts 2 issue?

No. It's a very basic Hibernate issue.

http://www.hibernate.org/hib_docs/v3/reference/en/html/transactions.html

> every thing suggest using spring. This is not an 
> option for me.

Why not? Aren't you already using it or a similar
solution for doing dependency injection etc.?

d.



       
____________________________________________________________________________________Luggage? GPS? Comic books? 
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org