Getting or displaying the JPA commit exception

174 views
Skip to first unread message

will

unread,
Dec 16, 2010, 9:01:18 PM12/16/10
to play-framework
Help! I cannot seem to catch the JPA commit exception and handle them
accordingly. I'm using Play 1.0.3.2 and using JPA entity directly
(not extending Model). Using JPA.em().persist(myEntity) to save to
JPA. When there's an exception during commit, the browser simply
displays "Oops, an error occured," while the log has the detail
exception trace. I would like to display more helpful error message,
like the exceptions' text, on the browser.

From the stacktrace in the log, it looks like JPA transaction is
committed by JPAPlugin.closeTx() in the
JPAPlugin.afterActionInvocation(), which is after my Controller action
handler has been called. Is there a way to intercept the JPA commit
exception and handle it? Thanks!

P.S. I'm getting this kind of exceptions in the log and I would like
to catch them and display "ORA-12899: value too large for column
"PTCTEST1"."SUBDIVISION"."VERSION" (actual: 38, maximum: 20)" on the
browser.

17:11:28,886 ERROR ~ Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC
batch update
at
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:
126)
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:
114)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:
66)
at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:
275)
at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:
312)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:
50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at
org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
at
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:
137)
at
org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
at play.db.jpa.JPAPlugin.closeTx(JPAPlugin.java:306)
at play.db.jpa.JPAPlugin.afterActionInvocation(JPAPlugin.java:
256)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:251)
at play.server.HttpHandler
$MinaInvocation.execute(HttpHandler.java:500)

Caused by: java.sql.BatchUpdateException: ORA-12899: value too large
for column "PTCTEST1"."SUBDIVISION"."VERSION" (actual: 38, maximum:
20)

Guillaume Bort

unread,
Dec 17, 2010, 10:00:04 AM12/17/10
to play-fr...@googlegroups.com
Edit the errors/500.html page.

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com

William Wong

unread,
Dec 17, 2010, 11:02:03 AM12/17/10
to play-fr...@googlegroups.com
Thanks!  I've searched all over the places but couldn't find any info on error/exception handling in the Play Framework.  It would be really helpful to add a section in the Controller documentation to talk about the error flow control via the normal render() flow control back to the browser.

Thanks again for the quick response!

William


On Fri, Dec 17, 2010 at 7:00 AM, Guillaume Bort <guillau...@gmail.com> wrote:
Edit the errors/500.html page.

On Fri, Dec 17, 2010 at 3:01 AM, will <willi...@gmail.com> wrote:
> Help!  I cannot seem to catch the JPA commit exception and handle them
> accordingly.  I'm using Play 1.0.3.2 and using JPA entity directly
> (not extending Model).  Using JPA.em().persist(myEntity) to save to
> JPA.  When there's an exception during commit, the browser simply
> displays "Oops, an error occured," while the log has the detail
> exception trace.  I would like to display more helpful error message,
> like the exceptions' text, on the browser.
>
> From the stacktrace in the log, it looks like JPA transaction is
> committed by JPAPlugin.closeTx() in thef
Reply all
Reply to author
Forward
0 new messages