OMAException is an application exception correct?
(not a RuntimeExecpton, RemoteException or Error)

JBoss will still try to commit the transaction if you
throw an application exception.

The previous work done in the transaction has violated
a foreign key constraint, the commit fails.

If you don't want it to commit, you should
sessionContext.setRollbackOnly();
before throwing the application exception.

Regards,
Adrian

On Wed, 2003-10-29 at 12:52, Rafal Kedziorski wrote:
> hi,
> 
> I have follow problem.
> 
> My servlet is calling one stateless session bean and catch some exceptions:
> 
> // register user
> try {
>      RegisterFacadeBeanLocalHome registerFacadeHome = 
> (RegisterFacadeBeanLocalHome) 
> serviceLocator.getLocalHome(JNDINamesRegister.REGISTER_FACADE_SSLSB);
>      registerFacadeHome.create().registerUser(inetAddress, groupId, userVO, 
> user_dataVO, addressVO, AGB_VERSION, newsletter, newsletterType);
> 
>      // if all o.k. than create account
>      showSubmitAgreePage(response);
> }
> catch (ServiceLocatorException sle) {
>      logger.fatal("showFirstPage() failed", sle);
>      showErrorPage(response);
> }
> catch (CreateException ce) {
>      logger.fatal("showFirstPage() failed", ce);
>      showErrorPage(response);
> }
> catch (OMAException omae) {
>      logger.fatal("showFirstPage() failed", omae);
>      showErrorPage(response);
> }
> catch (ParameterException pe) {
>      logger.fatal("showFirstPage() failed", pe);
>      showErrorPage(response);
> }
> 
> In RegisterFacadeBean wthe will be called some other session beans in the 
> same transaction. For example there will be called addUser2Group in access 
> session bean.
> 
> In my session bean I have this method:
> 
>      public void addUser2Group(Long user_id, Integer group_id)
>               throws CreateException, OMAException {
>          if (logger.isDebugEnabled()) {
>              logger.debug("addUser2Group(" + user_id + "," + group_id + ") 
> entered");
>          }
> 
>          // check for the user
>          try {
>              userEntityHome.findByPrimaryKey(user_id);
>          }
>          catch (FinderException fe) {
>              logger.fatal("addUser2Group() failed, because user " + user_id 
> + " not found", fe);
>              throw new OMAException("AccessBean::addUser2Group() failed, 
> because user " + user_id + " not found", ErrorIDs.USER_NOT_FOUND_ERROR);
>          }
> 
>          // check for the group
>          try {
>              systemGroupHome.findByPrimaryKey(group_id);
>          }
>          catch (FinderException fe) {
>              logger.error("addUser2Group() failed, because group " + 
> group_id + " not found");
>              throw new OMAException("AccessBean::addUser2Group() failed, 
> because group " + group_id + " not found", ErrorIDs.GROUP_NOT_FOUND_ERROR);
>          }
> 
>          // add user to the group with valid from now
>          try {
>              User_2_System_GroupBeanLocalHome user_2_systemGroupHome = 
> (User_2_System_GroupBeanLocalHome) 
> serviceLocator.getLocalHome(JNDINamesUser.USER_2_SYSTEM_GROUP_EJB);
>              user_2_systemGroupHome.create(user_id, group_id, 
> SQLUtils.getInstance().getCurrentTimestamp(), null);
>          }
>          catch (ServiceLocatorException sle) {
>              logger.fatal("ejbCreate() failed with 
> ServiceLocatorException", sle);
>              throw new OMAException("Access::addUser2Group() service 
> locator failed");
>          }
>      }
> 
> But if userEntityHome.findByPrimaryKey(user_id) or 
> systemGroupHome.findByPrimaryKey(group_id) I didn't get in my Servlet 
> OMAException (this is checked exception).
> 
> Than I get:
> 
> HTTP ERROR: 500 null; CausedByException is: Unable to commit, 
> tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=prog-01//85, 
> BranchQual=] status=STATUS_NO_TRANSACTION; - nested throwable: 
> (javax.ejb.EJBException: Store failed; CausedByException is: General error, 
> message from server: "Cannot add or update a child row: a foreign key 
> constraint fails"); - nested throwable: 
> (org.jboss.tm.JBossRollbackException: Unable to commit, 
> tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=prog-01//85, 
> BranchQual=] status=STATUS_NO_TRANSACTION; - nested throwable: 
> (javax.ejb.EJBException: Store failed; CausedByException is: General error, 
> message from server: "Cannot add or update a child row: a foreign key 
> constraint fails"))
> 
> Where is the problem?
> 
> 
> Regards,
> Rafal
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive?  Does it
> help you create better code?   SHARE THE LOVE, and help us help
> YOU!  Click Here: http://sourceforge.net/donate/
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
-- 
xxxxxxxxxxxxxxxxxxxxxxxx 
Adrian Brock
Director of Support
Back Office
JBoss Group, LLC 
xxxxxxxxxxxxxxxxxxxxxxxx 



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to