Example usage for javax.servlet ServletException getMessage

List of usage examples for javax.servlet ServletException getMessage

Introduction

In this page you can find the example usage for javax.servlet ServletException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.megatome.frame2.front.TestMissingFileUpload.java

private HttpFrontController initializeServlet() {
    HttpFrontController servlet = getServlet();
    try {/*w  ww  .  j  a v  a  2 s.  com*/
        servlet.init();
    } catch (ServletException e) {
        fail("Unexpected ServletException: " + e.getMessage()); //$NON-NLS-1$
    }
    Configuration config = getServlet().getConfiguration();

    assertNotNull(config);

    return servlet;
}

From source file:eu.eidas.node.connector.ColleagueResponseServlet.java

/**
 * Executes {@link eu.eidas.node.auth.connector.AUCONNECTOR#getAuthenticationResponse} and prepares the citizen to
 * be redirected back to the SP./*from  w w w  .  j  a va2s.c o m*/
 *
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    try {
        // Prevent cookies from being accessed through client-side script with renew of session.
        setHTTPOnlyHeaderToSession(false, request, response);
        SessionHolder.setId(request.getSession());
        request.getSession().setAttribute(EidasParameterKeys.SAML_PHASE.toString(),
                EIDASValues.EIDAS_CONNECTOR_RESPONSE);

        // Obtaining the assertion consumer url from SPRING context
        ConnectorControllerService controllerService = (ConnectorControllerService) getApplicationContext()
                .getBean(NodeBeanNames.EIDAS_CONNECTOR_CONTROLLER.toString());
        LOG.trace("ConnectorControllerService {}", controllerService);

        // Obtains the parameters from httpRequest
        WebRequest webRequest = new IncomingRequest(request);

        String samlResponseFromProxyService = webRequest
                .getEncodedLastParameterValue(EidasParameterKeys.SAML_RESPONSE);
        if (null == samlResponseFromProxyService) {
            samlResponseFromProxyService = StringUtils.EMPTY;
        }

        // Validating the only HTTP parameter: SAMLResponse or samlArtifact.
        if (!validateParameterAndIsNormalSAMLResponse(samlResponseFromProxyService)) {
            LOG.info("ERROR : Cannot validate parameter or abnormal SAML response");
        }
        LOG.trace("Normal SAML response decoding");
        AuthenticationExchange authenticationExchange = controllerService.getConnectorService()
                .getAuthenticationResponse(webRequest);

        // Build the LightResponse
        LightResponse lightResponse = LightResponse.builder(authenticationExchange.getConnectorResponse())
                .build();
        // Call the specific module
        sendResponse(lightResponse, request, response, controllerService);

    } catch (ServletException se) {
        LOG.info("BUSINESS EXCEPTION : ServletException", se.getMessage());
        LOG.debug("BUSINESS EXCEPTION : ServletException", se);
        throw se;
    }
}

From source file:at.sciencesoft.osgi.OXAdminGuiServletActivator.java

@Override
protected void handleAvailability(final Class<?> clazz) {
    /*//from   w w w.  ja va 2 s .c  o  m
     * Add available service to registry
     */
    LOG.info("Going to register Peter's OX Admin GUI Servlet");
    OXAdminGuiServletServiceRegistry.getServiceRegistry().addService(clazz, getService(clazz));
    if (OXAdminGuiServletServiceRegistry.getServiceRegistry().size() == NEEDED_SERVICES.length) {
        /*
         * All needed services available: Register servlet
         */
        try {
            registerServlet();
        } catch (final ServletException e) {
            LOG.error(e.getMessage(), e);
        } catch (final NamespaceException e) {
            LOG.error(e.getMessage(), e);
        }
    }
}

From source file:gov.nih.nci.cabig.caaers.web.rule.notification.ReportDefinitionAjaxFacade.java

private String getOutputFromJsp(String jspResource) {
    String html = "Error in rendering...";
    try {/*  w w w. j  ava  2  s .  c o m*/
        html = WebContextFactory.get().forwardToString(jspResource);
    } catch (ServletException e) {
        throw new CaaersSystemException(e.getMessage(), e);
    } catch (IOException e) {
        throw new CaaersSystemException(e.getMessage(), e);
    }
    return html;
}

From source file:gov.nih.nci.cabig.caaers.web.participant.CreateParticipantAjaxFacade.java

/**
 * Build the HTML output for the AJAX call
 * *//*  ww w  .ja va2 s  .  c  o  m*/
private String getOutputFromJsp(final String jspResource) {
    String html = "Error in rendering...";
    try {
        html = WebContextFactory.get().forwardToString(jspResource);
    } catch (ServletException e) {
        throw new CaaersSystemException(e.getMessage(), e);
    } catch (IOException e) {
        throw new CaaersSystemException(e.getMessage(), e);
    }
    return html;
}

From source file:org.eurekastreams.commons.server.ActionRPCServiceImpl.java

/**
 * As a servlet, this class' init() method is called automatically. This is how we get context.
 * //from w w w. j a  v a  2  s.com
 * @param config
 *            the configuration describing the run-time environment.
 */
@Override
public void init(final ServletConfig config) {
    log.info("ActionRPCServiceImpl::init()");

    try {
        super.init(config);
    } catch (ServletException e) {
        log.error("Caught a ServletException during initialization: " + e.getMessage(), e);
    }

    springContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());

    actionExecutorFactory = (ActionExecutorFactory) springContext.getBean("actionExecutorFactory");
}

From source file:de.micromata.genome.gwiki.web.tags.GWikiIncludeTag.java

@Override
public int doEndTag() throws JspException {

    GWikiElement el = null;/* w w  w. j  a  va2  s .  c o  m*/
    GWikiArtefakt<?> art = null;
    GWikiContext ctx = null;
    GWikiWeb wikiWeb = GWikiWeb.getWiki();
    try {
        if (StringUtils.isEmpty(pageId) == true) {
            ctx = (GWikiContext) pageContext.getAttribute("wikiContext");
            if (ctx == null) {
                throw new RuntimeException("no wikiContext set in GWikiInclude tag with no given pageId");
            }
            el = ctx.getCurrentElement();
            art = getPart(el);
        } else {
            el = wikiWeb.getElement(pageId);
        }
        if (part != null) {
            art = el.getPart(part);
        }
        if (StringUtils.isNotEmpty(chunk) == true) {
            if (part == null && art == null) {
                art = getPart(el);
            }
            if ((art instanceof GWikiWikiPageArtefakt) == false) {
                throw new RuntimeException("Including section, Part is not wiki page");
            }
            GWikiWikiPageArtefakt wpa = (GWikiWikiPageArtefakt) art;
            if (ctx != null) {
                wpa.renderChunk(ctx, chunk);
            } else {
                GWikiStandaloneContext sactx = GWikiStandaloneContext.create();
                // GWikiContext ctx = new GWikiContext(wikiWeb, servlet, request, response)
                wpa.renderChunk(sactx, chunk);
                String outt = sactx.getOutString();
                pageContext.getOut().append(outt);

            }
        } else {
            if (art == null) {
                pageContext.include(wikiWeb.getServletPath() + "/" + pageId);
            } else {
                if ((art instanceof GWikiExecutableArtefakt<?>) == false) {
                    throw new RuntimeException(
                            "Cannot render part because not a executable: " + art + " in page " + pageId);
                }
                GWikiExecutableArtefakt<?> exec = (GWikiExecutableArtefakt<?>) art;
                GWikiStandaloneContext sactx = GWikiStandaloneContext.create();
                exec.render(sactx);
                String outt = sactx.getOutString();
                pageContext.getOut().append(outt);
            }
        }
    } catch (ServletException e) {
        throw new JspException("Servlet exception wile rendering gwiki:include: " + e.getMessage(), e);
    } catch (IOException e) {
        throw new JspException("IO error wile rendering gwiki:include: " + e.getMessage(), e);
    }
    return super.doEndTag();
}

From source file:com.vcredit.lrh.microservice.gateway.api.redis.SecurityHandlerRedis.java

public void process(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException {
    HttpServletResponse httpServletResponse = (HttpServletResponse) response;
    HttpServletRequest servletRequest = (HttpServletRequest) request;
    String token = "";
    String clientVersion = "";
    String deviceType = "";
    //header??/*from w  ww .j av  a2 s. c  om*/
    String base64Str = servletRequest.getHeader("clientHeader");
    if (!StringUtils.isEmpty(base64Str)) {
        String headerJsonStr = Base64Utils.getFromBase64(base64Str);
        JSONObject headerJson = JSONObject.parseObject(headerJsonStr);
        token = headerJson.getString("accessToken");
        try {
            clientVersion = headerJson.getString("apiClientVersion");
            deviceType = headerJson.getString("deviceType");
            //add by xuhui 20170406
            if (!StringUtils.isEmpty(clientVersion)) {
                if ("iOS".equals(deviceType) && iosAppVertion.compareTo(clientVersion) > 0) {
                    JSONObject jSONObject = new JSONObject();
                    PrintWriter pw = httpServletResponse.getWriter();
                    jSONObject.put("type", LrhConstants.ErrorCodeTypeEnum.FORCEUPDATE.getCode());
                    jSONObject.put("success", true);
                    jSONObject.put("code", 201);
                    Map<String, Object> map = new HashMap();
                    //?
                    map.put("updateUrl", "");
                    map.put("updateInfo", "");
                    map.put("updateTargetVersion", iosAppVertion);
                    map.put("forceUpdate", true);
                    map.put("appType", "iOS");
                    jSONObject.put("data", map);
                    pw.write(jSONObject.toJSONString());
                    pw.flush();
                }
                if ("android".equals(deviceType) && andriodAppVersion.compareTo(clientVersion) > 0) {
                    JSONObject jSONObject = new JSONObject();
                    PrintWriter pw = httpServletResponse.getWriter();
                    jSONObject.put("type", LrhConstants.ErrorCodeTypeEnum.FORCEUPDATE.getCode());
                    jSONObject.put("success", true);
                    jSONObject.put("code", 201);
                    Map<String, Object> map = new HashMap();
                    //?
                    map.put("updateUrl",
                            "http://10.154.40.42:7777/lrh_apk_android_20_v0.0.1/vcredit_lrh_debug_v0.0.2_2017_0421_1041_Vcredit_TecentQQ.apk");
                    map.put("updateInfo", "");
                    map.put("updateTargetVersion", andriodAppVersion);
                    map.put("forceUpdate", true);
                    map.put("appType", "android");
                    jSONObject.put("data", map);
                    pw.write(jSONObject.toJSONString());
                    pw.flush();
                }
            }
        } catch (Exception e) {
        }
    }

    //        String token = request.getParameter("accessToken") == null ? accessTokenFromHeader : request.getParameter("accessToken");
    if (StringUtils.isEmpty(token)) {
        token = servletRequest.getSession().getId().toUpperCase();
    }
    String openId = request.getParameter("open_id");
    httpServletResponse.setHeader("Content-Type", "application/json");
    try {
        if (servletRequest.getServletPath().equals(securityProperties.getLoginSecurityUrl())) {
            chain.doFilter(request, response);
        } else if (servletRequest.getServletPath().equals("/favicon.ico")) {
            chain.doFilter(request, response);
            //                PrintWriter pw = httpServletResponse.getWriter();
            //                pw.write("favicon.ico");
            //                pw.flush();
        } else if (openId == null && null == token) {
            unauthorizedRequest(httpServletResponse);
        } else if (needAuthentication(servletRequest.getServletPath())) {
            //                JSONObject currentUser = securityService.getUserByAccessToken(token);
            JSONObject currentUser = redisTemplate.get(RedisCacheKeys.ACCOUNT_CACHE_TOKEN + token,
                    JSONObject.class);
            if (null == currentUser) {
                unauthorizedRequest(httpServletResponse);
            } else {
                chain.doFilter(request, response);
            }
        } else {
            chain.doFilter(request, response);
        }
    } catch (ServletException ex) {
        logger.error(ex.getMessage(), ex);
        serverErrorRequest(httpServletResponse);
    }
}

From source file:org.keycloak.testsuite.arquillian.undertow.UndertowAppServer.java

@Override
public void undeploy(Archive<?> archive) throws DeploymentException {
    log.info("Undeploying archive " + archive.getName());
    Field containerField = Reflections.findDeclaredField(UndertowJaxrsServer.class, "container");
    Reflections.setAccessible(containerField);
    ServletContainer container = (ServletContainer) Reflections.getFieldValue(containerField, undertow);

    DeploymentManager deploymentMgr = container.getDeployment(archive.getName());
    if (deploymentMgr != null) {
        DeploymentInfo deployment = deploymentMgr.getDeployment().getDeploymentInfo();

        try {//from ww w.j a v a2 s. c  om
            deploymentMgr.stop();
        } catch (ServletException se) {
            throw new DeploymentException(se.getMessage(), se);
        }

        deploymentMgr.undeploy();

        Field rootField = Reflections.findDeclaredField(UndertowJaxrsServer.class, "root");
        Reflections.setAccessible(rootField);
        PathHandler root = (PathHandler) Reflections.getFieldValue(rootField, undertow);

        String path = deployedArchivesToContextPath.get(archive.getName());
        root.removePrefixPath(path);

        container.removeDeployment(deployment);
    } else {
        log.warnf("Deployment '%s' not found", archive.getName());
    }
}

From source file:net.unicon.cas.chalkwire.servlet.CasChalkWireHttpServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    try {//w  w  w .j av  a2 s. c om
        if (req.getRemoteUser() == null)
            throw new ServletException("User is not authenticated. Check the CAS client log files for details");

        String userId = req.getUserPrincipal().getName();

        if (logger.isDebugEnabled())
            logger.debug("Received login request from user " + userId);

        final String URL = buildSingleSignOnTokenRequestUrl(userId);

        if (logger.isDebugEnabled()) {
            logger.debug("Requesing security token from ePortfolio Connect Server");
            logger.debug("Requesting url:" + URL);
        }

        /*
         * Send the single sign-on request url to server and parse the response.
         */
        ChalkWireResponseParser parser = new ChalkWireResponseParser(URL);

        if (logger.isDebugEnabled())
            logger.debug("Response is success:" + parser.isSuccess());

        if (parser.isSuccess()) {

            if (logger.isDebugEnabled())
                logger.debug("url: " + parser.getURL());

            if (logger.isDebugEnabled())
                logger.debug("token: " + parser.getToken());

            String finalURL = buildFinalSingleSignOnUrl(userId, parser);

            if (logger.isDebugEnabled())
                logger.debug("Single sign-on URL:" + finalURL);

            parser = new ChalkWireResponseParser(finalURL);

            if (!parser.isSuccess())
                throw new ServletException(parser.getMessage());

            resp.sendRedirect(finalURL);

        } else
            throw new ServletException(parser.getMessage());

    } catch (ServletException e) {
        logger.error(e.getMessage(), e);

        String casServerLoginUrl = getServletContext().getInitParameter("casServerLoginUrl");

        String service = req.getRequestURL().toString();
        casServerLoginUrl += "login?renew=true&service=" + URLEncoder.encode(service, ENCODING_TYPE);

        RequestDispatcher dispatcher = getServletContext()
                .getRequestDispatcher("/WEB-INF/view/jsp/chalkWireError.jsp");
        req.setAttribute("exception", e);

        if (logger.isDebugEnabled())
            logger.debug("Constructed CAS login url:" + casServerLoginUrl);

        req.setAttribute("loginUrl", casServerLoginUrl);
        dispatcher.forward(req, resp);

    }

}