code: protected void invokeGwtService(
          String serviceName,
          HttpServletRequest req,
          HttpServletResponse res,
          ServletConfig servletConfig) {
  
          CmsObject cms = null;
          try {
              // instantiate CMS context
              cms = initCmsObject(req, res);
              // instantiate GWT RPC service
              CmsGwtService rpcService = getGwtService(serviceName, servletConfig);
              // check permissions
              rpcService.checkPermissions(cms);
              // set runtime variables
              rpcService.setCms(cms);
              Object lock = req.getSession();
              if (lock == null) {
                  lock = new Object();
              }
              rpcService.service(req, res);
              // update the session info
              m_sessionManager.updateSessionInfo(cms, req);
          } catch (CmsRoleViolationException rv) {
              // don't log these into the error channel
              LOG.debug(rv.getLocalizedMessage(), rv);
              // error code not set - set "unauthorized error" (401)
              int status = HttpServletResponse.SC_UNAUTHORIZED;
              res.setStatus(status);
              try {
                  res.sendError(status, rv.toString());
              } catch (IOException e) {
                  // can be ignored
                  LOG.error(e.getLocalizedMessage(), e);
              }
          } catch (Throwable t) {
              // error code not set - set "internal server error" (500)
              LOG.error(t.getLocalizedMessage(), t);
              int status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
              res.setStatus(status);
              try {
                  res.sendError(status, t.toString());
              } catch (IOException e) {
                  // can be ignored
                  LOG.error(e.getLocalizedMessage(), e);
              }
          }
      }
docs: Invokes the GWT servlet from within OpenCms.<p>
  
  @param serviceName the GWT PRC service class name
  @param req the current servlet request
  @param res the current servlet response
  @param servletConfig the servlet configuration