Java Code Examples for java.rmi.RemoteException#getCause()

The following examples show how to use java.rmi.RemoteException#getCause() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractRemoteServiceProxy.java    From openAGV with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a suitable {@link RuntimeException} for the given {@link RemoteException}.
 *
 * @param ex The exception to find a runtime exception for.
 * @return The runtime exception.
 */
RuntimeException findSuitableExceptionFor(RemoteException ex) {
  if (ex.getCause() instanceof ObjectUnknownException) {
    return (ObjectUnknownException) ex.getCause();
  }
  if (ex.getCause() instanceof ObjectExistsException) {
    return (ObjectExistsException) ex.getCause();
  }
  if (ex.getCause() instanceof IllegalArgumentException) {
    return (IllegalArgumentException) ex.getCause();
  }

  if (getServiceListener() != null) {
    getServiceListener().onServiceUnavailable();
  }

  return new ServiceUnavailableException(SERVICE_UNAVAILABLE_MESSAGE, ex);
}
 
Example 2
Source File: RepositoryServerAdapter.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new repository on the server.
 * @param name repository name.
 * @return handle to new repository.
 * @throws DuplicateNameException
 * @throws UserAccessException
 * @throws IOException
 * @throws NotConnectedException if server connection is down (user already informed)
 * @see ghidra.framework.remote.RemoteRepositoryServerHandle#createRepository(String)
 */
public synchronized RepositoryAdapter createRepository(String name)
		throws DuplicateNameException, UserAccessException, IOException, NotConnectedException {
	checkServerHandle();
	try {
		return new RepositoryAdapter(this, name, serverHandle.createRepository(name));
	}
	catch (RemoteException e) {
		Throwable t = e.getCause();
		if (t instanceof DuplicateFileException) {
			throw new DuplicateNameException("Repository '" + name + "' already exists");
		}
		else if (t instanceof UserAccessException) {
			throw (UserAccessException) t;
		}
		if (recoverConnection(e)) {
			return new RepositoryAdapter(this, name, serverHandle.createRepository(name));
		}
		throw e;
	}
}
 
Example 3
Source File: BirtViewerReportService.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Temporary method for extracting the exception from the
 * DummyRemoteException and throwing it.
 */
private void throwReportServiceException( RemoteException e )
		throws ReportServiceException
{
	Throwable wrappedException = e;
	if ( e instanceof ReportEngineService.DummyRemoteException )
	{
		wrappedException = e.getCause( );
	}
	if ( wrappedException instanceof ReportServiceException )
	{
		throw (ReportServiceException) wrappedException;
	}
	else if ( wrappedException != null )
	{
		throw new ReportServiceException( wrappedException.getLocalizedMessage( ),
				wrappedException );
	}
	else
	{
		throw new ReportServiceException( e.getLocalizedMessage( ), e );
	}
}
 
Example 4
Source File: SketchServiceRunner.java    From Processing.R with GNU General Public License v3.0 5 votes vote down vote up
private void handleRemoteException(final RemoteException exception) throws SketchException {
  final Throwable cause = exception.getCause();
  if (cause instanceof SocketTimeoutException || cause instanceof ConnectException) {
    log("SketchRunner either hung or not there. Restarting it.");
    restartServerProcess();
  } else {
    throw new SketchException(exception.getMessage());
  }
}
 
Example 5
Source File: NDPIImageNative.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
@Override
public String readInfoString(String filename) throws OrbitImageServletException {
    try {
        logger.debug("file: "+this.filename);
        String info = getServer().getInfo(this.filename, level);
        return info;
    } catch (RemoteException e) {
        throw new OrbitImageServletException(e.getMessage() + "\nCause:" + e.getCause());
    }
}
 
Example 6
Source File: ExampleClient.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Helper function to easily evaluate web service related exceptions
 * @param e Exception thrown by a stub method
 */
public static void checkException(Exception e) {
    if(e instanceof JPlagException) {
        JPlagException je = (JPlagException) e;
        System.out.println("JPlagException: " + je.getDescription()
            + "\n" + je.getRepair());
    }
    else if(e instanceof RemoteException) {
        RemoteException re = (RemoteException) e;
        Throwable cause = re.getCause();
        if(cause != null && cause instanceof ClientTransportException) {
            cause = ((JAXRPCExceptionBase) cause).getLinkedException();
            if(cause != null) {
                System.out.println("Connection exception: "
                    + cause.getMessage());
                return;
            }
        }
        System.out.println("Unexpected RemoteException: "
            + re.getMessage());
        re.printStackTrace();
    }
    else {
        System.out.println("Unexpected Exception: " + e.getMessage());
        e.printStackTrace();
    }
}
 
Example 7
Source File: ExampleConnect.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Helper function to easily evaluate web service related exceptions
 * @param e Exception thrown by a stub method
 */
public static void checkException(Exception e) {
    if(e instanceof JPlagException) {
        JPlagException je = (JPlagException) e;
        System.out.println("JPlagException: " + je.getDescription()
            + "\n" + je.getRepair());
    }
    else if(e instanceof RemoteException) {
        RemoteException re = (RemoteException) e;
        Throwable cause = re.getCause();
        if(cause != null && cause instanceof ClientTransportException) {
            cause = ((JAXRPCExceptionBase) cause).getLinkedException();
            if(cause != null) {
                System.out.println("Connection exception: "
                    + cause.getMessage());
                return;
            }
        }
        System.out.println("Unexpected RemoteException: "
            + re.getMessage());
        re.printStackTrace();
    }
    else {
        System.out.println("Unexpected Exception: " + e.getMessage());
        e.printStackTrace();
    }
}
 
Example 8
Source File: AdminTool.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
public boolean CheckConnectException(RemoteException re, Component comp) {
	Throwable cause = re.getCause();
	if (cause != null && cause instanceof com.sun.xml.rpc.client.ClientTransportException) {
		cause = ((com.sun.xml.rpc.util.exception.JAXRPCExceptionBase) cause).getLinkedException();
		if (cause != null) {
			JOptionPane.showMessageDialog(comp, cause.getMessage(), "Connect exception!", JOptionPane.ERROR_MESSAGE);
			return true;
		}
	}
	return false;
}
 
Example 9
Source File: JplagSwingClient.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
public boolean CheckConnectException(RemoteException re) {
	Throwable cause = re.getCause();
	if (cause != null && cause instanceof com.sun.xml.rpc.client.ClientTransportException) {
		cause = ((com.sun.xml.rpc.util.exception.JAXRPCExceptionBase) cause).getLinkedException();
		if (cause != null) {
			getStatusTextfield().setText(cause.getMessage());
			return true;
		}
	}
	return false;
}
 
Example 10
Source File: OperationInfo.java    From tomee with Apache License 2.0 5 votes vote down vote up
public Throwable unwrapFault(RemoteException re) {
    if (re instanceof AxisFault && re.getCause() != null) {
        Throwable t = re.getCause();
        if (operationDesc.getFaultByClass(t.getClass()) != null) {
            return t;
        }
    }
    return re;
}
 
Example 11
Source File: RmiClientInterceptorUtils.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Determine whether the given RMI exception indicates a connect failure.
 * <p>Treats RMI's ConnectException, ConnectIOException, UnknownHostException,
 * NoSuchObjectException and StubNotFoundException as connect failure.
 * @param ex the RMI exception to check
 * @return whether the exception should be treated as connect failure
 * @see java.rmi.ConnectException
 * @see java.rmi.ConnectIOException
 * @see java.rmi.UnknownHostException
 * @see java.rmi.NoSuchObjectException
 * @see java.rmi.StubNotFoundException
 */
public static boolean isConnectFailure(RemoteException ex) {
	return (ex instanceof ConnectException || ex instanceof ConnectIOException ||
			ex instanceof UnknownHostException || ex instanceof NoSuchObjectException ||
			ex instanceof StubNotFoundException || ex.getCause() instanceof SocketException ||
			isCorbaConnectFailure(ex.getCause()));
}
 
Example 12
Source File: RmiClientInterceptorUtils.java    From spring4-understanding with Apache License 2.0 3 votes vote down vote up
/**
 * Determine whether the given RMI exception indicates a connect failure.
 * <p>Treats RMI's ConnectException, ConnectIOException, UnknownHostException,
 * NoSuchObjectException and StubNotFoundException as connect failure.
 * @param ex the RMI exception to check
 * @return whether the exception should be treated as connect failure
 * @see java.rmi.ConnectException
 * @see java.rmi.ConnectIOException
 * @see java.rmi.UnknownHostException
 * @see java.rmi.NoSuchObjectException
 * @see java.rmi.StubNotFoundException
 */
public static boolean isConnectFailure(RemoteException ex) {
	return (ex instanceof ConnectException || ex instanceof ConnectIOException ||
			ex instanceof UnknownHostException || ex instanceof NoSuchObjectException ||
			ex instanceof StubNotFoundException || ex.getCause() instanceof SocketException ||
			isCorbaConnectFailure(ex.getCause()));
}
 
Example 13
Source File: RmiClientInterceptorUtils.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Determine whether the given RMI exception indicates a connect failure.
 * <p>Treats RMI's ConnectException, ConnectIOException, UnknownHostException,
 * NoSuchObjectException and StubNotFoundException as connect failure.
 * @param ex the RMI exception to check
 * @return whether the exception should be treated as connect failure
 * @see java.rmi.ConnectException
 * @see java.rmi.ConnectIOException
 * @see java.rmi.UnknownHostException
 * @see java.rmi.NoSuchObjectException
 * @see java.rmi.StubNotFoundException
 */
public static boolean isConnectFailure(RemoteException ex) {
	return (ex instanceof ConnectException || ex instanceof ConnectIOException ||
			ex instanceof UnknownHostException || ex instanceof NoSuchObjectException ||
			ex instanceof StubNotFoundException || ex.getCause() instanceof SocketException);
}
 
Example 14
Source File: RmiClientInterceptorUtils.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Determine whether the given RMI exception indicates a connect failure.
 * <p>Treats RMI's ConnectException, ConnectIOException, UnknownHostException,
 * NoSuchObjectException and StubNotFoundException as connect failure.
 * @param ex the RMI exception to check
 * @return whether the exception should be treated as connect failure
 * @see java.rmi.ConnectException
 * @see java.rmi.ConnectIOException
 * @see java.rmi.UnknownHostException
 * @see java.rmi.NoSuchObjectException
 * @see java.rmi.StubNotFoundException
 */
public static boolean isConnectFailure(RemoteException ex) {
	return (ex instanceof ConnectException || ex instanceof ConnectIOException ||
			ex instanceof UnknownHostException || ex instanceof NoSuchObjectException ||
			ex instanceof StubNotFoundException || ex.getCause() instanceof SocketException);
}