Package org.mc4j.ems.connection

Examples of org.mc4j.ems.connection.EmsConnectException


                        entries.add(getCachedTempForFile(file,tempDir));
                    } else {
                        entries.add(file.toURI().toURL());
                    }
                } catch (MalformedURLException e) {
                    throw new EmsConnectException("Unable to read class path library url", e);
                }
            }
        }

        // Now load in the implementation jar
        // URL implURL = new URL(null, "deepjar://org-mc4j-ems-impl.jar", new Handler());
        URL implURL = storeImplToTemp("org-mc4j-ems-impl.jar", tempDir);

        entries.add(implURL);


        if (settings.getConnectionType() instanceof LocalVMTypeDescriptor) {
            // Need tools.jar if its not already loaded
            try {
                Class.forName("com.sun.tools.attach.VirtualMachine");
            } catch (ClassNotFoundException e) {
                // Try to load tools.jar
                File toolsJar = null;
                toolsJar = findToolsJarForHome(System.getProperty("java.home"));
                if (toolsJar == null) {
                    toolsJar = findToolsJarForHome(System.getProperty("env_java_home"));
                }

                if (toolsJar != null) {
                    try {
                        log.debug("Found tools.jar at " + toolsJar.getPath());
                        entries.add(toolsJar.toURI().toURL());
                    } catch (MalformedURLException e1) { /* Unnexpected */ }
                } else {
                    throw new EmsConnectException("Unable to find tools.jar. Add it to your classpath to use Sun local vm connections.");
                }
            }
        }


View Full Code Here


                        entries.add(getCachedTempForFile(file,tempDir));
                    } else {
                        entries.add(file.toURI().toURL());
                    }
                } catch (MalformedURLException e) {
                    throw new EmsConnectException("Unable to read class path library url", e);
                }
            }
        }

        // Now load in the implementation jar
        // URL implURL = new URL(null, "deepjar://org-mc4j-ems-impl.jar", new Handler());
        URL implURL = storeImplToTemp("org-mc4j-ems-impl.jar", tempDir);

        entries.add(implURL);


        if (settings.getConnectionType() instanceof LocalVMTypeDescriptor) {
            // Need tools.jar if its not already loaded
            try {
                Class.forName("com.sun.tools.attach.VirtualMachine");
            } catch (ClassNotFoundException e) {
                // Try to load tools.jar
                File toolsJar = null;
                toolsJar = findToolsJarForHome(System.getProperty("java.home"));
                if (toolsJar == null) {
                    toolsJar = findToolsJarForHome(System.getProperty("env_java_home"));
                }

                if (toolsJar != null) {
                    try {
                        log.debug("Found tools.jar at " + toolsJar.getPath());
                        entries.add(toolsJar.toURI().toURL());
                    } catch (MalformedURLException e1) { /* Unnexpected */ }
                } else {
                    throw new EmsConnectException("Unable to find tools.jar. Add it to your classpath to use Sun local vm connections.");
                }
            }
        }


View Full Code Here

                        entries.add(getCachedTempForFile(file,tempDir));
                    } else {
                        entries.add(file.toURI().toURL());
                    }
                } catch (MalformedURLException e) {
                    throw new EmsConnectException("Unable to read class path library url", e);
                }
            }
        }

        // Now load in the implementation jar
        // URL implURL = new URL(null, "deepjar://org-mc4j-ems-impl.jar", new Handler());
        URL implURL = storeImplToTemp("org-mc4j-ems-impl.jar", tempDir);

        entries.add(implURL);


        if (settings.getConnectionType() instanceof LocalVMTypeDescriptor) {
            // Need tools.jar if its not already loaded
            try {
                Class.forName("com.sun.tools.attach.VirtualMachine");
            } catch (ClassNotFoundException e) {
                // Try to load tools.jar
                File toolsJar = null;
                toolsJar = findToolsJarForHome(System.getProperty("java.home"));
                if (toolsJar == null) {
                    toolsJar = findToolsJarForHome(System.getProperty("env_java_home"));
                }

                if (toolsJar != null) {
                    try {
                        log.debug("Found tools.jar at " + toolsJar.getPath());
                        entries.add(toolsJar.toURI().toURL());
                    } catch (MalformedURLException e1) { /* Unnexpected */ }
                } else {
                    throw new EmsConnectException("Unable to find tools.jar. Add it to your classpath to use Sun local vm connections.");
                }
            }
        }


View Full Code Here

        try {
            doConnect();
           this.connected = true;
           this.connectionFailure = false;          
        } catch (Exception e) {
            throw new EmsConnectException("Could not connect [" + connectionSettings.getServerUrl() + "] " + e.toString(), e);
        }

        if (existingConnection == null) {
            DConnection connection = new DConnection("unknown",this);
View Full Code Here

        this.connectionFailure = false;

        try {
            doDisconnect();
        } catch (Exception e) {
            throw new EmsConnectException("Could not close connection " +  e.toString(), e);
        }

        for (ConnectionListener listener : connectionListeners) {
            listener.disconnect();
        }
View Full Code Here

            }
            setStatsProxy(proxy);
            this.mbeanServer = proxy.buildServerProxy();

        } catch (MalformedURLException e) {
            throw new EmsConnectException("Malformed url", e);
        } catch (IOException e) {
            throw new EmsConnectException("IOException: Check service availability",e);
        } catch (NamingException e) {
            throw new EmsConnectException("Naming failure",e);
        }

    }
View Full Code Here

        } else {
            method = serverClass.getMethod(m.getName(),m.getParameterTypes());
        }

        if (method == null) {
            throw new EmsConnectException("Unsupported operation [" + m.getName() + "]");
        }

        ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
        try {
            roundTrips++;
//            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
            boolean isJBossConnection = (this.provider instanceof JBossConnectionProvider);
            if (isJBossConnection) {
                JBossConnectionProvider jbossProvider = (JBossConnectionProvider) this.provider;
                // See https://jira.jboss.org/jira/browse/JOPR-9 for an explanation of why we have to re-set the
                // PrincipalInfo prior to every JBoss JMX call.                
                //jbossProvider.resetPrincipalInfo();
                // Login via JAAS before making the call...
                jbossProvider.login();
            }
            Object returnValue;
            try {
                returnValue = method.invoke(this.remoteServer, args);
            } finally {
                if (isJBossConnection) {
                    JBossConnectionProvider jbossProvider = (JBossConnectionProvider) this.provider;
                    // Logout via JAAS before returning...
                    jbossProvider.logout();
                }
            }
            return returnValue;
        } catch(InvocationTargetException e) {
            failures++;
            if (e.getCause() != null) {
                Throwable t = e.getCause();
                if (t instanceof java.rmi.ConnectException) {
                    throw new EmsConnectException(t);
                } else if (t instanceof NoSuchObjectException) {
                    // This happens when the server comes back up and the stub is stale
                    // try to reconnect if this provider supports it (if it told the proxy what the provider was)
                    if (provider != null && !reconnecting) {
                        try {
                            log.info("Reestablishing RMI stub " + this.provider.getConnectionSettings().getServerUrl());
                            reconnecting = true;
                            provider.connect();
                            // Retry the request once
                            return this.invoke(proxy, m, args);
                        } catch(Exception f) {
                            log.warn("Unable to reestablish RMI stub to restarted server.",f);
                        } finally{ reconnecting = false; }
                    }
                    // The reconnect failed, throw the original exception
                    // If the retry fails, it will throw its own exception
                    throw new EmsConnectException(t);
                } else if (t instanceof java.io.IOException) {
                    throw new EmsConnectException(t);
                } else if (t instanceof NotSerializableException) {
                    throw new EmsUnsupportedTypeException("Value was not serializable " + t.getLocalizedMessage(),t);
                } else {
                    throw new EmsConnectException("Connection failure " + t.getLocalizedMessage(), t);
                }
            } else {
                throw e;
            }
        } catch (Exception e) {
View Full Code Here

    protected void doConnect() {

        Integer vmid = Integer.parseInt(this.connectionSettings.getServerUrl());
        LocalVirtualMachine lvm = LocalVMConnector.getAllMonitorableVirtualMachines().get(vmid);
        if (lvm == null) {
            throw new EmsConnectException("Couldn't find VirtualMachine with id " + vmid);
        }

        if (!lvm.isManageable()) {
            try {
                LocalVMConnector.startManagementAgent(lvm);
            } catch (IOException e) {
                throw new EmsConnectException("Couldn't make vm manageable through agent attachment",e);
            }
        }
        connectionSettings.setServerUrl(lvm.getConnectorAddress());

        super.doConnect();
View Full Code Here

                        entries.add(getCachedTempForFile(file,tempDir));
                    } else {
                        entries.add(file.toURI().toURL());
                    }
                } catch (MalformedURLException e) {
                    throw new EmsConnectException("Unable to read class path library url", e);
                }
            }
        }

        // Now load in the implementation jar
        // URL implURL = new URL(null, "deepjar://org-mc4j-ems-impl.jar", new Handler());
        URL implURL = storeImplToTemp("org-mc4j-ems-impl.jar", tempDir);

        entries.add(implURL);


        if (settings.getConnectionType() instanceof LocalVMTypeDescriptor) {
            // Need tools.jar if its not already loaded
            try {
                Class.forName("com.sun.tools.attach.VirtualMachine");
            } catch (ClassNotFoundException e) {
                // Try to load tools.jar
                File toolsJar = null;
                toolsJar = findToolsJarForHome(System.getProperty("java.home"));
                if (toolsJar == null) {
                    toolsJar = findToolsJarForHome(System.getProperty("env_java_home"));
                }

                if (toolsJar != null) {
                    try {
                        log.debug("Found tools.jar at " + toolsJar.getPath());
                        entries.add(toolsJar.toURI().toURL());
                    } catch (MalformedURLException e1) { /* Unnexpected */ }
                } else {
                    throw new EmsConnectException("Unable to find tools.jar. Add it to your classpath to use Sun local vm connections.");
                }
            }
        }


View Full Code Here

        if (settings.getClassPathEntries() != null) {
            for (File file : settings.getClassPathEntries()) {
                try {
                    entries.add(file.toURI().toURL());
                } catch (MalformedURLException e) {
                    throw new EmsConnectException("Unable to read class path library url", e);
                }
            }
        }

        // Now load in the implementation jar
View Full Code Here

TOP

Related Classes of org.mc4j.ems.connection.EmsConnectException

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.