Search in sources :

Example 61 with UnavailableException

use of javax.servlet.UnavailableException in project sonarqube by SonarSource.

the class TestActionServlet method testProcessForwardConfigClassNoExtends.

/**
     * Make sure processForwardConfigClass() returns what it was given if the
     * forward passed to it doesn't extend anything.
     */
public void testProcessForwardConfigClassNoExtends() throws Exception {
    moduleConfig.addForwardConfig(baseForward);
    ForwardConfig result = null;
    try {
        result = actionServlet.processForwardConfigClass(baseForward, moduleConfig, null);
    } catch (UnavailableException e) {
        fail("An exception should not be thrown when there's nothing to do");
    }
    assertSame("Result should be the same as the input.", baseForward, result);
}
Also used : UnavailableException(javax.servlet.UnavailableException) ForwardConfig(org.apache.struts.config.ForwardConfig)

Example 62 with UnavailableException

use of javax.servlet.UnavailableException in project sonarqube by SonarSource.

the class TestActionServlet method notestProcessExceptionConfigClassError.

/**
     * Make sure the code throws the correct exception when it can't create an
     * instance of the base config's custom class.
     */
public void notestProcessExceptionConfigClassError() throws Exception {
    ExceptionConfig customBase = new CustomExceptionConfigArg("java.lang.NullPointerException");
    moduleConfig.addExceptionConfig(customBase);
    ExceptionConfig customSub = new ExceptionConfig();
    customSub.setType("java.lang.IllegalStateException");
    customSub.setExtends("java.lang.NullPointerException");
    moduleConfig.addExceptionConfig(customSub);
    try {
        actionServlet.processExceptionConfigClass(customSub, moduleConfig, null);
        fail("Exception should be thrown");
    } catch (UnavailableException e) {
    // success
    } catch (Exception e) {
        fail("Unexpected exception thrown.");
    }
}
Also used : ExceptionConfig(org.apache.struts.config.ExceptionConfig) UnavailableException(javax.servlet.UnavailableException) ServletException(javax.servlet.ServletException) UnavailableException(javax.servlet.UnavailableException)

Example 63 with UnavailableException

use of javax.servlet.UnavailableException in project head by mifos.

the class EnumPlugin method init.

@Override
public void init(ActionServlet actionServlet, ModuleConfig config) throws ServletException {
    try {
        ServletContext servletContext = actionServlet.getServletContext();
        List<String> enumFileNameList = getEnumFileNames();
        List<Class> enumClassList = buildClasses(enumFileNameList);
        EnumMapBuilder constantBuilder = EnumMapBuilder.getInstance();
        for (Class cl : enumClassList) {
            servletContext.setAttribute(getName(cl), constantBuilder.buildMap(cl));
        }
    } catch (Exception e) {
        UnavailableException ue = new UnavailableException(e.getMessage(), 0);
        ue.initCause(e);
        throw ue;
    }
}
Also used : UnavailableException(javax.servlet.UnavailableException) ServletContext(javax.servlet.ServletContext) ServletException(javax.servlet.ServletException) UnavailableException(javax.servlet.UnavailableException) ConstantsNotLoadedException(org.mifos.framework.exceptions.ConstantsNotLoadedException) EnumsNotLoadedException(org.mifos.framework.exceptions.EnumsNotLoadedException)

Example 64 with UnavailableException

use of javax.servlet.UnavailableException in project head by mifos.

the class ConstPlugin method init.

@Override
public void init(ActionServlet actionServlet, ModuleConfig config) throws ServletException {
    try {
        ServletContext servletContext = actionServlet.getServletContext();
        List<String> constantFileNameList = getConstantFileNames();
        List<Class> constantClassList = buildClasses(constantFileNameList);
        ConstantMapBuilder constantBuilder = ConstantMapBuilder.getInstance();
        for (Class cl : constantClassList) {
            servletContext.setAttribute(getName(cl), constantBuilder.buildMap(cl));
        }
    } catch (Exception e) {
        UnavailableException ue = new UnavailableException(e.getMessage(), 0);
        ue.initCause(e);
        throw ue;
    }
}
Also used : UnavailableException(javax.servlet.UnavailableException) ServletContext(javax.servlet.ServletContext) ServletException(javax.servlet.ServletException) UnavailableException(javax.servlet.UnavailableException) ConstantsNotLoadedException(org.mifos.framework.exceptions.ConstantsNotLoadedException)

Example 65 with UnavailableException

use of javax.servlet.UnavailableException in project opennms by OpenNMS.

the class BaseAcknowledgeServlet method init.

/**
	 * Looks up the <code>dispath.success</code> parameter in the servlet's
	 * config. If not present, this servlet will throw an exception so it will
	 * be marked unavailable.
	 *
	 * @throws javax.servlet.ServletException if any.
	 */
@Override
public void init() throws ServletException {
    ServletConfig config = this.getServletConfig();
    this.redirectSuccess = config.getInitParameter("redirect.success");
    if (this.redirectSuccess == null) {
        throw new UnavailableException("Require a redirect.success init parameter.");
    }
}
Also used : ServletConfig(javax.servlet.ServletConfig) UnavailableException(javax.servlet.UnavailableException)

Aggregations

UnavailableException (javax.servlet.UnavailableException)95 ServletException (javax.servlet.ServletException)54 IOException (java.io.IOException)33 MalformedURLException (java.net.MalformedURLException)15 SAXException (org.xml.sax.SAXException)14 MissingResourceException (java.util.MissingResourceException)12 ExceptionConfig (org.apache.struts.config.ExceptionConfig)10 URL (java.net.URL)8 Servlet (javax.servlet.Servlet)8 FormBeanConfig (org.apache.struts.config.FormBeanConfig)8 ForwardConfig (org.apache.struts.config.ForwardConfig)8 ServletContext (javax.servlet.ServletContext)6 ActionConfig (org.apache.struts.config.ActionConfig)6 ArrayList (java.util.ArrayList)5 ServletConfig (javax.servlet.ServletConfig)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 ClientAbortException (org.apache.catalina.connector.ClientAbortException)4 InvalidConfigException (com.revolsys.ui.web.config.InvalidConfigException)3 XmlConfigLoader (com.revolsys.ui.web.config.XmlConfigLoader)3 BufferedImage (java.awt.image.BufferedImage)3