Package org.jboss.remoting

Examples of org.jboss.remoting.CannotConnectException


   {
      if(this.server == null)
      {
         log.debug("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();
               if (marshaller instanceof VersionedMarshaller)
                  ((VersionedMarshaller) marshaller).write(payload, byteOut, getVersion());
               else
                  marshaller.write(payload, byteOut);
              
               byteOut.close();
              
               if (rmiOnewayMarshalling)
               {
                  // Legacy treatment, pre 2.4.0.
                  ByteArrayInputStream bais = new ByteArrayInputStream(byteOut.toByteArray());
                  SerializationManager manager = SerializationStreamFactory.getManagerInstance(getSerializationType());
                  ObjectInputStream ois = manager.createInput(bais, getClassLoader());

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

         int simulatedTimeout = getSimulatedTimeout(configuration, metadata);
         if (simulatedTimeout <= 0)
         {
            Object result = SecurityUtility.callTransport(server, payload);
            return unmarshal(result, unmarshaller, metadata);
         }
         else
         {
            if (log.isTraceEnabled()) log.trace("using simulated timeout: " + simulatedTimeout);
           
            class Holder {public Object value;}
            final Holder resultHolder = new Holder();
            final Object finalPayload = payload;
           
            Runnable r = new Runnable()
            {
               public void run()
               {
                  try
                  {
                     resultHolder.value = SecurityUtility.callTransport(server, finalPayload);
                     if (log.isTraceEnabled()) log.trace("result: " + resultHolder.value);
                  }
                  catch (Exception e)
                  {
                     resultHolder.value = e;
                     if (log.isTraceEnabled()) log.trace("exception: " + e);
                  }
               }
            };
           
            // BasicThreadPool timeout mechanism depends on the interrupted status of
            // the running thread.
            Thread.interrupted();
           
            ThreadPool pool = getTimeoutThreadPool();
            WaitingTaskWrapper wrapper = new WaitingTaskWrapper(r, simulatedTimeout);
            if (log.isTraceEnabled()) log.trace("starting task in thread pool");
            pool.runTaskWrapper(wrapper);
            if (log.isTraceEnabled()) log.trace("task finished in thread pool");
           
            Object result = unmarshal(resultHolder.value, unmarshaller, metadata);
            if (result == null)
            {
               if (log.isTraceEnabled()) log.trace("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;
            }
            else if (result instanceof RuntimeException)
            {
               throw (RuntimeException) result;
            }
            else
            {
               if (log.isTraceEnabled()) log.trace("returning result: " + result);
               return result;
            }
         }
      }
      catch(RemoteException e)
      {
         log.debug("Error making invocation in RMI client invoker.", e);
         throw new CannotConnectException("Error making invocation in RMI client invoker.", e);
      }
   }
View Full Code Here


/* 216 */       return (JMSException)t;
/*     */     }
/* 218 */     if ((t instanceof CannotConnectException))
/*     */     {
/* 220 */       boolean failover = true;
/* 221 */       CannotConnectException cc = (CannotConnectException)t;
/* 222 */       Throwable underlying = cc.getCause();
/* 223 */       if ((underlying != null) && ((underlying instanceof SocketException)))
/*     */       {
/* 228 */         if ((underlying.getMessage() != null) && (underlying.getMessage().startsWith("Can not obtain client socket connection from pool")))
/*     */         {
/* 231 */           log.warn("Timed out getting a connection from the pool. Try increasing clientMaxPoolSize and/or numberOfRetries attributes in remoting-xxx-service.xml");
View Full Code Here

/*     */       }
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 333 */       log.debug("Error invoking http client invoker.", e);
/* 334 */       throw new CannotConnectException("Can not connect http client invoker.", e);
/*     */     }
/*     */
/* 338 */     if ((responseCode >= 400) || (("servlet".equals(getLocator().getProtocol())) && ((result instanceof InvocationResponse)) && ((((InvocationResponse)result).getResult() instanceof ServletThrowable))))
/*     */     {
/* 343 */       if (metadata != null)
View Full Code Here

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

/*     */   {
/* 197 */     if (this.server == null)
/*     */     {
/* 199 */       log.error("Server stub has not been set in RMI invoker client.  See previous errors for details.");
/*     */
/* 201 */       throw new CannotConnectException("Server stub has not been set.");
/*     */     }
/*     */
/*     */     try
/*     */     {
/* 206 */       Object payload = invocation;
/* 207 */       if ((marshaller != null) && (!(marshaller instanceof RMIMarshaller)))
/*     */       {
/* 209 */         if ((marshaller instanceof MarshallerDecorator))
/*     */         {
/* 211 */           payload = ((MarshallerDecorator)marshaller).addDecoration(payload);
/*     */         }
/*     */         else
/*     */         {
/* 215 */           ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
/* 216 */           if ((marshaller instanceof VersionedMarshaller))
/* 217 */             ((VersionedMarshaller)marshaller).write(payload, byteOut, Version.getDefaultVersion());
/*     */           else
/* 219 */             marshaller.write(payload, byteOut);
/* 220 */           ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
/* 221 */           ObjectInputStream ois = new ObjectInputStream(byteIn);
/*     */           try
/*     */           {
/* 225 */             byteOut.close();
/* 226 */             payload = ois.readObject();
/* 227 */             ois.close();
/*     */           }
/*     */           catch (ClassNotFoundException e)
/*     */           {
/* 231 */             log.error("Could not marshall invocation payload object " + payload, e);
/* 232 */             throw new IOException(e.getMessage());
/*     */           }
/*     */         }
/*     */
/*     */       }
/*     */
/* 238 */       Object response = this.server.transport(payload);
/*     */
/* 268 */       return response;
/*     */     }
/*     */     catch (RemoteException e)
/*     */     {
/* 272 */       log.error(e);
/* 273 */     }throw new CannotConnectException("Error making invocation in RMI client invoker.", e);
/*     */   }
View Full Code Here

/*     */       }
/*     */       catch (Exception e)
/*     */       {
/* 557 */         this.semaphore.release();
/* 558 */         if (trace) log.trace(this + " released semaphore: " + this.semaphore.permits());
/* 559 */         throw new CannotConnectException("Can not get connection to server. Problem establishing socket connection for " + this.locator, e);
/*     */       }
/*     */
/* 564 */       if (tempTimeout >= 0)
/*     */       {
/* 566 */         savedTimeout = socketWrapper.getTimeout();
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

      }
      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)
      {
         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

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.