Example usage for java.lang ExceptionInInitializerError ExceptionInInitializerError

List of usage examples for java.lang ExceptionInInitializerError ExceptionInInitializerError

Introduction

In this page you can find the example usage for java.lang ExceptionInInitializerError ExceptionInInitializerError.

Prototype

public ExceptionInInitializerError(String s) 

Source Link

Document

Constructs an ExceptionInInitializerError with the specified detail message string.

Usage

From source file:org.viafirma.cliente.ViafirmaClientFactory.java

/**
 * Inicializa el cliente de viafirma. Este mdodo debe ser invocado por las
 * aplicaciones antes de utilizar cualquier otro mtodo.
 * /*from   w w w.  ja va  2s  . c  om*/
 * @param propiedades
 */
public synchronized static void init(Properties propiedades) {
    // -------------
    // INICIA la Autenticacin

    // Creo el conjunto de propiedades que se solicitaran al usuario
    // TODO permitir la configuracin del conjunto de propiedades
    // solicitadas
    Set<String> requestProperties = new HashSet<String>();
    // por defecto solicitamos email, nombre, apellidos y nif
    requestProperties.add(TypeRequest.EMAIL.getAlias());
    requestProperties.add(TypeRequest.FIRST_NAME.getAlias());
    requestProperties.add(TypeRequest.LAST_NAME.getAlias());
    requestProperties.add(TypeRequest.USER_NUMER_ID.getAlias());

    requestProperties.add(TypeRequest.OIDS.getAlias());
    requestProperties.add(TypeRequest.TYPE_CERTIFICATE.getAlias());
    requestProperties.add(TypeRequest.CA_NAME.getAlias());

    // recupero la url por defecto utilizada para realizar las
    // autenticacines sobre viafirma
    // simplificando el proceso de autenticacin OpenId.
    // TODO permitir la configuracin de servidores de confianza.
    // (Actualmente solo se permite como servidor de confianza el indicado
    // en este parametro de configuracin)
    String urlDefaultAuthenticationProvider = propiedades
            .getProperty(Constantes.PARAM_URL_DEFAULT_AUTHENTICATION_PROVIDER);
    if (urlDefaultAuthenticationProvider == null) {
        log.fatal("Parametro '" + Constantes.PARAM_URL_DEFAULT_AUTHENTICATION_PROVIDER
                + "' requerido para inicializar el cliente Viafirma.");
        throw new ExceptionInInitializerError(
                "Parametro '" + Constantes.PARAM_URL_DEFAULT_AUTHENTICATION_PROVIDER
                        + "' requerido para inicializar el cliente Viafirma.");
    }

    // -------------
    // INICIO de la configuracin de firma

    Set<String> requestFirmaProperties = new HashSet<String>();
    requestFirmaProperties.add(TypeRequest.SIGN_ID.getAlias());
    requestFirmaProperties.add(TypeRequest.SIGN_TIME_STAMP.getAlias());
    // La firma tambien contiene toda la informacin realacionada con el
    // firmante.
    requestFirmaProperties.addAll(requestProperties);

    // recupero el tipo de conector utilizado
    String urlRMI = propiedades.getProperty(Constantes.PARAM_URL_CONECTOR_FIRMA_RMI);
    // Check: Existe conector RMI/WS?
    if (urlRMI == null) {
        log.fatal("Parametro '" + Constantes.PARAM_URL_CONECTOR_FIRMA_RMI
                + "' requerido para inicializar el cliente Viafirma.");
        throw new ExceptionInInitializerError("Parametro '" + Constantes.PARAM_URL_CONECTOR_FIRMA_RMI
                + "' requerido para inicializar el cliente Viafirma.");
    }

    String urlDefaultSignProvider = propiedades.getProperty(Constantes.PARAM_URL_DEFAULT_SIGN_PROVIDER);
    // Check: Se ha indicado un proveedor de autenticacin Viafirma?
    if (urlDefaultSignProvider == null) {
        log.fatal("Parametro '" + Constantes.PARAM_URL_DEFAULT_SIGN_PROVIDER
                + "' requerido para inicializar el cliente Viafirma.");
        throw new ExceptionInInitializerError("Parametro '" + Constantes.PARAM_URL_DEFAULT_SIGN_PROVIDER
                + "' requerido para inicializar el cliente Viafirma.");
    }

    long tamanyoMaximoDocumento;

    String configMaxSize = propiedades.getProperty(Constantes.PARAM_MAX_SIZE);
    if (configMaxSize == null) {
        // Tamao por defecto
        tamanyoMaximoDocumento = Constantes.MAX_SIZE_UPLOAD_FILE;
    } else {
        tamanyoMaximoDocumento = Long.parseLong(configMaxSize);
    }

    // ----------------
    // Si todo esta OK. Creamos la instancia Singleton

    // recuperamos las instancias del manejador OpenId
    OpenIdHandler openIdHandler = OpenIdHandlerFactory.build(propiedades);
    // creamos una instancia del cliente
    singleton = new ViafirmaClient(tamanyoMaximoDocumento, openIdHandler, urlRMI,
            urlDefaultAuthenticationProvider, urlDefaultSignProvider, requestProperties,
            requestFirmaProperties);
}

From source file:ar.com.fdvs.dj.domain.builders.ReflectiveReportBuilder.java

/**
 * Takes the first item in the collection and adds a column for every property in that item.
 * @param _data the data collection. A not null and nor empty collection should be passed.
 *///from w  w  w. j a v  a  2s.c o  m
public ReflectiveReportBuilder(final Collection _data) {
    if (_data == null || _data.isEmpty()) {
        throw new IllegalArgumentException("Parameter _data is null or empty");
    }
    final Object item = _data.iterator().next();
    try {
        addProperties(PropertyUtils.getPropertyDescriptors(item));
    } catch (Exception ex) {
        LOGGER.error("", ex);
        throw new ExceptionInInitializerError(ex);
    }
}

From source file:org.webical.manager.impl.UserManagerImpl.java

public void afterPropertiesSet() throws Exception {
    if (userDao == null) {
        throw new ExceptionInInitializerError(USER_MANAGER_IMPL_NEEDS_USER_DAO);
    }// w ww.  jav a 2s  . c o m

    if (log.isDebugEnabled()) {
        log.debug("Class of UserDao set by Spring: " + userDao.getClass());
    }
}

From source file:org.webical.dao.hibernateImpl.SessionFactoryUtils.java

public void afterPropertiesSet() throws Exception {
    if (sessionFactory == null) {
        log.error(SessionFactoryUtils.class + " needs a " + SessionFactory.class);
        throw new ExceptionInInitializerError(SessionFactoryUtils.class + " needs a " + SessionFactory.class);
    }/* ww  w .  ja  v  a2s .c om*/
}

From source file:org.viafirma.util.ConfigUtil.java

/**
 * Recupera el conjunto de propiedades que utiliza la aplicacin.
 * @param context/*from  w ww. ja v  a 2  s  .c  om*/
 * @return
 */
public String readConfigProperty(String property) {
    Context initCtx;
    try {
        initCtx = new InitialContext();
        Context contextInit = (Context) initCtx.lookup("java:comp/env");
        // recuperamos ahora todos los parametros JNDI que estan en el raiz de la aplicacin 
        NamingEnumeration<NameClassPair> propiedadesJDNI = contextInit.list("");
        while (propiedadesJDNI.hasMoreElements()) {
            NameClassPair propiedad = propiedadesJDNI.nextElement();
            if (property.equalsIgnoreCase(propiedad.getName())) {
                // propiedad encontrada
                Object temp = contextInit.lookup(propiedad.getName());
                if (temp instanceof String) {
                    String valor = (String) temp;
                    return valor;
                }
            }
        }
    } catch (Exception e) {
        throw new ExceptionInInitializerError(
                "No se pueden recuperar los parametros de configuracin. JNDI parece no estar disponible."
                        + e.getMessage());
    }
    log.fatal("No se pueden recuperar el parametro de configuracin " + property
            + " de configuracin. JNDI parece no estar disponible.");
    return null;
}

From source file:edu.vt.vbi.patric.dao.HibernateHelper.java

public static void buildSessionFactory(String key, String path) {
    try {/*from  ww  w.  j  a  va  2  s  .  c  o m*/
        // Create the SessionFactory
        SessionFactory sessionFactory = new Configuration().configure(path).buildSessionFactory();
        sessionFactoryMap.put(key, sessionFactory);
    } catch (Throwable ex) {

        log.error("Initial SessionFactory creation failed.", ex);
        throw new ExceptionInInitializerError(ex);

    } // end of the try - catch block
}

From source file:org.apache.hadoop.yarn.server.sharedcachemanager.CleanerTask.java

/**
 * Creates a cleaner task based on the configuration. This is provided for
 * convenience./*from  www .j av  a  2  s  .  c om*/
 *
 * @param conf
 * @param store
 * @param metrics
 * @param cleanerTaskLock lock that ensures a serial execution of cleaner
 *                        task
 * @return an instance of a CleanerTask
 */
public static CleanerTask create(Configuration conf, SCMStore store, CleanerMetrics metrics,
        Lock cleanerTaskLock) {
    try {
        // get the root directory for the shared cache
        String location = conf.get(YarnConfiguration.SHARED_CACHE_ROOT,
                YarnConfiguration.DEFAULT_SHARED_CACHE_ROOT);

        long sleepTime = conf.getLong(YarnConfiguration.SCM_CLEANER_RESOURCE_SLEEP_MS,
                YarnConfiguration.DEFAULT_SCM_CLEANER_RESOURCE_SLEEP_MS);
        int nestedLevel = SharedCacheUtil.getCacheDepth(conf);
        FileSystem fs = FileSystem.get(conf);

        return new CleanerTask(location, sleepTime, nestedLevel, fs, store, metrics, cleanerTaskLock);
    } catch (IOException e) {
        LOG.error("Unable to obtain the filesystem for the cleaner service", e);
        throw new ExceptionInInitializerError(e);
    }
}

From source file:org.glite.security.voms.admin.persistence.HibernateFactory.java

public static synchronized void initialize(Properties databaseProperties) {

    Validate.notNull(databaseProperties);

    if (sessionFactory != null) {
        throw new VOMSDatabaseException("Hibernate session factory already initialized!");
    }/*from  ww w  .j a va 2  s.c  o m*/

    try {

        Configuration hibernateConf = new Configuration();
        hibernateConf.addProperties(databaseProperties);

        sessionFactory = hibernateConf.configure().buildSessionFactory();

    } catch (HibernateException e) {

        log.error("Hibernate session factory creation failed!", e);
        throw new ExceptionInInitializerError(e);

    }

}

From source file:org.webical.settings.ApplicationSettingsFactory.java

public void afterPropertiesSet() throws Exception {
    if (applicationSettingsManager == null) {
        log.fatal(ApplicationSettingsFactory.class + " needs a " + ApplicationSettingsManager.class);
        throw new ExceptionInInitializerError(
                ApplicationSettingsFactory.class + " needs a " + ApplicationSettingsManager.class);
    }/*from w w  w  .j av  a 2 s .c om*/

    instance = this;
}

From source file:org.fao.geonet.arcgis.ArcSDEJdbcConnection.java

/**
 *
 *
 * @param connectionString An example of server string in case of Oracle
 *                         is: "jdbc:oracle:thin:@84.123.79.19:1521:orcl".
 * @param username the username to connect to the database.
 * @param password the password to connect to the database.
 *//* w ww.j ava2  s  .  c o m*/
public ArcSDEJdbcConnection(String driverName, String connectionString, String username, String password) {

    try {
        Log.debug(ARCSDE_LOG_MODULE_NAME, "Getting ArcSDE connection (via JDBC)");

        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName(driverName);
        dataSource.setUrl(connectionString);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        // Test the connection config getting a connection and closing it.
        dataSource.getConnection().close();

        jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
    } catch (SQLException x) {
        Log.error(ARCSDE_LOG_MODULE_NAME, "Error getting ArcSDE connection (via JDBC)", x);

        throw new ExceptionInInitializerError(new ArcSDEConnectionException(
                "Exception in ArcSDEConnection using JDBC: can not connect to the database", x));
    }
}