List of usage examples for java.lang ClassNotFoundException getMessage
public String getMessage()
From source file:edu.emory.bmi.aiw.i2b2export.output.VisitDataOutputFormatter.java
public void format(BufferedWriter writer) throws IOException { try {// w ww .j av a2 s . c o m Class.forName("org.h2.Driver"); } catch (ClassNotFoundException ex) { throw new AssertionError("Error parsing i2b2 metadata: " + ex); } try (Connection con = DriverManager.getConnection("jdbc:h2:mem:VisitDataOutputFormatter")) { for (Patient patient : this.patients) { for (Event visit : patient.getEvents()) { new VisitDataRowOutputFormatter(this.config, visit, con).format(writer); writer.write(IOUtils.LINE_SEPARATOR); } } } catch (SQLException ex) { throw new IOException("Error parsing i2b2 metadata: " + ex.getMessage()); } }
From source file:com.opoopress.maven.plugins.plugin.AbstractDeployMojo.java
private static void configureScpWagonIfRequired(Wagon wagon, Log log) { log.debug("configureScpWagonIfRequired: " + wagon.getClass().getName()); if (System.console() == null) { log.debug("No System.console(), skip configure Wagon"); return;//ww w . j a va 2 s .co m } ClassLoader parent = Thread.currentThread().getContextClassLoader(); if (parent == null) { parent = AbstractDeployMojo.class.getClassLoader(); } List<ClassLoader> loaders = new ArrayList<ClassLoader>(); loaders.add(wagon.getClass().getClassLoader()); ChainingClassLoader loader = new ChainingClassLoader(parent, loaders); Class<?> scpWagonClass; try { scpWagonClass = ClassUtils.getClass(loader, "org.apache.maven.wagon.providers.ssh.jsch.ScpWagon"); } catch (ClassNotFoundException e) { log.debug( "Class 'org.apache.maven.wagon.providers.ssh.jsch.ScpWagon' not found, skip configure Wagon."); return; } //is ScpWagon if (scpWagonClass.isInstance(wagon)) { try { Class<?> userInfoClass = ClassUtils.getClass(loader, "com.opoopress.maven.plugins.plugin.ssh.SystemConsoleInteractiveUserInfo"); Object userInfo = userInfoClass.newInstance(); MethodUtils.invokeMethod(wagon, "setInteractiveUserInfo", userInfo); log.debug("ScpWagon using SystemConsoleInteractiveUserInfo(Java 6+)."); } catch (ClassNotFoundException e) { log.debug( "Class 'com.opoopress.maven.plugins.plugin.ssh.SystemConsoleInteractiveUserInfo' not found, skip configure Wagon."); } catch (InstantiationException e) { log.debug("Instantiate class exception", e); } catch (IllegalAccessException e) { log.debug(e.getMessage(), e); } catch (NoSuchMethodException e) { log.debug(e.getMessage(), e); } catch (InvocationTargetException e) { log.debug(e.getMessage(), e); } } else { log.debug("Not a ScpWagon."); } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.NavigationController.java
protected Set<ValueFactory> getValueFactory(RDFNode valueNode, OntModel displayOntModel) { //maybe use jenabean or owl2java for this? if (valueNode.isResource()) { Resource res = (Resource) valueNode.as(Resource.class); Statement stmt = res.getProperty(DisplayVocabulary.JAVA_CLASS_NAME); if (stmt == null || !stmt.getObject().isLiteral()) { log.debug("Cannot build value factory: java class was " + stmt.getObject()); return Collections.emptySet(); }//from w ww .j a va2 s. c o m String javaClassName = ((Literal) stmt.getObject().as(Literal.class)).getLexicalForm(); if (javaClassName == null || javaClassName.length() == 0) { log.debug("Cannot build value factory: no java class was set."); return Collections.emptySet(); } Class<?> clazz; Object newObj; try { clazz = Class.forName(javaClassName); } catch (ClassNotFoundException e) { log.debug("Cannot build value factory: no class found for " + javaClassName); return Collections.emptySet(); } try { newObj = clazz.newInstance(); } catch (Exception e) { log.debug("Cannot build value factory: exception while creating object of java class " + javaClassName + " " + e.getMessage()); return Collections.emptySet(); } if (newObj instanceof ValueFactory) { ValueFactory valueFactory = (ValueFactory) newObj; return Collections.singleton(valueFactory); } else { log.debug("Cannot build value factory: " + javaClassName + " does not implement " + ValueFactory.class.getName()); return Collections.emptySet(); } } else { log.debug("Cannot build value factory for " + valueNode); return Collections.emptySet(); } }
From source file:gemlite.core.internal.view.func.ViewManagerFunc.java
/** * ReCreate view after deleted.//from ww w. j a v a 2 s . c o m * * @param paramsMap * @return */ @SuppressWarnings({ "unchecked", "rawtypes" }) private String createView(Map<String, Object> paramsMap) { String msg = getNodeInfo(); String clsName = (String) paramsMap.get("ClassName"); if (StringUtils.isEmpty(clsName)) { String result = msg + "Input param can't be null."; return result; } StringBuffer sb = new StringBuffer(); sb.append(msg + "\n"); GemliteViewContext ctx = GemliteViewContext.getInstance(); Class<ViewTool> cls = null; try { cls = (Class<ViewTool>) ViewManagerFunc.class.getClassLoader().loadClass(clsName); } catch (ClassNotFoundException e) { e.printStackTrace(); sb.append("Create view failed, class " + clsName + " not found in classloader."); return sb.toString(); } try { ctx.createView(cls); } catch (Exception e) { e.printStackTrace(); sb.append("Create view failed." + "\n"); sb.append(e.getMessage() + "\n"); return sb.toString(); } sb.append("Create view successfully."); return sb.toString(); }
From source file:com.google.gsa.valve.rootAuth.RootAuthenticationProcess.java
/** * Sets the Valve Configuration instance to read the parameters * from there//w ww .j av a 2 s . c o m * * @param valveConf the Valve configuration instance */ public void setValveConfiguration(ValveConfiguration valveConf) { this.valveConf = valveConf; //Protection. Make sure the Map is empty before proceeding authenticationImplementations.clear(); //Authentication process instance AuthenticationProcessImpl authenticationProcess = null; String repositoryIds[] = valveConf.getRepositoryIds(); ValveRepositoryConfiguration repository = null; int order = 1; for (int i = 0; i < repositoryIds.length; i++) { try { repository = valveConf.getRepository(repositoryIds[i]); //Check if repository has to be included in the authentication process. By default set it to true boolean checkAuthN = true; try { if ((repository.getCheckAuthN() != null) && (!repository.getCheckAuthN().equals(""))) { checkAuthN = new Boolean(repository.getCheckAuthN()).booleanValue(); } } catch (Exception e) { logger.error("Error when reading checkAuthN param: " + e.getMessage(), e); //protection checkAuthN = true; } if (checkAuthN) { logger.info( "Initialising authentication process for " + repository.getId() + " [#" + order + "]"); authenticationProcess = (AuthenticationProcessImpl) Class.forName(repository.getAuthN()) .newInstance(); authenticationProcess.setValveConfiguration(valveConf); //add this authentication process to the Map synchronized (authenticationImplementations) { synchronized (authenticationImplementations) { authenticationImplementations.put(repository.getId(), authenticationProcess); authenticationImplementationsOrder.put(new Integer(order), repository.getId()); order++; } } } else { logger.debug("Authentication process for repository [" + repository.getId() + "] is not going to be launched"); } } catch (LinkageError le) { logger.error(repository.getId() + " - Can't instantiate class [AuthenticationProcess-LinkageError]: " + le.getMessage(), le); } catch (InstantiationException ie) { logger.error(repository.getId() + " - Can't instantiate class [AuthenticationProcess-InstantiationException]: " + ie.getMessage(), ie); } catch (IllegalAccessException iae) { logger.error(repository.getId() + " - Can't instantiate class [AuthenticationProcess-IllegalAccessException]: " + iae.getMessage(), iae); } catch (ClassNotFoundException cnfe) { logger.error(repository.getId() + " - Can't instantiate class [AuthenticationProcess-ClassNotFoundException]: " + cnfe.getMessage(), cnfe); } catch (Exception e) { logger.error(repository.getId() + " - Can't instantiate class [AuthenticationProcess-Exception]: " + e.getMessage(), e); } } logger.debug(RootAuthenticationProcess.class.getName() + " initialised"); }
From source file:com.gmt2001.MySQLStore.java
private MySQLStore() { try {/*from ww w.j ava2 s .c o m*/ Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException ex) { com.gmt2001.Console.err.println(ex.getMessage()); } catch (Exception ex) { com.gmt2001.Console.err.println(ex.getMessage()); } }
From source file:ConsumerServer.java
public void processMessages() { // for this exercise start from offset 0 // produce batches of n size for jdbc and insert // for this table // char(10), char(20), long String sqlInsert = "INSERT INTO kblog.BLOGDATA VALUES (?,?,?,?,?)"; String sqlUpsert = "UPSERT INTO kblog.BLOGDATA VALUES (?,?,?,?,?)"; final String UDFCALL = " select * from udf(kblog.kaf3('nap007:9092'," + " 'gid'," + " 'blogit'," + " 0," + " 'null'," + " 'C10C20IC55C55'," + " '|'," + " -1," + " 1000 ))"; final String SQLUPSERT = "upsert using load into kblog.blogdata "; final String SQLINSERT = "insert into kblog.blogdata "; final String SQLUPSERT2 = "upsert into kblog.blogdata "; try {//from ww w . j ava 2 s . c o m if (t2Connect) { // T2 Class.forName("org.apache.trafodion.jdbc.t2.T2Driver"); conn = DriverManager.getConnection("jdbc:t2jdbc:"); } else { // T4 Class.forName("org.trafodion.jdbc.t4.T4Driver"); conn = DriverManager.getConnection("jdbc:t4jdbc://nap007:23400/:", "trafodion", "passw"); } conn.setAutoCommit(autoCommit); } catch (SQLException sx) { System.out.println("SQL error: " + sx.getMessage()); System.exit(1); } catch (ClassNotFoundException cx) { System.out.println("Driver class not found: " + cx.getMessage()); System.exit(2); } // message processing loop String[] msgFields; long numRows = 0; long totalRows = 0; int[] batchResult; if (udfMode == 0 && insMode == 0) { // missing cmd line setting System.out.println("*** Neither UDF nor INSERT mode specified - aborting ***"); System.exit(2); } try { if (udfMode > 0) { long diff = 0; long startTime = System.currentTimeMillis(); switch (udfMode) { case 1: // upsert using load pStmt = conn.prepareStatement(SQLUPSERT + UDFCALL); totalRows = pStmt.executeUpdate(); diff = (System.currentTimeMillis() - startTime); System.out.println("Upsert loaded row count: " + totalRows + " in " + diff + " ms"); break; case 2: // insert pStmt = conn.prepareStatement(SQLINSERT + UDFCALL); totalRows = pStmt.executeUpdate(); if (!autoCommit) { conn.commit(); diff = (System.currentTimeMillis() - startTime); System.out .println("Insert row count (autocommit off): " + totalRows + " in " + diff + " ms"); } else { diff = (System.currentTimeMillis() - startTime); System.out .println("Insert row count (autocommit on): " + totalRows + " in " + diff + " ms"); } break; case 3: // upsert pStmt = conn.prepareStatement(SQLUPSERT2 + UDFCALL); totalRows = pStmt.executeUpdate(); if (!autoCommit) { conn.commit(); diff = (System.currentTimeMillis() - startTime); System.out .println("Upsert row count (autocommit off): " + totalRows + " in " + diff + " ms"); } else { diff = (System.currentTimeMillis() - startTime); System.out .println("Upsert row count (autocommit on): " + totalRows + " in " + diff + " ms"); } break; default: // illegal value System.out.println("*** Only udf values 1,2,3 allowed; found: " + udfMode); System.exit(2); } // switch } // udfMode else { // iterative insert/upsert switch (insMode) { case 1: // insert pStmt = conn.prepareStatement(sqlInsert); break; case 2: //upsert pStmt = conn.prepareStatement(sqlUpsert); break; default: // illegal System.out.println("*** Only insert values 1,2 allowed; found: " + insMode); System.exit(2); } // switch kafka.subscribe(Arrays.asList(topic)); // priming poll kafka.poll(100); // always start from beginning kafka.seekToBeginning(Arrays.asList(new TopicPartition(topic, 0))); // enable autocommit and singleton inserts for comparative timings long startTime = System.currentTimeMillis(); while (true) { // note that we don't commitSync to kafka - tho we should ConsumerRecords<String, String> records = kafka.poll(streamTO); if (records.isEmpty()) break; // timed out for (ConsumerRecord<String, String> msg : records) { msgFields = msg.value().split("\\" + Character.toString(delimiter)); // position info for this message long offset = msg.offset(); int partition = msg.partition(); String topic = msg.topic(); pStmt.setString(1, msgFields[0]); pStmt.setString(2, msgFields[1]); pStmt.setLong(3, Long.parseLong(msgFields[2])); pStmt.setString(4, msgFields[3]); pStmt.setString(5, msgFields[4]); numRows++; totalRows++; if (autoCommit) { // single ins/up sert pStmt.executeUpdate(); } else { pStmt.addBatch(); if ((numRows % commitCount) == 0) { numRows = 0; batchResult = pStmt.executeBatch(); conn.commit(); } } } // for each msg } // while true // get here when poll returns no records if (numRows > 0 && !autoCommit) { // remaining rows batchResult = pStmt.executeBatch(); conn.commit(); } long diff = (System.currentTimeMillis() - startTime); if (autoCommit) System.out.println("Total rows: " + totalRows + " in " + diff + " ms"); else System.out.println( "Total rows: " + totalRows + " in " + diff + " ms; batch size = " + commitCount); kafka.close(); } // else } // try catch (ConsumerTimeoutException to) { System.out.println("consumer time out; " + to.getMessage()); System.exit(1); } catch (BatchUpdateException bx) { int[] insertCounts = bx.getUpdateCounts(); int count = 1; for (int i : insertCounts) { if (i == Statement.EXECUTE_FAILED) System.out.println("Error on request #" + count + ": Execute failed"); else count++; } System.out.println(bx.getMessage()); System.exit(1); } catch (SQLException sx) { System.out.println("SQL error: " + sx.getMessage()); System.exit(1); } }
From source file:org.sakaiproject.hierarchy.tool.vm.spring.VelocityView.java
/** * Set tool attributes to expose to the view, as attribute name / class name pairs. * An instance of the given class will be added to the Velocity context for each * rendering operation, under the given attribute name. * <p>For example, an instance of MathTool, which is part of the generic package * of Velocity Tools, can be bound under the attribute name "math", specifying the * fully qualified class name "org.apache.velocity.tools.generic.MathTool" as value. * <p>Note that VelocityView can only create simple generic tools or values, that is, * classes with a public default constructor and no further initialization needs. * This class does not do any further checks, to not introduce a required dependency * on a specific tools package.//from ww w. j a v a2s . c o m * <p>For tools that are part of the view package of Velocity Tools, a special * Velocity context and a special init callback are needed. Use VelocityToolboxView * in such a case, or override <code>createVelocityContext</code> and * <code>initTool</code> accordingly. * <p>For a simple VelocityFormatter instance or special locale-aware instances * of DateTool/NumberTool, which are part of the generic package of Velocity Tools, * specify the "velocityFormatterAttribute", "dateToolAttribute" or * "numberToolAttribute" properties, respectively. * @param toolAttributes attribute names as keys, and tool class names as values * @see org.apache.velocity.tools.generic.MathTool * @see VelocityToolboxView * @see #createVelocityContext * @see #initTool * @see #setVelocityFormatterAttribute * @see #setDateToolAttribute * @see #setNumberToolAttribute */ public void setToolAttributes(Properties toolAttributes) { this.toolAttributes = new HashMap(toolAttributes.size()); for (Enumeration attributeNames = toolAttributes.propertyNames(); attributeNames.hasMoreElements();) { String attributeName = (String) attributeNames.nextElement(); String className = toolAttributes.getProperty(attributeName); Class toolClass = null; try { toolClass = ClassUtils.forName(className); } catch (ClassNotFoundException ex) { throw new IllegalArgumentException("Invalid definition for tool '" + attributeName + "' - tool class not found: " + ex.getMessage()); } this.toolAttributes.put(attributeName, toolClass); } }
From source file:com.buaa.cfs.security.UserGroupInformation.java
@SuppressWarnings("unchecked") private static Class<? extends Principal> getOsPrincipalClass() { ClassLoader cl = ClassLoader.getSystemClassLoader(); try {/*from w w w. j a v a 2 s .com*/ String principalClass = null; if (IBM_JAVA) { if (is64Bit) { principalClass = "com.ibm.security.auth.UsernamePrincipal"; } else { if (windows) { principalClass = "com.ibm.security.auth.NTUserPrincipal"; } else if (aix) { principalClass = "com.ibm.security.auth.AIXPrincipal"; } else { principalClass = "com.ibm.security.auth.LinuxPrincipal"; } } } else { principalClass = windows ? "com.sun.security.auth.NTUserPrincipal" : "com.sun.security.auth.UnixPrincipal"; } return (Class<? extends Principal>) cl.loadClass(principalClass); } catch (ClassNotFoundException e) { LOG.error("Unable to find JAAS classes:" + e.getMessage()); } return null; }
From source file:org.datanucleus.store.hbase.fieldmanager.FetchFieldManager.java
private UUID fetchUUIDInternal(AbstractMemberMetaData mmd, byte[] bytes) { if (bytes == null) { // Handle missing field String dflt = HBaseUtils.getDefaultValueForMember(mmd); return dflt != null ? UUID.fromString(dflt) : null; }//from w w w . j av a 2 s .c o m if (mmd.isSerialized()) { ByteArrayInputStream bis = null; ObjectInputStream ois = null; try { bis = new ByteArrayInputStream(bytes); ois = new ObjectInputStream(bis); return UUID.class.cast(ois.readObject()); } catch (ClassNotFoundException e) { throw new NucleusException(e.getMessage(), e); } catch (IOException e) { throw new NucleusException(e.getMessage(), e); } finally { IOUtils.closeStream(ois); IOUtils.closeStream(bis); } } else { if (bytes.length == 16) { // serialized as bytes long upper = Bytes.toLong(bytes); long lower = Bytes.toLong(ArrayUtils.subarray(bytes, 8, 16)); return new UUID(upper, lower); } else { final String value = new String(bytes, Charsets.UTF_8); return UUID.fromString(value); } } }