You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Martin Gainty <mg...@hotmail.com> on 2009/02/01 02:24:40 UTC

RE: interceptor redirection problem

the problem is you are relying on your own ServletFilter

this is possibly a configuration problem
please display hibernate.xml,hibernate.properties

Fairly comprehensive example of configuring hibernate with struts is located at
http://www.hibernate.org/105.html

Martin 
______________________________________________ 
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. 




> Date: Sat, 31 Jan 2009 04:30:44 -0800
> From: rouxelec@yahoo.com
> Subject: interceptor redirection problem
> To: user@struts.apache.org
> 
> Hi,
> 
> here's my code.
> I want to show an error message if it's impossible to commit. But it seems my action still display the 'success' result.
> 
> can anybody help me?
> 
> 
> 
>      public String intercept(ActionInvocation invocation) throws Exception {
>         String retour = Action.ERROR;
>         try {
>             sf.getCurrentSession().beginTransaction();
>             retour = invocation.invoke();            
>             sf.getCurrentSession().getTransaction().commit();
>         } catch(Exception e) {
>             try{
>                 Transaction tx = sf.getCurrentSession().getTransaction();
>                 if(tx != null && tx.isActive()) {
>                     tx.rollback();
>                 }
>             }catch (Exception e1) {
>                 e1.printStackTrace();
>             }
>             retour = Action.ERROR;    
>         }
>         return retour;
>     }
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 

_________________________________________________________________
Windows Live™ Hotmail®:…more than just e-mail. 
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t2_hm_justgotbetter_explore_012009

Re: interceptor redirection problem

Posted by Dave Newton <ne...@yahoo.com>.
Martin Gainty wrote:
> the problem is you are relying on your own ServletFilter

It's a Struts 2 interceptor.

> this is possibly a configuration problem
> please display hibernate.xml,hibernate.properties

The issue is with the interceptor and not knowing that the result is 
executed within the invocation.invoke() method, thus the result is 
rendered before the interceptor can return the ERROR result.

> Fairly comprehensive example of configuring hibernate with struts is located at
> http://www.hibernate.org/105.html

That's Struts 1; OP is using Struts 2, and writing, in essence, a Struts 
2 version of OpenSessionInView.

(Whether or not that's a good pattern is, of course, debatable :)

Dave


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