You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Florian B." <fl...@gmail.com> on 2011/08/21 11:26:03 UTC

StaleObjectStateException got intercepted

Hi 

I'm trying to add exception handling to one of my pages but I'm a little bit
stuck. 

I've got a page that loads an entity using a DAO (Hibernate, Spring). In
case of an error due to optimistic locking I want to reload the page with
the updated entity and display a message on a feedback panel. 

The onSubmit() method of my button looks like that: 

@Override 
public void onSubmit() { 
    // save store to DB 
    try { 
            storeDao.saveOrUpdate(store); 
            setResponsePage(StoreTablePage.class);	
    } catch (StaleObjectStateException ex) { 
             store = storeDao.retrieve(store.getId()); 
             error(new
StringResourceModel("form.error.optimisticLockingException", this,
null).toString()); 
    } 
} 

What is weird is that when I write "catch (StaleObjectStateException ex)"
then the exception is somehow intercepted and the catch section is never
reached, instead a stack trace of the exception is shown. When I change it
to "catch (Exception ex)" then it works as expected. At the moment I'm
running the Wicket application in development mode. 

Am I missing some important concept about exceptions in Wicket? 

Bye, 
Florian 


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/StaleObjectStateException-got-intercepted-tp3758154p3758154.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: StaleObjectStateException got intercepted

Posted by "Florian B." <fl...@gmail.com>.
Checking the type of exception during run time show that the Hibernate
StaleObjectStateException was wrapped by a
HibernateOptimisticLockingFailureException of the Spring framework. 

So catching the latter one worked as expected. 

Thanks for pushing me in the right direction! 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/StaleObjectStateException-got-intercepted-tp3758154p3759537.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: StaleObjectStateException got intercepted

Posted by hu...@butterbrot.org.
Sounds like there is some other exception thrown that is caught somewhere 
upwards your callstack. You could try to catch Exception and in your catch 
block log the actual Exception class to see what you actually caught.

On Sun, 21 Aug 2011, Florian B. wrote:

> Hi
>
> I'm trying to add exception handling to one of my pages but I'm a little bit
> stuck.
>
> I've got a page that loads an entity using a DAO (Hibernate, Spring). In
> case of an error due to optimistic locking I want to reload the page with
> the updated entity and display a message on a feedback panel.
>
> The onSubmit() method of my button looks like that:
>
> @Override
> public void onSubmit() {
>    // save store to DB
>    try {
>            storeDao.saveOrUpdate(store);
>            setResponsePage(StoreTablePage.class);
>    } catch (StaleObjectStateException ex) {
>             store = storeDao.retrieve(store.getId());
>             error(new
> StringResourceModel("form.error.optimisticLockingException", this,
> null).toString());
>    }
> }
>
> What is weird is that when I write "catch (StaleObjectStateException ex)"
> then the exception is somehow intercepted and the catch section is never
> reached, instead a stack trace of the exception is shown. When I change it
> to "catch (Exception ex)" then it works as expected. At the moment I'm
> running the Wicket application in development mode.
>
> Am I missing some important concept about exceptions in Wicket?
>
> Bye,
> Florian
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/StaleObjectStateException-got-intercepted-tp3758154p3758154.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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