Package org.jboss.remoting

Examples of org.jboss.remoting.CannotConnectException


         }
      }
      catch (Exception e)
      {
         log.debug("Error invoking http client invoker.", e);
         throw new CannotConnectException("Can not connect http client invoker.", e);
      }

      // now check for error response and throw exception unless configured to not do so
      if(responseCode >= 400)
      {
View Full Code Here


         return (JMSException)t;
      }
      else if (t instanceof CannotConnectException)
      {
        boolean failover = true;
        CannotConnectException cc = (CannotConnectException)t;
        Throwable underlying = cc.getCause();
        if (underlying != null && underlying instanceof SocketException)
        {
          //If remoting fails to find a connection because the client pool is full
          //then it throws a SocketException! - in this case we DO NOT want to failover
          //See http://jira.jboss.com/jira/browse/JBMESSAGING-1114
View Full Code Here

        }

        try {
            // AutoDiscoveryException match throws so we assume the developer knows what he is doing and only
            // includes causes within it that are allowed to be sent over the wire - it is not wrapped
            pojo.throwSpecificException(new AutoDiscoveryException("should not be wrapped", new CannotConnectException(
                "inner exception")));
        } catch (AutoDiscoveryException expected) {
            assert expected.getMessage().equals("should not be wrapped");
            assert expected.getCause() instanceof CannotConnectException;
            assert expected.getCause().getMessage().equals("inner exception");
        }

        try {
            // IllegalArgumentException doesn't match throws but is a java.* runtime exception - however, its cause
            // is a non-java.* exception - it should be wrapped entirely
            pojo.throwSpecificException(new IllegalArgumentException("should be wrapped", new CannotConnectException(
                "inner exception")));
        } catch (WrappedRemotingException expected) {
            assert expected.getMessage().indexOf("should be wrapped") != -1;
            assert expected.getCause().getMessage().indexOf("inner exception") != -1;
            assert ((WrappedRemotingException) expected.getCause()).getActualException().getExceptionName().equals(
                CannotConnectException.class.getName());
        }

        try {
            // doesn't match throws and is not a java.* exception - will be wrapped
            pojo.throwSpecificException(new CannotConnectException("should be wrapped"));
        } catch (WrappedRemotingException expected) {
            assert expected.getMessage().indexOf("should be wrapped") != -1;
            assert expected.getActualException().getExceptionName().equals(CannotConnectException.class.getName());
        }

View Full Code Here

      }
      catch(Exception e)
      {
         connected = false;
         log.debug("Error connecting RMI invoker client.", e);
         throw new CannotConnectException("Error connecting RMI invoker client", e);
      }
   }
View Full Code Here

   {
      if(this.server == null)
      {
         log.error("Server stub has not been set in RMI invoker client.  See previous errors for details.");
         //throw new IOException("Server stub hasn't been set!");
         throw new CannotConnectException("Server stub has not been set.");
      }
      try
      {

         Object payload = invocation;
         if(marshaller != null && !(marshaller instanceof RMIMarshaller))
         {
            if(marshaller instanceof MarshallerDecorator)
            {
               payload = ((MarshallerDecorator) marshaller).addDecoration(payload);
            }
            else
            {
               ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
               marshaller.write(payload, byteOut);
               ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
               ObjectInputStream ois = new ObjectInputStream(byteIn);

               try
               {
                  byteOut.close();
                  payload = ois.readObject();
                  ois.close();
               }
               catch(ClassNotFoundException e)
               {
                  log.error("Could not marshall invocation payload object " + payload, e);
                  throw new IOException(e.getMessage());
               }
            }

         }

         Object response = server.transport(payload);

         /* Jira Issue: JBREM-167
         if(unmarshaller != null && !(unmarshaller instanceof RMIUnMarshaller))
         {
            PipedOutputStream pos = new PipedOutputStream();
            PipedInputStream pis = new PipedInputStream();
            pos.connect(pis);
            ObjectOutputStream oos = new ObjectOutputStream(pos);
            oos.writeObject(response);
            oos.flush();
            oos.reset();
            oos.writeObject(Boolean.TRUE);
            oos.flush();
            oos.reset();
            try
            {
               oos.close();
               response = unmarshaller.read(pis, metadata);
               pis.close();
            }
            catch(ClassNotFoundException e)
            {
               log.error("Could not unmarshall invocation response" + response, e);
               throw new IOException(e.getMessage());
            }

         }
         */

         return response;
      }
      catch(RemoteException e)
      {
         log.error(e);
         throw new CannotConnectException("Error making invocation in RMI client invoker.", e);
      }
   }
View Full Code Here

         }
      }
      catch (Exception e)
      {
         log.debug("Error invoking http client invoker.", e);
         throw new CannotConnectException("Can not connect http client invoker.", e);
      }

      // now check for error response and throw exception unless configured to not do so
      if(responseCode >= 400)
      {
View Full Code Here

         {
//            if (bailOut)
//               return null;
            semaphore.release();
            if (trace) log.trace(this + " released semaphore: " + semaphore.permits(), e);
            sockEx =  new CannotConnectException(
                  "Can not get connection to server. Problem establishing " +
                  "socket connection for " + locator, e);
            continue;
         }

         if (tempTimeout >= 0)
         {
            timeLeft = (int) (tempTimeout - (System.currentTimeMillis() - start));
            if (timeLeft <= 0)
               break;
            savedTimeout = socketWrapper.getTimeout();           
            socketWrapper.setTimeout(timeLeft);
         }

         long end = System.currentTimeMillis() - start;
         getSocketTime += end;

         try
         {
            int version = getVersion();
            boolean performVersioning = Version.performVersioning(version);

            OutputStream outputStream = socketWrapper.getOutputStream();

            if (performVersioning)
            {
               writeVersion(outputStream, version);
            }

            //TODO: -TME so this is messed up as now ties remoting versioning to using a marshaller type
            versionedWrite(outputStream, marshaller, invocation, version);

            end = System.currentTimeMillis() - start;
            writeTime += end;
            start = System.currentTimeMillis();

            if (serverSideOneway)
            {
               if(trace) { log.trace(this + " sent oneway invocation, so not waiting for response, returning null"); }
            }
            else
            {
               int onewaySavedTimeout = -1;
               if (oneway)
               {
                  onewaySavedTimeout = socketWrapper.getTimeout();
                  socketWrapper.setTimeout(onewayConnectionTimeout);
               }
              
               InputStream inputStream = socketWrapper.getInputStream();
               if (performVersioning)
               {
                  version = readVersion(inputStream);
                  if (version == -1)
                  {
                     throw new EOFException("end of file");
                  }
                  if (version == SocketWrapper.CLOSING)
                  {
                     log.trace(this + " received version 254: treating as end of file");
                     throw new EOFException("end of file");
                  }
               }

               response = versionedRead(inputStream, unmarshaller, version);
              
               // Note that if an exception is thrown, the socket is thrown away,
               // so there's no need to reset the timeout value.
               if (oneway)
               {
                  socketWrapper.setTimeout(onewaySavedTimeout);
               }
            }

            end = System.currentTimeMillis() - start;
            readTime += end;

            // Note that resetting the timeout value after closing the socket results
            // in an exception, so the reset is not done in a finally clause.  However,
            // if a catch clause is ever added that does not close the socket, care
            // must be taken to reset the timeout in that case.
            if (tempTimeout >= 0)
            {
               socketWrapper.setTimeout(savedTimeout);
            }
         }
         catch (SocketException sex)
         {
            handleRetriableException(socketWrapper, sex, retryCount);
            sockEx = sex;
            continue;
         }
         catch (EOFException ex)
         {
            handleRetriableException(socketWrapper, ex, retryCount);
            sockEx = ex;
            continue;
         }
         catch (Exception ex)
         {
            log.debug(this + " got exception: " + socketWrapper, ex);

            try
            {
               semaphore.release();
               if (trace) log.trace(this + " released semaphore: " + semaphore.permits());
               socketWrapper.close();
            }
            catch (Exception ignored)
            {
            }
           
            if (oneway)
               return null;
            else
               return handleException(ex, socketWrapper);
         }

         // call worked, so no need to retry
         break;
      }

      // need to check if ran out of retries
      if (retryCount >= numberOfCallRetries)
      {
         handleException(sockEx, socketWrapper);
      }
     
      if (response == null && tempTimeout > 0 && timeLeft <= 0)
      {
         if (sockEx == null)
         {
            sockEx =  new CannotConnectException(
                         "Can not get connection to server. Timed out establishing " +
                         "socket connection for " + locator);
         }
         handleException(sockEx, socketWrapper);
      }
View Full Code Here

         {
            socketWrapper = getConnection(marshaller, unmarshaller, timeLeft);
         }
         catch (Exception e)
         {
            throw new CannotConnectException(
               "Can not get connection to server. Problem establishing " +
               "socket connection for " + locator, e);
         }

         if (tempTimeout >= 0)
View Full Code Here

            log.debug(this + " got " + e + ": " + e.getMessage());
            if (retryCount < numberOfCallRetries - 1)
            {
               continue;
            }
            throw new CannotConnectException(
                  "Can not get connection to server. Problem establishing " +
                  "socket connection for " + locator, e);
           
         }
         catch (IOException e)
         { 
            semaphore.release();
            if (trace) log.trace(this + " released semaphore: " + semaphore.permits());
            log.debug(this + " got " + e + ": " + e.getMessage());
            if (retryCount < numberOfCallRetries - 1 && isGeneralizeSocketException()
                  && e.getMessage() != null && RETRIABLE_ERROR_MESSAGE.matcher(e.getMessage()).matches())
            {
               continue;
            }
            throw new CannotConnectException(
               "Can not get connection to server. Problem establishing " +
               "socket connection for " + locator, e);
         }
         catch (Exception e)
         {
//            if (bailOut)
//               return null;
            semaphore.release();
            if (trace) log.trace(this + " released semaphore: " + semaphore.permits());
            if (e instanceof InterruptedException && isWrapInterruptedException())
               throw new RuntimeException(e);
            throw new CannotConnectException(
               "Can not get connection to server. Problem establishing " +
               "socket connection for " + locator, e);
         }

         if (tempTimeout >= 0)
View Full Code Here

            Object result = resultHolder.value;
            if (result == null)
            {
               if (log.isDebugEnabled()) log.debug("invocation timed out");
               Exception cause = new SocketTimeoutException("timed out");
               throw new CannotConnectException("Can not connect http client invoker.", cause);
            }
            else if (result instanceof IOException)
            {
               throw (IOException) result;
            }
View Full Code Here

TOP

Related Classes of org.jboss.remoting.CannotConnectException

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.