public MBeanServerConnection connect() throws MBeanServerConnectionException {
		if (vmd == null) {
			throw new MBeanServerConnectionException(ReturnCode.ServerNotFound);
		}

		try {
			VirtualMachine vm = VirtualMachine.attach(vmd);

			String connectorAddress = getConnectorAddress(vm);
			if (connectorAddress == null) {
				throw new MBeanServerConnectionException(ReturnCode.ServerHasNoConnectorAddress);
			}

			JMXServiceURL url = new JMXServiceURL(connectorAddress);
			jmxCon = JMXConnectorFactory.connect(url);
			mbc = jmxCon.getMBeanServerConnection();

		} catch (AttachNotSupportedException ansx) {
			LOG.severe(ReturnCode.ServerAttachFailed.getMessage() + ": "
					+ ExceptionToStacktraceString.toStacktrace(ansx));
			throw new MBeanServerConnectionException(ReturnCode.ServerAttachFailed);

		} catch (Exception iox) {
			LOG.severe(ReturnCode.ServerCommunicationError.getMessage() + ": "
					+ ExceptionToStacktraceString.toStacktrace(iox));
			throw new MBeanServerConnectionException(iox, ReturnCode.ServerCommunicationError);
		}

		return mbc;
	}