Package javax.servlet

Examples of javax.servlet.UnavailableException


        try {
            IBindingFactory factory = BindingDirectory.getFactory(ServiceDefinition.class);
            ctx = factory.createUnmarshallingContext();
        } catch (JiBXException e) {
            logger.error("Unable to initialize unmarshalling", e);
            throw new UnavailableException("Unable to initialize unmarshalling. \n" + getErrorDetails(e));
        }

        // read and validate service definitions
        String path = null;
        String file = null;
        try {

            // loop through all initialization parameter pairs
            HashMap map = new HashMap();
            Enumeration pnum = servlet.getInitParameterNames();
            ServletContext serv = servlet.getServletContext();
            while (pnum.hasMoreElements()) {

                // parameter name is path and value is service definition file
                path = (String) pnum.nextElement();
                file = "/WEB-INF/" + servlet.getInitParameter(path);
                InputStream is = null;
                try {
                    is = serv.getResourceAsStream(file);
                    if (is == null) {
                        logger.error("Service definition not found for service " + path + " at " + file);
                        throw new UnavailableException("Service definition not found for service " + path + " at "
                            + file + ". Check configuration of servlet " + servlet.getServletName()
                            + " in WEB-INF/web.xml.");
                    }
                    ServiceDefinition sdef = (ServiceDefinition) ctx.unmarshalDocument(is, null);
                    if (!path.startsWith("/")) {
                        path = "/" + path;
                    }
                    map.put(path, sdef);

                } finally {
                    if (is != null) {
                        try {
                            is.close();
                        } catch (IOException ignore) {
                        }
                    }
                }
            }

            // return map with all services entered
            return map;

        } catch (JiBXException e) {
            logger.error("Error reading service definition " + file + " for service " + path, e);
            throw new UnavailableException("Error reading service definition " + file + " for service " + path + ".\n"
                + getErrorDetails(e));
        }
    }
View Full Code Here


    try {
      java.io.InputStream propertiesInputStream = servlet.getServletContext().getResourceAsStream("/WEB-INF/classes/CentraView.properties");
      if (propertiesInputStream != null) {
        inProps.load(propertiesInputStream);
      } else {
        throw new UnavailableException("Cannot create CentraView.properties InputStream.");
      }
      initCtx = new InitialContext(inProps);
    } catch (java.io.IOException e1) {
      // catch the IOException if the properties file can't be found or read.
      logger.error("[init] Cannot read/find CentraView.properties.", e1);
      throw new UnavailableException("Cannot load CentraView.properties file.");
    } catch (NamingException e) {
      logger.error("[init] Failed getting InitialContext.", e);
      throw new UnavailableException("Cannot get Initial Context");
    }
    String dataSource = inProps.getProperty("centraview.datasource");

    // put the info in the singleton
    settings.setInitCtx(initCtx);
View Full Code Here

    public void init() throws ServletException {
        String errorTime = getServletConfig().getInitParameter("errorTime");
        this.errorAtInit = ((errorTime == null) || errorTime.equals("init"));
        if (this.errorAtInit)
            throw new UnavailableException(
                    "Error thrown deliberately during init");
    }
View Full Code Here

    }

    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        if (!this.errorAtInit)
            throw new UnavailableException(
                    "Error thrown deliberately during get");

        Writer out = response.getWriter();
        out
                .write("This should not be shown, because we've thrown unavailable exceptions");
View Full Code Here

            // The follow error message is not retrieved from internal message
            // resources as they may not have been able to have been
            // initialized
            log.error("Failed to initialise core.", t);
            throw new UnavailableException(t.getMessage());
        } finally {
            pastInitialisation = true;
        }
    }
View Full Code Here

            storage=(Storage)cons.newInstance(sargs);

        } catch(InvocationTargetException e) {
            log.fatal("Could not initialize. Exiting now!  Nested exc:",
                    e.getTargetException());
            throw new UnavailableException(e.getMessage());
        } catch(Exception e) {
            log.fatal("Could not initialize. Exiting now!", e);
            throw new UnavailableException(e.getMessage());
        }
    }
View Full Code Here

            sysdata=new XMLSystemData(root,cs);
            log.debug( "SimpleStorage: WebMail configuration loaded.");
        } catch(Exception ex) {
            log.error("SimpleStorage: Failed to load WebMail configuration file",
                    ex);
            throw new UnavailableException(ex.getMessage());
        }
    }
View Full Code Here

        throws ServletException,
               UnavailableException,
               IOException
    {
        if (_class==null)
            throw new UnavailableException("Servlet Not Initialized");
       
        Servlet servlet = getServletInstance();
        synchronized(this)
        {
            if (!isAvailable() || !isSetInitOrder())
                servlet=getServlet();
            if (servlet==null)
                throw new UnavailableException("Could not instantiate "+_class);
        }
       
        // Service the request
        boolean servlet_error=true;
       
View Full Code Here

   * Creates a sub invocation, handing unmapped URLs and stopped webApps.
   */
  private WebApp buildSubInvocation(Invocation invocation)
  {
    if (! _lifecycle.waitForActive(_startWaitTime)) {
      UnavailableException e;
      e = new UnavailableException(invocation.getURI());

      FilterChain chain = new ExceptionFilterChain(e);
      invocation.setFilterChain(chain);
      invocation.setDependency(AlwaysModified.create());
      return null;
    }

    WebAppController appController = getWebAppController(invocation);

    if (appController == null) {
      String url = invocation.getURI();

      FileNotFoundException e = new FileNotFoundException(url);

      FilterChain chain = new ExceptionFilterChain(e);
      invocation.setFilterChain(chain);
      invocation.setDependency(AlwaysModified.create());
      return null;
    }

    WebApp webApp = appController.subrequest();

    if (webApp == null) {
      UnavailableException e;
      e = new UnavailableException(invocation.getURI());

      FilterChain chain = new ExceptionFilterChain(e);
      invocation.setFilterChain(chain);
      invocation.setDependency(AlwaysModified.create());
      return null;
View Full Code Here

    _initException = exn;

    _nextInitTime = Long.MAX_VALUE / 2;

    if (exn instanceof UnavailableException) {
      UnavailableException unExn = (UnavailableException) exn;

      if (! unExn.isPermanent())
        _nextInitTime = (Alarm.getCurrentTime() +
                         1000L * unExn.getUnavailableSeconds());
    }
  }
View Full Code Here

TOP

Related Classes of javax.servlet.UnavailableException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.