List of usage examples for java.lang InstantiationException getMessage
public String getMessage()
From source file:org.apache.struts.util.RequestUtils.java
/** * <p>Try to locate a multipart request handler for this request. First, * look for a mapping-specific handler stored for us under an attribute. * If one is not present, use the global multipart handler, if there is * one.</p>//from w ww. ja v a2 s . com * * @param request The HTTP request for which the multipart handler should * be found. * @return the multipart handler to use, or null if none is found. * @throws ServletException if any exception is thrown while attempting to * locate the multipart handler. */ private static MultipartRequestHandler getMultipartHandler(HttpServletRequest request) throws ServletException { MultipartRequestHandler multipartHandler = null; String multipartClass = (String) request.getAttribute(Globals.MULTIPART_KEY); request.removeAttribute(Globals.MULTIPART_KEY); // Try to initialize the mapping specific request handler if (multipartClass != null) { try { multipartHandler = (MultipartRequestHandler) applicationInstance(multipartClass); } catch (ClassNotFoundException cnfe) { log.error("MultipartRequestHandler class \"" + multipartClass + "\" in mapping class not found, " + "defaulting to global multipart class"); } catch (InstantiationException ie) { log.error( "InstantiationException when instantiating " + "MultipartRequestHandler \"" + multipartClass + "\", " + "defaulting to global multipart class, exception: " + ie.getMessage()); } catch (IllegalAccessException iae) { log.error( "IllegalAccessException when instantiating " + "MultipartRequestHandler \"" + multipartClass + "\", " + "defaulting to global multipart class, exception: " + iae.getMessage()); } if (multipartHandler != null) { return multipartHandler; } } ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request); multipartClass = moduleConfig.getControllerConfig().getMultipartClass(); // Try to initialize the global request handler if (multipartClass != null) { try { multipartHandler = (MultipartRequestHandler) applicationInstance(multipartClass); } catch (ClassNotFoundException cnfe) { throw new ServletException("Cannot find multipart class \"" + multipartClass + "\"", cnfe); } catch (InstantiationException ie) { throw new ServletException( "InstantiationException when instantiating " + "multipart class \"" + multipartClass + "\"", ie); } catch (IllegalAccessException iae) { throw new ServletException( "IllegalAccessException when instantiating " + "multipart class \"" + multipartClass + "\"", iae); } if (multipartHandler != null) { return multipartHandler; } } return multipartHandler; }
From source file:org.grails.datastore.mapping.model.AbstractPersistentEntity.java
public Object newInstance() { try {/*from w ww. j a v a 2 s. co m*/ return getJavaClass().newInstance(); } catch (InstantiationException e) { throw new EntityCreationException( "Unable to create entity of type [" + getJavaClass().getName() + "]: " + e.getMessage(), e); } catch (IllegalAccessException e) { throw new EntityCreationException( "Unable to create entity of type [" + getJavaClass().getName() + "]: " + e.getMessage(), e); } }
From source file:info.magnolia.cms.beans.config.ModuleLoader.java
private void load(ModuleDefinition def, Content moduleNode) { try {/* ww w . j a v a 2 s .co m*/ Module module = this.getModuleInstance(def.getName()); // instantiate if not yet done (due registraion) if (module == null) { try { String moduleClassName = moduleNode.getNodeData("class").getString(); //$NON-NLS-1$ module = (Module) Class.forName(moduleClassName).newInstance(); this.addModuleInstance(def.getName(), module); } catch (InstantiationException ie) { log.error("Module {} failed to load", moduleNode.getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ log.error(ie.getMessage()); } catch (IllegalAccessException ae) { log.error(ae.getMessage()); } } // init the module if (!module.isInitialized()) { if (!module.isRestartNeeded()) { log.info("start initialization of module {}", def.getName()); Content moduleConfigNode = ContentUtil.getCaseInsensitive(moduleNode, CONFIG_NODE); module.init(moduleConfigNode); log.info("module {} initialized", def.getName()); //$NON-NLS-1$ } else { log.warn("won't initialize the module {} since a system restart is needed", module.getName()); } if (module.isRestartNeeded()) { ModuleRegistration.getInstance().setRestartNeeded(true); } } final Module m = module; // add destroy method as a shutdown task ShutdownManager.addShutdownTask(new ShutdownTask() { public boolean execute(info.magnolia.context.Context context) { log.info("Shutting down module: " + m.getName()); m.destroy(); return true; } public String toString() { return getClass().getName() + " " + m; } }); } catch (Exception e) { log.error("can't initialize module " + moduleNode.getHandle(), e); //$NON-NLS-1$ } }
From source file:com.octo.captcha.service.AbstractManageableCaptchaService.java
/** * Set the fully qualified class name of the concrete CaptchaEngine used by the service * * @param theClassName the fully qualified class name of the CaptchaEngine used by the service * * @throws IllegalArgumentException if className can't be used as the service CaptchaEngine, either because it can't * be instanciated by the service or it is not a ImageCaptchaEngine concrete * class. *//* w ww.j av a2 s .com*/ public void setCaptchaEngineClass(String theClassName) throws IllegalArgumentException { try { Object engine = Class.forName(theClassName).newInstance(); if (engine instanceof com.octo.captcha.engine.CaptchaEngine) { this.engine = (com.octo.captcha.engine.CaptchaEngine) engine; } else { throw new IllegalArgumentException("Class is not instance of CaptchaEngine! " + theClassName); } } catch (InstantiationException e) { throw new IllegalArgumentException(e.getMessage()); } catch (IllegalAccessException e) { throw new IllegalArgumentException(e.getMessage()); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(e.getMessage()); } catch (RuntimeException e) { throw new IllegalArgumentException(e.getMessage()); } }
From source file:org.kuali.kfs.sec.businessobject.lookup.AccessSecuritySimulationLookupableHelperServiceImpl.java
/** * @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#setRows() *///from w w w . j a v a 2s . com @Override protected void setRows() { List<String> lookupFieldAttributeList = new ArrayList<String>(); if (getParameters().containsKey(SecPropertyConstants.TEMPLATE_ID)) { String templateId = ((String[]) getParameters().get(SecPropertyConstants.TEMPLATE_ID))[0]; if (accessSecurityService.getInquiryWithFieldValueTemplate().getId().equals(templateId)) { lookupFieldAttributeList = getInquiryTemplateFields(); } else if (accessSecurityService.getLookupWithFieldValueTemplate().getId().equals(templateId)) { lookupFieldAttributeList = getLookupTemplateFields(); } else { lookupFieldAttributeList = getDocumentTemplateFields(); } } else { lookupFieldAttributeList = getLookupTemplateFields(); } // construct field object for each search attribute List<Field> fields = new ArrayList<Field>(); int numCols; try { fields = FieldUtils.createAndPopulateFieldsForLookup(lookupFieldAttributeList, getReadOnlyFieldsList(), getBusinessObjectClass()); BusinessObjectEntry boe = (BusinessObjectEntry) SpringContext.getBean(DataDictionaryService.class) .getDataDictionary().getBusinessObjectEntry(this.getBusinessObjectClass().getName()); numCols = boe.getLookupDefinition().getNumOfColumns(); } catch (InstantiationException e) { throw new RuntimeException("Unable to create instance of business object class" + e.getMessage()); } catch (IllegalAccessException e) { throw new RuntimeException("Unable to create instance of business object class" + e.getMessage()); } if (numCols == 0) { numCols = KRADConstants.DEFAULT_NUM_OF_COLUMNS; } rows = FieldUtils.wrapFields(fields, numCols); }
From source file:org.acegisecurity.acl.basic.jdbc.JdbcDaoImpl.java
/** * Constructs an individual <code>BasicAclEntry</code> from the passed <code>AclDetailsHolder</code>s.<P>Guarantees * to never return <code>null</code> (exceptions are thrown in the event of any issues).</p> * * @param propertiesInformation mandatory information about which instance to create, the object identity, and the * parent object identity (<code>null</code> or empty <code>String</code>s prohibited for * <code>aclClass</code> and <code>aclObjectIdentity</code> * @param aclInformation optional information about the individual ACL record (if <code>null</code> only an * "inheritence marker" instance is returned which will include a recipient of {@link * #RECIPIENT_USED_FOR_INHERITENCE_MARKER} ; if not <code>null</code>, it is prohibited to present * <code>null</code> or an empty <code>String</code> for <code>recipient</code>) * * @return a fully populated instance suitable for use by external objects * * @throws IllegalArgumentException if the indicated ACL class could not be created *//*w w w. j a va 2 s .c o m*/ private BasicAclEntry createBasicAclEntry(AclDetailsHolder propertiesInformation, AclDetailsHolder aclInformation) { BasicAclEntry entry; try { entry = (BasicAclEntry) propertiesInformation.getAclClass().newInstance(); } catch (InstantiationException ie) { throw new IllegalArgumentException(ie.getMessage()); } catch (IllegalAccessException iae) { throw new IllegalArgumentException(iae.getMessage()); } entry.setAclObjectIdentity(propertiesInformation.getAclObjectIdentity()); entry.setAclObjectParentIdentity(propertiesInformation.getAclObjectParentIdentity()); if (aclInformation == null) { // this is an inheritence marker instance only entry.setMask(0); entry.setRecipient(RECIPIENT_USED_FOR_INHERITENCE_MARKER); } else { // this is an individual ACL entry entry.setMask(aclInformation.getMask()); entry.setRecipient(aclInformation.getRecipient()); } return entry; }
From source file:jp.mathes.databaseWiki.web.DbwServlet.java
private void handleHttp(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("UTF-8"); resp.setCharacterEncoding("UTF-8"); String user = null;//from www . j a v a2 s . com String password = null; if (req.getHeader("Authorization") != null) { String[] split = req.getHeader("Authorization").split(" "); String userpw = ""; if (split.length > 1) { userpw = new String(Base64.decodeBase64(split[1])); } user = StringUtils.substringBefore(userpw, ":"); password = StringUtils.substringAfter(userpw, ":"); resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("application/xhtml+xml; charset=UTF-8"); try { this.handleAction(req, resp, user, password); } catch (InstantiationException e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not instantiate database backend: " + e.getMessage()); } catch (IllegalAccessException e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Illegal Access: " + e.getMessage()); } catch (ClassNotFoundException e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not find database backend: " + e.getMessage()); } catch (TemplateException e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Template error: " + e.getMessage()); } catch (BackendException e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Database error: " + e.getMessage()); } catch (PluginException e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Rendering error: " + e.getMessage()); } } else { resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED); resp.setHeader("WWW-Authenticate", "Basic realm=\"databaseWiki\""); } }
From source file:org.hyperic.hq.plugin.mysql_stats.MySqlStatsMeasurementPlugin.java
protected Connection getConnection(String url, String user, String password) throws SQLException { try {/*from w w w. j av a 2 s. c om*/ password = (password == null) ? "" : password; password = (password.matches("^\\s*$")) ? "" : password; Driver driver = (Driver) Class.forName(_driver).newInstance(); final Properties props = new Properties(); props.put("user", user); props.put("password", password); return driver.connect(getJdbcUrl(url), props); } catch (InstantiationException e) { throw new SQLException(e.getMessage()); } catch (IllegalAccessException e) { throw new SQLException(e.getMessage()); } catch (ClassNotFoundException e) { throw new SQLException(e.getMessage()); } }
From source file:org.apache.velocity.tools.struts.TilesTool.java
/** * End of Process for definition.//from w w w. jav a 2 s. c o m * * @param definition Definition to process. * @return the fully processed definition. * @throws Exception from InstantiationException Can't create requested controller */ protected String processDefinition(ComponentDefinition definition) throws Exception { Controller controller = null; try { controller = definition.getOrCreateController(); String role = definition.getRole(); String page = definition.getTemplate(); return doInsert(definition.getAttributes(), page, role, controller); } catch (InstantiationException ex) { throw new Exception(ex.getMessage()); } }
From source file:org.openinfinity.cloud.service.healthmonitoring.HealthMonitoringServiceImpl.java
private <T extends AbstractResponse> T toObject(String source, Class<T> expectedType) { if (source == null || StringUtils.isEmpty(source)) { T newInstance = null;//ww w . ja v a 2 s. c om try { newInstance = expectedType.newInstance(); newInstance.setResponseStatus(AbstractResponse.STATUS_RRD_FAIL); } catch (InstantiationException e) { LOG.error(e.getMessage(), e); } catch (IllegalAccessException e) { LOG.error(e.getMessage(), e); } return newInstance; } ObjectMapper mapper = new ObjectMapper(); T obj = null; try { //LOG.debug("================================================"); LOG.debug("Now: " + System.currentTimeMillis() + " source:" + source); //LOG.debug("================================================"); obj = mapper.readValue(source, expectedType); } catch (Exception e) { LOG.error("Exception occurred while converting from String to Object. ", e); } return obj; }