List of usage examples for java.lang InstantiationException getMessage
public String getMessage()
From source file:net.orpiske.ssps.common.db.MultiRsHandler.java
@Override protected T handleRow(ResultSet rs) throws SQLException { T dto;//from ww w . ja va 2 s . com try { dto = clazz.newInstance(); } catch (InstantiationException e1) { throw new SQLException("Unable to instantiate DTO class: " + e1.getMessage(), e1); } catch (IllegalAccessException e1) { throw new SQLException("Illegal to instantiate DTO class: " + e1.getMessage(), e1); } ResultSetMetaData meta = rs.getMetaData(); for (int i = 1; i <= meta.getColumnCount(); i++) { Object value = rs.getObject(i); String name = meta.getColumnName(i); try { /* * We convert the column name to a more appropriate and java like name * because some columns are usually named as some_thing whereas Java * properties are named someThing. This call does this conversion. */ String javaProperty = NameConverter.sqlToProperty(name); PropertyUtils.setSimpleProperty(dto, javaProperty, value); } catch (Exception e) { throw new SQLException("Unable to set property " + name + " for bean" + dto.getClass(), e); } } return dto; }
From source file:com.us.listener.ScheduleInitListener.java
public void doWork() { log.info("?"); Set<String> paks = getPackgeList(); log.info("?" + paks); try {//from ww w. j ava 2 s. co m SCHEDULER = StdSchedulerFactory.getDefaultScheduler(); for (String pak : paks) { Set<Class<?>> allClass = ClassUtil.getClassesByPackage(pak, true); for (Class<?> clazz : allClass) { try { final Object jobInstance = clazz.newInstance(); if (jobInstance instanceof UsJob) { UsJob job = (UsJob) jobInstance; if (!job.isDisable()) { Trigger trigger = job.initTrigger(); if (trigger.getName() == null) { trigger.setName(jobInstance.getClass().getName()); } log.info(String.format("Class[%s],Trigger:[%s]", jobInstance.getClass().getName(), trigger.getName())); SCHEDULER.scheduleJob(job.makeJob(), trigger); } } } catch (InstantiationException e) { log.error("??" + e.getMessage()); } catch (IllegalAccessException e) { log.error("??" + e.getMessage()); } } } SCHEDULER.start(); log.info("??"); } catch (SchedulerException e) { e.printStackTrace(); } }
From source file:org.eclipse.ecr.core.search.api.client.querymodel.descriptor.WhereClauseDescriptor.java
/** * Initiates escaper object by using the provided {@link RuntimeContext}. * * @param context/*from www. jav a 2s. c o m*/ */ public void initEscaper(RuntimeContext context) { try { escaper = (Escaper) context.loadClass(escaperClassName).newInstance(); } catch (InstantiationException e) { log.warn("Could not instantiate esacper: " + e.getMessage()); } catch (IllegalAccessException e) { log.warn("Could not instantiate escaper: " + e.getMessage()); } catch (ClassNotFoundException e) { log.warn("escaper class " + escaperClassName + "not found"); } }
From source file:com.orange.mmp.api.ws.jsonrpc.SimpleMapSerializer.java
@SuppressWarnings("unchecked") @Override//from ww w.ja v a 2 s. c o m public Object unmarshall(SerializerState state, Class clazz, Object o) throws UnmarshallException { Map map = null; try { try { try { if (clazz.isInterface()) { map = new java.util.HashMap(); } else map = (Map) clazz.newInstance(); } catch (ClassCastException cce) { throw new UnmarshallException("invalid unmarshalling Class " + cce.getMessage()); } } catch (IllegalAccessException iae) { throw new UnmarshallException("no access unmarshalling object " + iae.getMessage()); } } catch (InstantiationException ie) { throw new UnmarshallException("unable to instantiate unmarshalling object " + ie.getMessage()); } JSONObject jso = (JSONObject) o; Iterator keys = jso.keys(); state.setSerialized(o, map); try { while (keys.hasNext()) { String key = (String) keys.next(); map.put(key, ser.unmarshall(state, null, jso.get(key))); } } catch (JSONException je) { throw new UnmarshallException("Could not read map: " + je.getMessage()); } return map; }
From source file:org.nuxeo.ecm.platform.webdav.adapters.DavResourceAdapterFactory.java
public Object getAdapter(DocumentModel doc, Class cls) { DavResourceAdapter adapter = null;//from www .j av a 2 s. c o m // first try to get Type Adapter try { adapter = getConfigService().getAdapterForType(doc.getType()); } catch (InstantiationException e) { log.error("Error while getting DAV adapter for type " + doc.getType() + ':' + e.getMessage()); } catch (IllegalAccessException e) { log.error("Error while getting DAV adapter for type " + doc.getType() + ':' + e.getMessage()); } if (adapter == null) { // use default built-in adapters if (doc.isFolder()) { adapter = new DefaultFolderishDavDownloadAdapter(); } else { if (doc.hasSchema("file")) { adapter = new FileBasedDavResourceAdapter(); } /* else if (doc.getType().equals("Note")) { adapter = new NoteDavResourceAdapter(); }*/ else { adapter = new DefaultNonFolderishDavDownloadAdapter(); } } } adapter.setDocumentModel(doc); return adapter; }
From source file:com.impetus.kundera.property.accessor.ObjectAccessor.java
public Object getInstance(Class<?> clazz) { Object o = null;/* w ww . j a va 2s . co m*/ try { o = clazz.newInstance(); return o; } catch (InstantiationException ie) { log.warn("Instantiation exception,caused by :" + ie.getMessage()); return null; } catch (IllegalAccessException iae) { log.warn("Illegal access exception,caused by :" + iae.getMessage()); return null; } }
From source file:com.liferay.portal.servlet.SharedServletWrapper.java
public void init(ServletConfig sc) throws ServletException { super.init(sc); ServletContext ctx = getServletContext(); _servletContextName = StringUtil.replace(ctx.getServletContextName(), StringPool.SPACE, StringPool.UNDERLINE);// w w w.j ava 2s. c o m _servletClass = sc.getInitParameter("servlet-class"); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); try { _servletInstance = (Servlet) contextClassLoader.loadClass(_servletClass).newInstance(); } catch (ClassNotFoundException cnfe) { throw new ServletException(cnfe.getMessage()); } catch (IllegalAccessException iae) { throw new ServletException(iae.getMessage()); } catch (InstantiationException ie) { throw new ServletException(ie.getMessage()); } if (_servletInstance instanceof HttpServlet) { _httpServletInstance = (HttpServlet) _servletInstance; _httpServletInstance.init(sc); } else { _servletInstance.init(sc); } }
From source file:com.orange.mmp.api.ws.jsonrpc.SimpleListSerializer.java
@SuppressWarnings("unchecked") @Override//from w ww. j av a 2 s . com public Object unmarshall(SerializerState state, Class clazz, Object o) throws UnmarshallException { List list = null; try { try { try { if (clazz.isInterface()) { list = new java.util.ArrayList(); } else list = (List) clazz.newInstance(); } catch (ClassCastException cce) { throw new UnmarshallException("invalid unmarshalling Class " + cce.getMessage()); } } catch (IllegalAccessException iae) { throw new UnmarshallException("no access unmarshalling object " + iae.getMessage()); } } catch (InstantiationException ie) { throw new UnmarshallException("unable to instantiate unmarshalling object " + ie.getMessage()); } JSONArray jsa = (JSONArray) o; state.setSerialized(o, list); int i = 0; try { for (; i < jsa.length(); i++) { list.add(ser.unmarshall(state, null, jsa.get(i))); } } catch (UnmarshallException e) { throw new UnmarshallException("element " + i + " " + e.getMessage()); } catch (JSONException e) { throw new UnmarshallException("element " + i + " " + e.getMessage()); } return list; }
From source file:eagle.log.entity.TestHBaseWriteEntitiesPerformance.java
private List<String> writeEntities(int count) { GenericEntityWriter writer = null;//from w w w . ja va2s . c o m try { writer = new GenericEntityWriter(ed.getService()); } catch (InstantiationException e1) { Assert.fail(e1.getMessage()); } catch (IllegalAccessException e1) { Assert.fail(e1.getMessage()); } if (LOG.isDebugEnabled()) LOG.debug("Start to write " + count + " entities"); int wroteCount = 0; List<String> rowkeys = new ArrayList<String>(); List<TestLogAPIEntity> list = new ArrayList<TestLogAPIEntity>(); for (int i = 0; i <= count; i++) { TestLogAPIEntity e = new TestLogAPIEntity(); e.setTimestamp(new Date().getTime()); e.setField1(i); e.setField2(i); e.setField3(i); e.setField4(new Long(i)); e.setField5(new Double(i)); e.setField6(new Double(i)); e.setField7(String.valueOf(i)); e.setTags(new HashMap<String, String>()); e.getTags().put("jobID", "index_test_job_id"); e.getTags().put("hostname", "testhost"); e.getTags().put("index", String.valueOf(i)); e.getTags().put("class", e.toString()); list.add(e); if (list.size() >= 1000) { try { StopWatch watch = new StopWatch(); watch.start(); rowkeys.addAll(writer.write(list)); watch.stop(); wroteCount += list.size(); if (LOG.isDebugEnabled()) LOG.debug("Wrote " + wroteCount + " / " + count + " entities" + " in " + watch.getTime() + " ms"); list.clear(); } catch (Exception e1) { Assert.fail(e1.getMessage()); } } } try { rowkeys.addAll(writer.write(list)); wroteCount += list.size(); if (LOG.isDebugEnabled()) LOG.debug("wrote " + wroteCount + " / " + count + " entities"); } catch (Exception e) { Assert.fail(e.getMessage()); } if (LOG.isDebugEnabled()) LOG.debug("done " + count + " entities"); return rowkeys; }
From source file:org.apache.oodt.cas.metadata.extractors.TestExternMetExtractor.java
@Override public void setUp() throws Exception { super.setUp(); String configFilename = "/extern-config.xml"; String extractFilename = "/testfile.txt"; String extractorFilename = "/testExtractor"; String sampleMetFilename = "/samplemet.xml"; this.confFile = super.getTestDataFile(configFilename); this.extractFile = super.getTestDataFile(extractFilename); this.metFile = new File(this.extractFile.getCanonicalPath() + ".met"); this.expectedFileLocation = this.extractFile.getParent(); File extractorFile = super.getTestDataFile(extractorFilename); // make it executable // yes this is ghetto String chmodCmd = "chmod +x " + extractorFile.getAbsolutePath(); ExecHelper.execUsingShell(chmodCmd); // replace the FileLocation met field in the sample met file // with the actual file location of the extractFile File sampleMetFile = super.getTestDataFile(sampleMetFilename); String sampleMetFileContents = FileUtils.readFileToString(sampleMetFile); String extractFileLocKey = "[EXTRACT_FILE_LOC]"; sampleMetFileContents = sampleMetFileContents.replace(extractFileLocKey, URLEncoder.encode(extractFile.getParent(), "UTF-8")); FileUtils.writeStringToFile(sampleMetFile, sampleMetFileContents, "UTF-8"); // replace the path to the sample met file inside of testExtractor String extractorFileContents = FileUtils.readFileToString(extractorFile); String sampleMetFilePathKey = "<TEST_SAMPLE_MET_PATH>"; extractorFileContents = extractorFileContents.replace(sampleMetFilePathKey, sampleMetFile.getAbsolutePath()); FileUtils.writeStringToFile(extractorFile, extractorFileContents); // replace path in confFile named TEST_PATH String testPathKey = "TEST_PATH"; String confFileContents = FileUtils.readFileToString(this.confFile); Metadata replaceMet = new Metadata(); replaceMet.addMetadata(testPathKey, extractorFile.getParent()); confFileContents = PathUtils.replaceEnvVariables(confFileContents, replaceMet); FileUtils.writeStringToFile(this.confFile, confFileContents); try {/*from w w w . j a v a2 s . c o m*/ extractor = new ExternMetExtractor(); } catch (InstantiationException e) { fail(e.getMessage()); } }