Package com.atomikos.icatch

Examples of com.atomikos.icatch.SysException


            exported_ = false;
        } else {
            name_ = tmUniqueName + "UserTransactionServer";
            providerUrl_ = properties.getProperty ( Context.PROVIDER_URL );
            if ( providerUrl_ == null ) {
                throw new SysException ( "Startup property "
                        + Context.PROVIDER_URL
                        + " must be set for client demarcation." );
            }
            initialContextFactory_ = properties
                    .getProperty ( Context.INITIAL_CONTEXT_FACTORY );
            if ( initialContextFactory_ == null ) {
                throw new SysException ( "Startup property "
                        + Context.INITIAL_CONTEXT_FACTORY
                        + " must be set for client demarcation." );
            }
            properties_ = properties;

            tm_ = (TransactionManagerImp) TransactionManagerImp
                    .getTransactionManager ();
            if ( tm_ == null )
                throw new SysException ( "No TM found" );

            try {

                if ( "PortableRemoteObject".equals ( exportClass ) ) {
                    PortableRemoteObject.exportObject ( this );
                    exported_ = true;
                } else if ( "UnicastRemoteObject".equals ( exportClass ) ) {
                    UnicastRemoteObject.exportObject ( this );
                    exported_ = true;
                }

            } catch ( Exception e ) {

                throw new SysException (
                        "Error exporting - naming service not running?", e );
            }

            try {

                Context ctx = getInitialContext ();
                ctx.rebind ( name_, this );
            } catch ( Exception e ) {

                throw new SysException (
                        "Please make sure the rmiregistry is running!?", e );
            }

        }
View Full Code Here


                    UnicastRemoteObject.unexportObject ( this, true );

                Context ctx = getInitialContext ();
                ctx.unbind ( name_ );
            } catch ( Exception e ) {
                throw new SysException ( e.getMessage (), e );
            }
            // set exported to false, to make sure this method is
            // idempotent
            exported_ = false;
        }
View Full Code Here

                                    + xares + " and " + xaresource );
                }
            } catch ( XAException xe ) {
                Stack errors = new Stack ();
                errors.push ( xe );
                throw new SysException ( "Error in XAResource comparison: "
                        + xe.getMessage (), errors );
            }
        }
        return ret;
    }
View Full Code Here

            if ( Configuration.isInfoLoggingEnabled() ) Configuration.logInfo ( "Bridge: error during message processing", e );
            if ( Configuration.isInfoLoggingEnabled() ) Configuration.logInfo ( "Bridge: linked exception is " + e.getLinkedException() );
            Stack errors = new Stack ();
            errors.push ( e );
            // throw runtime to rollback
            throw new SysException ( "Error during message processing", errors );
        }
    }
View Full Code Here

        if ( delegate_ != null ) return;

        String factoryClassName = getOrFindProperty ( "com.atomikos.icatch.service" );

        if ( factoryClassName == null )
            throw new SysException (
            "UserTransactionServiceImp: property not defined: com.atomikos.icatch.service" );

        try {
            Class factoryClass = ClassLoadingHelper.loadClass ( factoryClassName );
            UserTransactionServiceFactory factory =
                    ( UserTransactionServiceFactory ) factoryClass.newInstance ();
            delegate_ = factory.getUserTransactionService ( properties_ );
            //This should initialize the properties with whatever is specified and
            //use SYSTEM_DEPENDENT DEFAULT values for others
        }
        catch ( Exception e ) {
            Stack errors = new Stack ();
            errors.push ( e );
            throw new SysException ( "Error in init of UserTransactionServiceImp: " + e.getMessage() , errors );
        }

    }
View Full Code Here

            exported_ = false;
        } else {
            name_ = tmUniqueName + "UserTransactionServer";
            providerUrl_ = properties.getProperty ( Context.PROVIDER_URL );
            if ( providerUrl_ == null ) {
                throw new SysException ( "Startup property "
                        + Context.PROVIDER_URL
                        + " must be set for client demarcation." );
            }
            initialContextFactory_ = properties
                    .getProperty ( Context.INITIAL_CONTEXT_FACTORY );
            if ( initialContextFactory_ == null ) {
                throw new SysException ( "Startup property "
                        + Context.INITIAL_CONTEXT_FACTORY
                        + " must be set for client demarcation." );
            }
            properties_ = properties;

            tm_ = (TransactionManagerImp) TransactionManagerImp
                    .getTransactionManager ();
            if ( tm_ == null )
                throw new SysException ( "No TM found" );

            try {

                if ( "PortableRemoteObject".equals ( exportClass ) ) {
                    PortableRemoteObject.exportObject ( this );
                    exported_ = true;
                } else if ( "UnicastRemoteObject".equals ( exportClass ) ) {
                    UnicastRemoteObject.exportObject ( this );
                    exported_ = true;
                }

            } catch ( Exception e ) {
                Stack errors = new Stack ();
                errors.push ( e );
                throw new SysException (
                        "Error exporting - naming service not running?", errors );
            }

            try {

                Context ctx = getInitialContext ();
                ctx.rebind ( name_, this );
            } catch ( Exception e ) {
                Stack errors = new Stack ();
                errors.push ( e );
                throw new SysException (
                        "Please make sure the rmiregistry is running!?", errors );
            }

        }
View Full Code Here

                Context ctx = getInitialContext ();
                ctx.unbind ( name_ );
            } catch ( Exception e ) {
                Stack errors = new Stack ();
                errors.push ( e );
                throw new SysException ( e.getMessage (), errors );
            }
            // set exported to false, to make sure this method is
            // idempotent
            exported_ = false;
        }
View Full Code Here

        // duplicate prepares can happen for siblings in serial subtxs!!!
        // in that case, the second prepare just returns READONLY
        if ( state_.equals ( TxState.IN_DOUBT ) )
            return Participant.READ_ONLY;
        else if ( !state_.equals ( TxState.LOCALLY_DONE ) )
            throw new SysException ( "Wrong state for prepare: " + state_ );
        try {
            // refresh xaresource for MQSeries: seems to close XAResource after
            // suspend???
            testOrRefreshXAResourceFor2PC ();
            if(LOGGER.isDebugEnabled()){
              LOGGER.logDebug( "About to call prepare on XAResource instance: "
                        + xaresource_);
            }
            ret = xaresource_.prepare ( xid_ );

        } catch ( XAException xaerr ) {
          String msg = interpretErrorCode ( resourcename_ , "prepare" , xid_ , xaerr.errorCode );
            LOGGER.logWarning ( msg , xaerr ); // see case 84253
            if ( (XAException.XA_RBBASE <= xaerr.errorCode)
                    && (xaerr.errorCode <= XAException.XA_RBEND) ) {
                throw new RollbackException ( msg );
            } else {
                errors.push ( xaerr );
                throw new SysException ( msg , errors );
            }
        }
        setState ( TxState.IN_DOUBT );
        if ( ret == XAResource.XA_RDONLY ) {
          if(LOGGER.isInfoEnabled()){
View Full Code Here

            xaresource_.rollback ( xid_ );

        } catch ( ResourceException resErr ) {
            // failure of suspend
            errors.push ( resErr );
            throw new SysException ( "Error in rollback: "
                    + resErr.getMessage (), errors );
        } catch ( XAException xaerr ) {
              String msg = interpretErrorCode ( resourcename_ , "rollback" , xid_ , xaerr.errorCode );
            if ( (XAException.XA_RBBASE <= xaerr.errorCode)
                    && (xaerr.errorCode <= XAException.XA_RBEND) ) {
                // do nothing, corresponds with semantics of rollback
                if ( LOGGER.isDebugEnabled() ) LOGGER.logDebug ( msg );
            } else {
                LOGGER.logWarning ( msg , xaerr );
                switch ( xaerr.errorCode ) {
                case XAException.XA_HEURHAZ:
                  switchToHeuristicState ( "rollback" , TxState.HEUR_HAZARD , xaerr );
                  throw new HeurHazardException ( getHeuristicMessages() );
                case XAException.XA_HEURMIX:
                  switchToHeuristicState ( "rollback" , TxState.HEUR_MIXED , xaerr );
                    throw new HeurMixedException ( getHeuristicMessages () );
                case XAException.XA_HEURCOM:
                  switchToHeuristicState ( "rollback", TxState.HEUR_COMMITTED , xaerr );
                    throw new HeurCommitException ( getHeuristicMessages () );
                case XAException.XA_HEURRB:
                    forget ();
                    break;
                case XAException.XAER_NOTA:
                     //see case 21552
                   if(LOGGER.isDebugEnabled()){
                     LOGGER.logDebug("XAResource.rollback: invalid Xid - already rolled back in resource?");
                   }
                    setState ( TxState.TERMINATED );
                    //ignore error - corresponds to semantics of rollback!
                    break;
                default:
                  //fix for bug 31209
                  switchToHeuristicState( "rollback", TxState.HEUR_HAZARD , xaerr );
                    errors.push ( xaerr );
                    throw new SysException ( msg , errors );
                } // switch
            } // else
        }
        setState ( TxState.TERMINATED );
        return getHeuristicMessages ();
View Full Code Here

            throw new com.atomikos.icatch.RollbackException ( re.getMessage () );
        }

        if ( !(state_.equals ( TxState.LOCALLY_DONE ) || state_
                .equals ( TxState.IN_DOUBT ) || state_.equals ( TxState.HEUR_HAZARD )) )
            throw new SysException ( "Wrong state for commit: " + state_ );
        try {
            // refresh xaresource for MQSeries: seems to close XAResource after
            // suspend???
            testOrRefreshXAResourceFor2PC ();
            if(LOGGER.isInfoEnabled()){
              LOGGER.logInfo("XAResource.commit ( " + xidToHexString + " , " + onePhase
                        + " ) on resource " + resourcename_
                        + " represented by XAResource instance " + xaresource_);
            }
            xaresource_.commit ( xid_, onePhase );

        } catch ( XAException xaerr ) {
          String msg = interpretErrorCode ( resourcename_ , "commit" , xid_ , xaerr.errorCode );
            LOGGER.logWarning ( msg , xaerr );

            if ( (XAException.XA_RBBASE <= xaerr.errorCode)
                    && (xaerr.errorCode <= XAException.XA_RBEND) ) {
                errors.push ( xaerr );

                if ( !onePhase )
                    throw new SysException ( msg , errors );
                else
                    throw new com.atomikos.icatch.RollbackException (
                            "Already rolled back in resource." );
            } else {
                switch ( xaerr.errorCode ) {
                case XAException.XA_HEURHAZ:
                  switchToHeuristicState ( "commit" , TxState.HEUR_HAZARD , xaerr );
                    throw new HeurHazardException ( getHeuristicMessages () );
                case XAException.XA_HEURMIX:
                  switchToHeuristicState ( "commit", TxState.HEUR_MIXED , xaerr );
                    throw new HeurMixedException ( getHeuristicMessages () );
                case XAException.XA_HEURCOM:
                    forget ();
                    break;
                case XAException.XA_HEURRB:
                  switchToHeuristicState ( "commit", TxState.HEUR_ABORTED , xaerr );
                    throw new HeurRollbackException ( getHeuristicMessages () );
                case XAException.XAER_NOTA:
                    if ( ! onePhase ) {
                         //see case 21552
                      LOGGER.logWarning("XAResource.commit: invalid Xid - transaction already committed in resource?");
                        setState ( TxState.TERMINATED );
                        break;
                    }
                default:
                  //fix for bug 31209
                  switchToHeuristicState( "commit", TxState.HEUR_HAZARD , xaerr );
                    errors.push ( xaerr );
                    throw new SysException ( msg , errors );
                } // switch
            } // else
        }
        setState ( TxState.TERMINATED );
        return getHeuristicMessages ();
View Full Code Here

TOP

Related Classes of com.atomikos.icatch.SysException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.