@Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent messageEvent) throws JBNodeException {

        if(!(messageEvent.getMessage() instanceof Request)) {
            throw new JBNodeException("Message contains no 'Request' object.");
        }

        Request request = (Request)messageEvent.getMessage();

        Object service = getService(request.getService());
        Method method = getServiceMethod(request.getService(), request.getMethod());

        if (service == null || method == null) {
            logger.log(Level.WARNING, "Service '" + request.getService() + "' or method " +
                "'" + request.getService() + "." + request.getMethod() + "' is not configured.");

            throw new JBNodeException("Protocol error: invalid header (3).");
        }

        byte[] resultBody;
        boolean executionFailed = false;
        
        try {
            try {
                resultBody = executeMethod(request.getService(), request.getMethod(), service, method, request.getData());
            } catch (IllegalAccessException e) {
                throw e;
            } catch (InvocationTargetException e) {
                if (e.getCause() != null) {
                    throw e.getCause();
                } else {
                    throw new Exception("Unknown exception thrown by service method.");
                }
            }
        } catch (Throwable t) {
            if (isDebugMode()) {
                logger.log(Level.SEVERE, "Exception thrown " + "'" + request.getService() +
                        "." + request.getMethod() + "' " + t.getMessage(), t);
            } else {
                logger.log(Level.SEVERE, "Exception thrown " + "'" + request.getService() +
                        "." + request.getMethod() + "' " + t.getMessage());
            }

            executionFailed = true;
            resultBody = t.getMessage().getBytes();
        }
        
        messageEvent.getChannel().write(new Response(executionFailed, resultBody));
        
    }