Example usage for java.lang InstantiationException getMessage

List of usage examples for java.lang InstantiationException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.nuxeo.ecm.platform.login.LoginPluginRegistry.java

private void registerPlugin(LoginPluginDescriptor pluginExtension) {
    Boolean enabled = pluginExtension.getEnabled();
    Class<LoginPlugin> className = pluginExtension.getClassName();
    String pluginName = pluginExtension.getPluginName();

    if (loginPluginStack.containsKey(pluginName)) {
        // merge/* w  ww .  j a va 2s .c o m*/
        LoginPlugin oldLoginPlugin = loginPluginStack.get(pluginName);
        LoginPluginDescriptor oldLoginPluginDescriptor = pluginDescriptorStack.get(pluginName);

        Map<String, String> mergedParams = oldLoginPluginDescriptor.getParameters();
        mergedParams.putAll(pluginExtension.getParameters());

        oldLoginPlugin.setParameters(mergedParams);
        if (!oldLoginPlugin.initLoginModule()) {
            oldLoginPluginDescriptor.setInitialized(false);
            log.warn("Unable to initialize LoginPlugin for class " + className.getName());
        } else {
            oldLoginPluginDescriptor.setInitialized(true);
        }
        if (enabled != null) {
            oldLoginPluginDescriptor.setEnabled(enabled);
        }
    } else {
        LoginPlugin newLoginPlugin = null;
        try {
            newLoginPlugin = className.newInstance();
        } catch (InstantiationException e) {
            log.error("Unable to create LoginPlugin for class " + className.getName() + ":" + e.getMessage(),
                    e);
            return;
        } catch (IllegalAccessException e) {
            log.error("Unable to create LoginPlugin for class " + className.getName() + ":" + e.getMessage(),
                    e);
            return;
        }
        newLoginPlugin.setParameters(pluginExtension.getParameters());
        if (newLoginPlugin.initLoginModule()) {
            pluginExtension.setInitialized(true);
            log.info("LoginPlugin initialized for class " + className.getName());
        } else {
            pluginExtension.setInitialized(false);
            log.warn("Unable to initialize LoginPlugin for class " + className.getName());
        }
        pluginDescriptorStack.put(pluginName, pluginExtension);
        loginPluginStack.put(pluginName, newLoginPlugin);
    }
}

From source file:org.squale.welcom.addons.config.AddonsConfig.java

/**
 * Initialisation de l'addons/*w  ww .  j ava  2 s . c  o m*/
 * 
 * @param addonsClass : Classe de l'addons
 * @param servlet : Servlet
 * @param config : Config
 * @throws AddonsException : Probleme de chargement
 */
public void initAddons(final Class addonsClass, final ActionServlet servlet, final ModuleConfig config)
        throws AddonsException {

    WIAddOns addons = null;
    try {
        addons = (WIAddOns) addonsClass.newInstance();
    } catch (final InstantiationException e1) {
        throw new AddonsException(e1.getMessage());
    } catch (final IllegalAccessException e1) {
        throw new AddonsException(e1.getMessage());
    }

    logStartup.info("-> Init Addons : " + addons.getDisplayName());

    saveAddons(addons);
    addons.init(servlet, config);
    listAddons.add(addons);
}

From source file:org.jadira.scanner.classpath.types.JPackage.java

@Override
public Set<JAnnotation<?>> getAnnotations() throws ClasspathAccessException {

    Set<JAnnotation<?>> retVal = new HashSet<JAnnotation<?>>();
    List<? extends ClassFile> classes = getResolver().getClassFileResolver().resolveAll(null,
            CLASSPATH_PROJECTOR, new PackageFileFilter(getName(), false), new PackageFilter(this),
            new JElementTypeFilter(JAnnotation.class));
    for (ClassFile classFile : classes) {
        if (classFile.isInterface() && (classFile.getSuperclass().equals("java.lang.annotation.Annotation"))) {
            try {
                @SuppressWarnings("unchecked")
                Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) (getResolver()
                        .loadClass(classFile.getName()));
                Annotation theAnnotation = annotationClass.newInstance();
                retVal.add(JAnnotation.getJAnnotation(theAnnotation, this, getResolver()));
            } catch (InstantiationException e) {
                throw new ClasspathAccessException("Cannot instantiate annotation: " + e.getMessage(), e);
            } catch (IllegalAccessException e) {
                throw new ClasspathAccessException("Cannot access annotation: " + e.getMessage(), e);
            }/*from ww  w . ja va2s.  co  m*/
        }
    }
    return retVal;
}

From source file:nonjsp.application.XmlXulRuleSet.java

public Object createObject(Attributes attributes) {
    Class cClass = null;// ww  w. ja v a  2 s.  c  o  m
    UIComponent c = null;

    // Identify the name of the class to instantiate
    String className = attributes.getValue("class");
    String id = attributes.getValue("id");
    String value = attributes.getValue("value");

    // Instantiate the new object and return it
    try {
        cClass = Util.loadClass(className);
        c = (UIComponent) cClass.newInstance();
    } catch (ClassNotFoundException cnf) {
        throw new RuntimeException("Class Not Found:" + cnf.getMessage());
    } catch (InstantiationException ie) {
        throw new RuntimeException("Class Instantiation Exception:" + ie.getMessage());
    } catch (IllegalAccessException ia) {
        throw new RuntimeException("Illegal Access Exception:" + ia.getMessage());
    }

    c.setId(id);
    if (c instanceof UIOutput) {
        ((UIOutput) c).setValue(value);
    }
    return c;
}

From source file:org.wso2.carbon.databridge.agent.internal.endpoint.DataEndpointFactory.java

public DataEndpoint getNewDataEndpoint(String endPointType)
        throws DataEndpointAgentConfigurationException, DataEndpointException {
    try {/*ww w  . j a va2s.co m*/
        DataEndpointAgent agent = AgentHolder.getInstance().getDataEndpointAgent(endPointType);
        DataEndpoint dataEndpoint = (DataEndpoint) (DataEndpointFactory.class.getClassLoader()
                .loadClass(agent.getDataEndpointAgentConfiguration().getClassName()).newInstance());
        return dataEndpoint;
    } catch (InstantiationException e) {
        log.error("Error while instantiating the endpoint class for endpoint name " + endPointType, e);
        throw new DataEndpointException("Error while instantiating the endpoint class for endpoint name "
                + endPointType + ". " + e.getMessage(), e);
    } catch (IllegalAccessException e) {
        log.error("Error while instantiating the endpoint class for endpoint name " + endPointType, e);
        throw new DataEndpointException("Error while instantiating the endpoint class for endpoint name "
                + endPointType + ". " + e.getMessage(), e);
    } catch (ClassNotFoundException e) {
        log.error("Class defined: "
                + AgentHolder.getInstance().getDataEndpointAgent(endPointType)
                        .getDataEndpointAgentConfiguration().getClassName()
                + " cannot be found for endpoint name " + endPointType, e);
        throw new DataEndpointException("Class defined: "
                + AgentHolder.getInstance().getDataEndpointAgent(endPointType)
                        .getDataEndpointAgentConfiguration().getClassName()
                + " cannot be found for endpoint name " + endPointType + ". " + e.getMessage(), e);
    }
}

From source file:org.envirocar.app.application.ECApplication.java

@Override
public void onCreate() {
    Logger.initialize(Util.getVersionString(this));
    super.onCreate();

    try {//from   w  w w  .  j  a va2s. c  om
        DbAdapterImpl.init(getApplicationContext());
    } catch (InstantiationException e) {
        logger.warn("Could not initalize the database layer. The app will probably work unstable.");
        logger.warn(e.getMessage(), e);
    }

    preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

    DAOProvider.init(new ContextInternetAccessProvider(getApplicationContext()), new CacheDirectoryProvider() {
        @Override
        public File getBaseFolder() {
            return Util.resolveCacheFolder(getApplicationContext());
        }
    });

    UserManager.init(getApplicationContext());

    FeatureFlags.init(getApplicationContext());

    initializeErrorHandling();
    CarManager.init(preferences);
    TermsOfUseManager.instance();

    // Make a new commandListener to interpret the measurement values that are
    // returned
    logger.info("init commandListener");

}

From source file:com.bbytes.zorba.jobworker.impl.JobProcessorImpl.java

@Override
public void processJob(String jobExecutionId, String jobName, ZorbaData<String, Serializable> jobData,
        JobExecutionContext executionContext) throws ProcessingException {
    if (jobName == null) {
        String message = "jobName is null";
        log.error(message);//  w w w .  j av a  2 s.co  m
        throw new ProcessingException(message);
    }
    Class<IJob> jobClass = jobMap.get(jobName);
    if (jobClass == null) {
        JobEvent failed = new JobEvent(jobExecutionId, JobStatusType.FAILED, null, this);
        String description = "Class for job name " + jobName + " not registered";
        failed.setDescription(description);
        failed.setExecutionContext(executionContext);
        eventPublisher.publish(failed);
        log.error(description);
        throw new ProcessingException(description);
    }
    IJob job = null;
    try {
        job = jobClass.newInstance();
        JobEvent started = new JobEvent(jobExecutionId, JobStatusType.RUNNNING, job, this);
        started.setExecutionContext(executionContext);
        eventPublisher.publish(started);
        log.debug("Going to execute the job :: " + job.getJobName());
        //execute the job
        job.execute(jobData);
        log.debug("Finished Execution - Firing Completion Event :: " + job.getJobName());
        //publish the event after execution
        JobEvent finished = new JobEvent(jobExecutionId, JobStatusType.COMPLETED, job, this);
        finished.setExecutionContext(executionContext);
        eventPublisher.publish(finished);
    } catch (InstantiationException e) {
        JobEvent failed = new JobEvent(jobExecutionId, JobStatusType.FAILED, job, this);
        failed.setExecutionContext(executionContext);
        eventPublisher.publish(failed);
        log.error(e.getMessage(), e);
        throw new ProcessingException(e);
    } catch (IllegalAccessException e) {
        JobEvent failed = new JobEvent(jobExecutionId, JobStatusType.FAILED, job, this);
        eventPublisher.publish(failed);
        log.error(e.getMessage(), e);
        throw new ProcessingException(e);
    } catch (JobExecutionException e) {
        JobEvent failed = new JobEvent(jobExecutionId, JobStatusType.FAILED, job, this);
        eventPublisher.publish(failed);
        log.error(e.getMessage(), e);
        throw new ProcessingException(e);
    }
}

From source file:org.hyperic.hq.plugin.weblogic.jmx.WeblogicQuery.java

public WeblogicQuery cloneInstance() {
    WeblogicQuery query;/*from  w  w  w.j  a va  2  s .  co  m*/

    try {
        query = (WeblogicQuery) this.getClass().newInstance();
    } catch (InstantiationException e) {
        throw new IllegalArgumentException(e.getMessage());
    } catch (IllegalAccessException e) {
        throw new IllegalArgumentException(e.getMessage());
    }

    query.setParent(getParent());
    query.setName(getName());
    query.setVersion(getVersion());

    return query;
}

From source file:org.nuxeo.ecm.platform.content.template.service.ContentTemplateServiceImpl.java

@Override
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) {

    if (extensionPoint.equals(FACTORY_DECLARATION_EP)) {
        // store factories
        ContentFactoryDescriptor descriptor = (ContentFactoryDescriptor) contribution;
        factories.put(descriptor.getName(), descriptor);
    } else if (extensionPoint.equals(FACTORY_BINDING_EP)) {
        // store factories binding to types
        FactoryBindingDescriptor descriptor = (FactoryBindingDescriptor) contribution;
        if (factories.containsKey(descriptor.getFactoryName())) {
            String targetType = descriptor.getTargetType();
            String targetFacet = descriptor.getTargetFacet();

            // merge binding
            if (descriptor.getAppend()) {
                descriptor = mergeFactoryBindingDescriptor(descriptor);
            }//ww  w  .  j a va  2 s. com

            // store binding
            if (null != targetType) {
                factoryBindings.put(targetType, descriptor);
            } else {
                factoryBindings.put(targetFacet, descriptor);
            }

            // create factory instance : one instance per binding
            ContentFactoryDescriptor factoryDescriptor = factories.get(descriptor.getFactoryName());
            try {
                ContentFactory factory = factoryDescriptor.getClassName().newInstance();
                Boolean factoryOK = factory.initFactory(descriptor.getOptions(), descriptor.getRootAcl(),
                        descriptor.getTemplate());
                if (!factoryOK) {
                    log.error("Error while initializing instance of factory " + factoryDescriptor.getName());
                    return;
                }

                // store initialized instance
                if (null != targetType) {
                    factoryInstancesByType.put(targetType, factory);
                } else {
                    factoryInstancesByFacet.put(targetFacet, factory);
                }

            } catch (InstantiationException e) {
                log.error("Error while creating instance of factory " + factoryDescriptor.getName() + " :"
                        + e.getMessage());
            } catch (IllegalAccessException e) {
                log.error("Error while creating instance of factory " + factoryDescriptor.getName() + " :"
                        + e.getMessage());
            }
        } else {
            log.error("Factory Binding" + descriptor.getName() + " can not be registered since Factory "
                    + descriptor.getFactoryName() + " is not registered");
        }
    } else if (POST_CONTENT_CREATION_HANDLERS_EP.equals(extensionPoint)) {
        PostContentCreationHandlerDescriptor descriptor = (PostContentCreationHandlerDescriptor) contribution;
        postContentCreationHandlers.addContribution(descriptor);
    }
}

From source file:cz.incad.kramerius.client.ForwardServlet.java

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

    try {// w w w.  j a v a 2 s .  com
        TypeOfCall tc = disectTypeOfCall(req);
        User user = tc.getUser((CallUserController) req.getSession().getAttribute(CallUserController.KEY));

        String prefixKey = getInitParameter(URL_PREFIX_KEY);
        String prefixAddr = KConfiguration.getInstance().getConfiguration().getString(prefixKey);
        if (prefixAddr == null || StringUtils.isEmptyString(prefixAddr))
            throw new RuntimeException("expecting property " + prefixKey);

        String queryString = req.getQueryString();
        String requestedURI = req.getRequestURI();

        String urlModif = getInitParameter(URL_PATH_MODIF_KEY);
        if (urlModif != null) {
            URLPathModify pathModifier = getPathModifier(urlModif);
            requestedURI = pathModifier.modifyPath(requestedURI, req);
            queryString = pathModifier.modifyQuery(queryString, req);
        } else {
            URLPathModify pathModifier = getPathModifier(DefaultModify.class.getName());
            requestedURI = pathModifier.modifyPath(requestedURI, req);
            queryString = pathModifier.modifyQuery(queryString, req);
        }

        String replaceURL = prefixAddr + requestedURI;
        if (StringUtils.isAnyString(queryString)) {
            replaceURL = replaceURL + "?" + queryString;
        }

        // settings
        String readTimeOut = getInitParameter(READ_TIMEOUT_KEY);
        String conTimeOut = getInitParameter(CON_TIMEOUT_KEY);
        Map<String, String> settings = new HashMap<String, String>();
        if (readTimeOut != null) {
            settings.put(RESTHelper.READ_TIMEOUT, readTimeOut);
        }

        if (conTimeOut != null) {
            settings.put(RESTHelper.CONNECTION_TIMEOUT, conTimeOut);
        }

        InputStream inputStream = null;
        if (user != null) {

            fileDisposition(req, resp);
            RESTHelper.fillResponse(replaceURL, user.getUserName(), user.getPassword(), req, resp, settings);
        } else {
            fileDisposition(req, resp);
            RESTHelper.fillResponse(replaceURL, null, null, req, resp, settings);
        }
    } catch (InstantiationException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (IllegalAccessException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (ClassNotFoundException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (URISyntaxException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }

}