Package org.rhq.core.util.exception

Examples of org.rhq.core.util.exception.WrappedRemotingException


            serverBootstrapService = (ServerCommunicationsServiceMBean) MBeanServerInvocationHandler.newProxyInstance(
                mbean_server, ServerCommunicationsServiceMBean.OBJECT_NAME, ServerCommunicationsServiceMBean.class,
                false);
        } catch (Exception e) {
            LOG.error("Could not find server comm service - agent communications are not allowed at this time");
            throw new WrappedRemotingException(new Exception(
                "Cannot get server comm service; unable to communicate with agents", e));
        }

        return serverBootstrapService;
    }
View Full Code Here


            result = m.invoke(target, nbi.getParameters());
            successful = true;

        } catch (InvocationTargetException e) {
            log.error("Failed to invoke remote request", e);
            return new WrappedRemotingException(e.getTargetException());
        } catch (Exception e) {
            log.error("Failed to invoke remote request", e);
            return new WrappedRemotingException(e);
        } finally {
            if (result != null) {
                // set the strategy guiding how the return information is serialized
                ExternalizableStrategy.setStrategy(ExternalizableStrategy.Subsystem.REFLECTIVE_SERIALIZATION);

                // scrub the return data if Hibernate proxies
                try {
                    HibernateDetachUtility.nullOutUninitializedFields(result,
                        HibernateDetachUtility.SerializationType.SERIALIZATION);
                } catch (Exception e) {
                    log.error("Failed to null out uninitialized fields", e);
                    this.metrics.addData(methodName, System.currentTimeMillis() - time, false);

                    return new WrappedRemotingException(e);
                }
            }

            // want to calculate this after the hibernate util so we take that into account too
            long executionTime = System.currentTimeMillis() - time;
View Full Code Here

            try {
                agentManager.updateAgent(agentByName);
            } catch (Exception e) {
                log.warn("Could not update the agent in database", e);
                throw new AgentRegistrationException(new WrappedRemotingException(e));
            }

            // if agent is re-registering in order to change its remote endpoint, destroy our old client.
            if (!oldAddress.equals(request.getAddress()) || oldPort != request.getPort()
                || !oldRemoteEndpoint.equals(request.getRemoteEndpoint())) {
                try {
                    final Agent oldAgent = new Agent();
                    oldAgent.setName(agentByName.getName());
                    oldAgent.setAddress(oldAddress);
                    oldAgent.setPort(oldPort);
                    oldAgent.setRemoteEndpoint(oldRemoteEndpoint);
                    agentManager.destroyAgentClient(oldAgent);
                } catch (Exception e) {
                    log.warn("Could not destroy the agent client - will continue but agent comm may be broken", e);
                }
            }
        } else {
            log.info("Got agent registration request for new agent: " + request.getName() + "[" + request.getAddress()
                + ":" + request.getPort() + "][" + request.getAgentVersion() + "]");

            // the agent does not yet exist, we need to create it
            try {
                agentByName = new Agent(request.getName(), request.getAddress(), request.getPort(),
                    request.getRemoteEndpoint(), generateAgentToken());

                agentByName.setServer(registeringServer);
                agentManager.createAgent(agentByName);
            } catch (Exception e) {
                log.warn("Failed to create agent in database", e);
                throw new AgentRegistrationException(new WrappedRemotingException(e));
            }
        }

        // get existing or generate new server list for the registering agent
        FailoverListComposite failoverList = getPartitionEventManager().agentPartitionEvent(
View Full Code Here

                    plugins.add(potentialPlugin);
                }
            }
        } catch (Exception e) {
            log.warn("Failed to get the list of latest plugins", e);
            throw new WrappedRemotingException(e);
        } finally {
            if (em != null) {
                em.close();
            }
        }
View Full Code Here

            BufferedInputStream bis = new BufferedInputStream(fis, 1024 * 32);
            RemoteInputStream in = ServerCommunicationsServiceUtil.remoteInputStream(bis);

            return in;
        } catch (Exception e) {
            throw new WrappedRemotingException(e);
        }
    }
View Full Code Here

                        + endpoint);
                }
            }
        } catch (Exception e) {
            failure = new AgentRegistrationException("Cannot verify agent endpoint due to internal error.",
                new WrappedRemotingException(e));
        }

        if (failure != null) {
            log.warn(failure);
            throw failure;
View Full Code Here

            // In the exception we throw over to the server, strip the InvalidPluginConfigurationException out of the
            // stack trace, but append the message from that exception to the message of the exception we throw. This
            // will make for a nicer error message for the server to display in the UI.
            throw new InvalidPluginConfigurationClientException(errorMessage,
                (e.getCause() != null) ? new WrappedRemotingException(e.getCause()) : null);
        }
    }
View Full Code Here

                // In the exception we throw over to the server, strip the InvalidPluginConfigurationException out of the
                // stack trace, but append the message from that exception to the message of the exception we throw. This
                // will make for a nicer error message for the server to display in the UI.
                errorMessage += ((t.getLocalizedMessage() != null) ? (" " + t.getLocalizedMessage()) : "");
                throw new InvalidPluginConfigurationClientException(errorMessage,
                    (t.getCause() != null) ? new WrappedRemotingException(t.getCause()) : null);
            } else {
                log.error("Manual add failed for resource of type [" + resourceType.getName()
                    + "] and parent resource id [" + parentResourceId + "]", t);
                throw new PluginContainerException("Failed to add resource with type [" + resourceType.getName()
                    + "] and parent resource id [" + parentResourceId + "]", new WrappedRemotingException(t));
            }
        }

        return mergeResourceResponse;
    }
View Full Code Here

                // make sure its serializable
                StreamUtil.serialize(e);
                return e;
            } catch (Exception ignore) {
                // not serializable for some reason (a cause within the exception was an inner class within a non-serialized class?)
                return new WrappedRemotingException(e);
            }
        }

        // if the exception occurred outside of invoking any method - wrap the exception
        if (method == null) {
            return new WrappedRemotingException(e);
        }

        Class<?>[] declared_exceptions = method.getExceptionTypes();

        // if the method did not declare any exceptions, wrap the exception
        if ((declared_exceptions == null) || (declared_exceptions.length == 0)) {
            return new WrappedRemotingException(e);
        }

        // check all declared exceptions and do not wrap the given exception if its one of those types
        for (Class<?> declared_exception : declared_exceptions) {
            // don't use isAssignableFrom since we a declared "java.lang.Exception" would match everything.
            if (declared_exception.getName().equals(e.getClass().getName())) {
                try {
                    // one final check - make sure its serializable
                    StreamUtil.serialize(e);
                    return e;
                } catch (Exception ignore) {
                    // not serializable for some reason (exception was an inner class within a non-serialized class?)
                    return new WrappedRemotingException(e);
                }
            }
        }

        // didn't match any of the method's declared exceptions - wrap it
        return new WrappedRemotingException(e);
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.util.exception.WrappedRemotingException

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.