Package com.google.opengse.configuration

Examples of com.google.opengse.configuration.WebAppConfigurationException


      WebAppConfiguration config)
      throws IllegalAccessException, WebAppConfigurationException,
      IOException, InstantiationException, ClassNotFoundException {
    String context = PropertiesUtil.getAliasedProperty(props, "context", null);
    if (context == null) {
      throw new WebAppConfigurationException(
          "No property named 'context' found");
    }
    File contextdir = PropertiesUtil.getFile(props, "contextdir");
    if (contextdir == null) {
      throw new WebAppConfigurationException(
          "No property named 'contextdir' found");
    }
    if (!contextdir.isDirectory()) {
      throw new WebAppConfigurationException(
          "'" + contextdir + "' is not a directory");
    }
    return create(props, context, contextdir, config);
  }
View Full Code Here


      InstantiationException, IllegalAccessException {
    if (ROOT.equals(contextname)) {
      return createWithRootWebapp(props, contextdir, config);
    }
    if (contextname.indexOf('/') >= 0) {
      throw new WebAppConfigurationException(
              "Found / in contextname '" + contextname + "'");
    }
    if (contextname.equals("")) {
      throw new WebAppConfigurationException(
              "Invalid context name. Use \"ROOT\" for the root context");
    }
    String uriPrefix = "/" + contextname;
    WebAppCollection webAppCollection = WebAppCollectionFactory.create(props);
    ServletContainerContext containerContext
View Full Code Here

      JasperHack ugly = (JasperHack) classLoader;
      URL[] classLoaderUrls = null;
      try {
        classLoaderUrls = ugly.getUrls();
      } catch (IOException ex) {
        throw new WebAppConfigurationException(ex);
      }
      URLClassLoader whatJasperExpects =
          new URLClassLoader(classLoaderUrls, classLoader);
      // uncomment the following line if Jasper has trouble finding TLDs etc.
      // (ie. if jstl does not work)
      // System.setProperty("java.class.path",
      // getClassPathFromClassLoader(whatJasperExpects));
      return whatJasperExpects;
    }
    throw new WebAppConfigurationException("I can't figure out"
        + " how to turn that class loader into something that Jasper needs");
  }
View Full Code Here

      if (obj instanceof HttpSessionListener) {
        sessionListeners.add((HttpSessionListener) obj);
        used = true;
      }
      if (!used) {
        throw new WebAppConfigurationException("Don't know what to do with '"
            + className + "'");
      }
    }
  }
View Full Code Here

  private void loadServletClasses(WebAppConfiguration wac)
      throws WebAppConfigurationException,
      IllegalAccessException, InstantiationException {
    for (WebAppServlet servletDef : wac.getServlets()) {
      if (servletDef.getServletName() == null) {
        throw new WebAppConfigurationException("Invalid servlet definition");
      }
      String servletClassName = servletDef.getServletClass();
      String jspFileName = servletDef.getJspFile();
      if (servletClassName == null && jspFileName == null) {
        throw new WebAppConfigurationException(
            "No servet-class or jsp-file for servlet '"
                + servletDef.getServletName() + "'");
      }
      if (servletClassName != null && jspFileName != null) {
        throw new WebAppConfigurationException("servlet '"
            + servletDef.getServletName()
            + "' has both servlet-class and jsp-file elements defined");
      }
      Object servletObject;
      // for jsp-file element, we use the generic JSP servlet class
      if (servletClassName == null) {
        servletClassName = getJspServletClassName(servletDef.getJspFile());
      }
      Class<?> servletClass = null;
      try {
        if (servletClassName != null) {
          servletClass = classLoader.loadClass(servletClassName);
        }
      } catch (ClassNotFoundException e) {
        LOGGER.log(Level.SEVERE, "Cannot find " + servletClassName);
      }
      if (servletClass != null) {
        servletObject = servletClass.newInstance();
        if (!(servletObject instanceof Servlet)) {
          throw new WebAppConfigurationException("'" + servletClassName
              + "' is not a Servlet");
        }
        manager.addServlet(servletDef, (Servlet) servletObject);
      }
    }
View Full Code Here

  private void loadFilterClasses(WebAppConfiguration wac)
      throws WebAppConfigurationException, ClassNotFoundException,
      IllegalAccessException, InstantiationException {
    for (WebAppFilter filterDef : wac.getFilters()) {
      if (filterDef.getFilterName() == null) {
        throw new WebAppConfigurationException("Invalid filter definition");
      }
      String filterClassName = filterDef.getFilterClass();
      if (filterClassName == null) {
        throw new WebAppConfigurationException(
            "No filter-class element defined");
      }
      Class<?> filterClass = classLoader.loadClass(filterClassName);
      Object filterObject = filterClass.newInstance();
      if (!(filterObject instanceof Filter)) {
        throw new WebAppConfigurationException("'" + filterClassName
            + "' is not a Filter");
      }
      manager.addFilter(filterDef, (Filter) filterObject);
    }
  }
View Full Code Here

    WebAppConfiguration globalConfig;
    try {
      globalConfig =
          GlobalConfigurationFactory.getGlobalConfiguration(classLoader);
    } catch (IOException e) {
      throw new WebAppConfigurationException("", e);
    }
    localConfig = WebAppConfigurationCombiner.combine(globalConfig, localConfig);
    return new WebAppImpl(uriPrefix, contextbase, classLoader, localConfig,
        containerContext);
  }
View Full Code Here

      contextParams
          .put(contextParam.getParamName(), contextParam.getParamValue());
    }
    String value = contextParams.get(OPENGSE_MAJORVERSION);
    if (value == null) {
      throw new WebAppConfigurationException(
          "No context-param named '" + OPENGSE_MAJORVERSION + "'");
    }
    majorVersion = Integer.parseInt(value);
    value = contextParams.get(OPENGSE_MINORVERSION);
    if (value == null) {
      throw new WebAppConfigurationException(
          "No context-param named '" + OPENGSE_MINORVERSION + "'");
    }
    minorVersion = Integer.parseInt(value);
    for (WebAppMimeMapping mapping : globalConfig.getMimeMappings()) {
      extensionToMimeType.put(mapping.getExtension(), mapping.getMimeType());
View Full Code Here

    checkDirectory(dir);
    File webinfdir = new File(dir, "WEB-INF");
    checkDirectory(webinfdir);
    File webxml = new File(webinfdir, "web.xml");
    if (!webxml.exists()) {
      throw new WebAppConfigurationException(
          "File '" + webxml + "' does not exist");
    }
    WebXmlParser parser = new WebXmlParserImpl2();
    FileReader reader;
    try {
      reader = new FileReader(webxml);
    } catch (FileNotFoundException e) {
      throw new WebAppConfigurationException(e);
    }
    // now we have a non-null reader.
    // pass it to the parser.
    try {
      return parser.parse(reader);
    } catch (IOException e) {
      throw new WebAppConfigurationException(e);
    } catch (SAXException e) {
      throw new WebAppConfigurationException(e);
    } finally {
      // always close the reader
      try {
        reader.close();
      } catch (IOException e) {
        throw new WebAppConfigurationException(e);
      }
    }
  }
View Full Code Here

   * if the directory does not exist or is not a directory
   */
  private static void checkDirectory(File dir)
      throws WebAppConfigurationException {
    if (!dir.exists()) {
      throw new WebAppConfigurationException(
          "Directory '" + dir + "' does not exist");
    }
    if (!dir.isDirectory()) {
      throw new WebAppConfigurationException(
          "'" + dir + "' is not a directory");
    }
  }
View Full Code Here

TOP

Related Classes of com.google.opengse.configuration.WebAppConfigurationException

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.