Example usage for org.springframework.remoting RemoteAccessException RemoteAccessException

List of usage examples for org.springframework.remoting RemoteAccessException RemoteAccessException

Introduction

In this page you can find the example usage for org.springframework.remoting RemoteAccessException RemoteAccessException.

Prototype

public RemoteAccessException(String msg, Throwable cause) 

Source Link

Document

Constructor for RemoteAccessException.

Usage

From source file:org.apache.mina.springrpc.MinaClientInterceptor.java

protected RemoteAccessException convertMinaAccessException(Throwable ex) {
    if (ex instanceof SocketException) {
        throw new RemoteConnectFailureException(
                "Could not connect to Mina remote service at [" + getServiceUrl() + "]", ex);
    } else if (ex instanceof ClassNotFoundException || ex instanceof NoClassDefFoundError
            || ex instanceof InvalidClassException) {
        throw new RemoteAccessException(
                "Could not deserialize result from Mina remote service [" + getServiceUrl() + "]", ex);
    } else {/*from  w w w.  j  av  a  2 s .  co  m*/
        throw new RemoteAccessException("Could not access Mina remote service at [" + getServiceUrl() + "]",
                ex);
    }
}

From source file:org.logicblaze.lingo.jms.JmsClientInterceptor.java

public Object invoke(MethodInvocation methodInvocation) throws Throwable {
    if (AopUtils.isToStringMethod(methodInvocation.getMethod())) {
        return "JMS invoker proxy for service URL [" + getServiceUrl() + "]";
    }//from www . j  a va  2s. co m
    LingoInvocation invocation = (LingoInvocation) createRemoteInvocation(methodInvocation);
    MethodMetadata metadata = invocation.getMetadata();
    replaceRemoteReferences(invocation, metadata);
    try {
        Message requestMessage = marshaller.createRequestMessage(requestor, invocation);
        populateHeaders(requestMessage);
        if (metadata.isOneWay()) {
            requestor.send(destination, requestMessage);
            return null;
        } else if (!isMultipleResponse(methodInvocation, metadata)) {
            Message response = requestor.request(destination, requestMessage, getResponseTimeout());
            RemoteInvocationResult result = marshaller.extractInvocationResult(response);
            return recreateRemoteInvocationResult(result);
        } else {
            ResultJoinHandler handler = createResultJoinHandler(methodInvocation, metadata);
            requestor.request(destination, requestMessage, handler, getMultipleResponseTimeout());
            RemoteInvocationResult result = handler.waitForResult();
            return recreateRemoteInvocationResult(result);
        }
    } catch (JMSException e) {
        log.warn("Remote access error: " + methodInvocation, e);
        throw new RemoteAccessException("Cannot access JMS invoker remote service at [" + getServiceUrl() + "]",
                e);
    }
}

From source file:org.xins.common.spring.XinsClientInterceptor.java

/**
 * Convert the given XINS exception to an appropriate Spring RemoteAccessException.
 *
 * @param ex//from w  ww .j a va 2 s. c  o m
 *    the exception to convert.
 *
 * @return
 *    the RemoteAccessException to throw.
 */
protected RemoteAccessException convertXinsAccessException(Throwable ex) {
    if (ex instanceof GenericCallException) {
        throw new RemoteConnectFailureException(
                "Cannot connect to Burlap remote service at [" + getServiceUrl() + "]", ex);
    } else {
        throw new RemoteAccessException("Cannot access Burlap remote service at [" + getServiceUrl() + "]", ex);
    }
}

From source file:com.zz.cluster4spring.support.provider.AbstractDiscoveringEndpointProvider.java

/**
 * Creates list of endpoints available for service. Method obtains list of
 * urls that corresponds to required service key from the
 * <code>ConsumingRegistry</code> and based on this list tries to create
 * list of endpoints.//from   www  .  ja v  a 2s.c  o  m
 * <p/>
 * If endpoint creation is failed for some service url, method notes such
 * url and after endpoints creation notifies <code>ConsumingRegistry</code>
 * that particular service url is invalid.
 *
 * @param aRemoteInvocationFactory
 *            factory used to create remote invocation
 * @param aEndpointFactory
 *            factory used to create endpoints
 * @param aBeanName
 * @return list of created endpoints
 * @throws org.springframework.remoting.RemoteAccessException
 *             throws if list of endpoints could not be created
 */
@Override
protected List<E> doRefreshServiceEndpointsList(RemoteInvocationFactory aRemoteInvocationFactory,
        EndpointFactory<E, SI> aEndpointFactory, String aBeanName) throws RemoteAccessException {
    if (fLog.isTraceEnabled()) {
        String message = format("Starting refreshing of service endpoints list. Bean Name: [{0}]", aBeanName);
        fLog.trace(message);
    }

    // first, list of service "URL's" is obtained
    Set<SI> serviceURLs = null;
    String serviceKey = obtainServiceKey(aBeanName);
    try {
        serviceURLs = obtainServiceUrlsFromRegistry(serviceKey);
    } catch (Exception e) {
        String message = format("Unable to determine list of service URL from registry. Bean Name: [{0}]",
                aBeanName);
        throw new RemoteAccessException(message, e);
    }

    // For which found URL we trying to create an appropriate Endpoint
    int size = serviceURLs.size();
    List<E> result = new ArrayList<E>(size);
    List<SI> invalidURLs = new ArrayList<SI>(size); // here we collect URL's
                                                    // for which creation of
                                                    // endpoint is failed
    for (SI serviceURL : serviceURLs) {
        try {
            E endpoint = doCreateServiceEndpoint(aRemoteInvocationFactory, aEndpointFactory, aBeanName,
                    serviceURL);
            if (endpoint != null) {
                result.add(endpoint);
            } else {
                invalidURLs.add(serviceURL);
            }
        } catch (URLException e) {
            invalidURLs.add(serviceURL);

            fLog.error(serviceURL + " is valid");
            fLog.error("??URLExceptionurl?...");

        }

    }

    if (!invalidURLs.isEmpty()) // we have invalid urls - we should notify
                                // registry about them
    {
        if (fLog.isTraceEnabled()) {
            fLog.trace(format("Invalidating not valid endpoints on refresh. Bean Name: [{0}]", aBeanName));
        }

        for (SI invalidURL : invalidURLs) {
            markServiceInvalidInternal(serviceKey, serviceURLs, invalidURL);
        }
    }

    if (result.isEmpty()) {
        String message = format(
                "Unable to determine at least one server endpoint for service. Bean Name: [{0}]", aBeanName);
        throw new RemoteAccessException(message);
    }
    return result;
}

From source file:org.springframework.remoting.rmi.RmiClientInterceptorUtils.java

/**
 * Wrap the given arbitrary exception that happened during remote access
 * in either a RemoteException or a Spring RemoteAccessException (if the
 * method signature does not support RemoteException).
 * <p>Only call this for remote access exceptions, not for exceptions
 * thrown by the target service itself!//from  w w w  .j  a  v  a2  s  .co  m
 * @param method the invoked method
 * @param ex the exception that happened, to be used as cause for the
 * RemoteAccessException or RemoteException
 * @param message the message for the RemoteAccessException respectively
 * RemoteException
 * @return the exception to be thrown to the caller
 */
public static Exception convertRmiAccessException(Method method, Throwable ex, String message) {
    if (logger.isDebugEnabled()) {
        logger.debug(message, ex);
    }
    if (ReflectionUtils.declaresException(method, RemoteException.class)) {
        return new RemoteException(message, ex);
    } else {
        return new RemoteAccessException(message, ex);
    }
}

From source file:org.springframework.remoting.rmi.RmiClientInterceptorUtils.java

/**
 * Convert the given RemoteException that happened during remote access
 * to Spring's RemoteAccessException if the method signature does not
 * support RemoteException. Else, return the original RemoteException.
 * @param method the invoked method/*  ww w  .  j  a v  a2s .  c  om*/
 * @param ex the RemoteException that happened
 * @param isConnectFailure whether the given exception should be considered
 * a connect failure
 * @param serviceName the name of the service (for debugging purposes)
 * @return the exception to be thrown to the caller
 */
public static Exception convertRmiAccessException(Method method, RemoteException ex, boolean isConnectFailure,
        String serviceName) {

    if (logger.isDebugEnabled()) {
        logger.debug("Remote service [" + serviceName + "] threw exception", ex);
    }
    if (ReflectionUtils.declaresException(method, ex.getClass())) {
        return ex;
    } else {
        if (isConnectFailure) {
            return new RemoteConnectFailureException(
                    "Could not connect to remote service [" + serviceName + "]", ex);
        } else {
            return new RemoteAccessException("Could not access remote service [" + serviceName + "]", ex);
        }
    }
}