• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling database exception in CMP

 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a stateless session bean acting as a facade for CMP entity bean. Our container is WebLogic 8.1 and our database is Oracle 9i. What happens is a remote client calls a method on the session bean, which starts a transaction. This method then calls a set method on the CMP using the same transaction. However, there is a unique constraint on this field in Oracle, so occasionally Oracle can object to the value that was set. This is formed into a SQLException, but it's not thrown by the CMP's setter, since it doesn't actually occur until the container stores the new value. In fact, it can't be caught by the session bean at all. When the transaction tries to commit, WebLogic wraps the SQLException in a Runtime "unexpected" exception and throws it back to the original client.

My question: is there any way we can catch this in the session bean so we can report the error more clearly back to the client? Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic