List of usage examples for java.lang ClassNotFoundException toString
public String toString()
From source file:nc.noumea.mairie.organigramme.core.viewmodel.AbstractViewModel.java
/** * Mthode utilitaire, pour lister les valeurs d'une numration (dans * l'ordre de leur dclaration), avec la possibilit d'insrer en tte la * valeur null.//from w w w . j a va 2 s . c o m * * @param enumClassName * nom complet de la classe (avec le package, ex : * "nc.noumea.mairie.organigramme.enums.Civilite") * @param insertNull * indique s'il faut insrer en tte de la liste rsultat la * valeur null * @return la liste des valeurs numres, dans l'ordre de leur dclaration * (avec null en tte optionnellement) */ @SuppressWarnings({ "unchecked", "rawtypes" }) public ListModelList<?> getListeEnum(String enumClassName, boolean insertNull) { try { Class<?> classe = Class.forName(enumClassName); ListModelList result = new ListModelList(classe.getEnumConstants()); if (insertNull) { result.add(0, null); } return result; } catch (ClassNotFoundException e) { LOGGER.error("erreur sur getListeEnum", e); Messagebox.show(e.toString()); } return null; }
From source file:org.n52.sos.ds.pgsql.PGConnectionPool.java
/** * Abstract method returns an available connection from the pool. After the query operation, you have to * "give back" the connection to the pool with the returnConnection method! * /* w w w. ja va2s . c om*/ * @return DB Connection to execute the query * * @throws OwsExceptionReport * If all connections are in use and no further connection could be established */ public Connection getConnection() throws OwsExceptionReport { // pooled connection Connection conn; // inner connection (postgresql) Connection con; Class<?> geomClass; Class<?> boxClass; try { // get pooled connection conn = dataSource.getConnection(); // int active = dataSource.getNumActive(); // int idle = dataSource.getNumIdle(); // log.debug("Connections active: " + active); // log.debug("Connections idle: " + idle); // get inner connection (postgresql) from pooled connection con = ((DelegatingConnection) conn).getInnermostDelegate(); geomClass = Class.forName("org.postgis.PGgeometry"); boxClass = Class.forName("org.postgis.PGbox3d"); // add spatial data types to inner connection ((org.postgresql.PGConnection) con).addDataType("geometry", geomClass); ((org.postgresql.PGConnection) con).addDataType("box3d", boxClass); } catch (SQLException sqle) { if (dataSource.getNumActive() == dataSource.getMaxActive()) { OwsExceptionReport se = new OwsExceptionReport(); se.addCodedException(OwsExceptionReport.ExceptionCode.NoApplicableCode, null, "All db connections are in use. Please try again later! " + sqle.toString()); log.debug("All database connections are in use. Please retry later! " + sqle.toString()); throw se; } else { OwsExceptionReport se = new OwsExceptionReport(); se.addCodedException(OwsExceptionReport.ExceptionCode.NoApplicableCode, null, "Could not get connection from connection pool. Please make sure that your database server is running and configured proper. " + sqle.toString()); log.debug( "Could not get connection from connection pool. Please make sure that your database server is running and configured proper. " + sqle.toString()); throw se; } } catch (ClassNotFoundException cnfe) { OwsExceptionReport se = new OwsExceptionReport(cnfe); log.fatal( "Adding geometry types to the connection failed. Please make sure that the PostGIS extension of your PostgreSQLDB is activated: " + cnfe.toString()); throw se; } // return new pooled connection return conn; }
From source file:org.apache.hadoop.sqoop.testutil.ImportJobTestCase.java
@Before public void setUp() { incrementTableNum();//w ww .j a v a 2s . co m if (!isLog4jConfigured) { BasicConfigurator.configure(); isLog4jConfigured = true; LOG.info("Configured log4j with console appender."); } testServer = new HsqldbTestServer(); try { testServer.resetServer(); } catch (SQLException sqlE) { LOG.error("Got SQLException: " + sqlE.toString()); fail("Got SQLException: " + sqlE.toString()); } catch (ClassNotFoundException cnfe) { LOG.error("Could not find class for db driver: " + cnfe.toString()); fail("Could not find class for db driver: " + cnfe.toString()); } manager = testServer.getManager(); }
From source file:org.madeirahs.editor.ui.SubviewUI.java
private Artifact readSubmission(String str) { try {//from w w w . ja v a 2 s .c o m InputStream in = prov.getInputStream(ServerFTP.subDir + str); if (in == null) { JOptionPane.showMessageDialog(parent, "Failed to locate file on remote server", "I/O Error", JOptionPane.ERROR_MESSAGE); return null; } ObjectInputStream objIn = new ObjectInputStream(in); Artifact a = (Artifact) objIn.readObject(); objIn.close(); return a; } catch (IOException e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(parent, "An error occurred while retrieving the file:\n" + e1.toString(), "I/O Error", JOptionPane.ERROR_MESSAGE); return null; } catch (ClassNotFoundException e2) { e2.printStackTrace(); JOptionPane.showMessageDialog(parent, "An error occurred while retrieving the file:\n" + e2.toString(), "This Shouldn't Happen", JOptionPane.ERROR_MESSAGE); return null; } }
From source file:org.onecmdb.core.utils.ClassInjector.java
public Class getClassForCi(ICi ci) { if (ci == null) { return (null); }/*from w ww. j av a 2 s .co m*/ String alias = ci.getAlias(); // Need a class name String className = null; // First check if the ci is configured with a javaClass // attribute, use that. List<IAttribute> clazzes = ci.getAttributesWithAlias(CLASS_ATTRIBUTE_NAME); if (clazzes != null && clazzes.size() == 1) { IValue value = clazzes.get(0).getValue(); if (value != null) { className = value.getAsString(); } } // If no className is provided by the ci, // check the aliasToClassName map. if (className == null) { className = aliasToClassNameMap.get(alias); } Class clazz = aliasToClassMap.get(alias); if (clazz == null) { ClassLoader loader = getClassLoader(); if (className == null) { clazz = getClassForCi(ci.getDerivedFrom()); } else { try { clazz = loader.loadClass(className); } catch (ClassNotFoundException e) { throw new IllegalArgumentException( "Class " + className + " for alias " + alias + " not found: " + e.toString(), e); } } if (clazz != null) { log.info("Map alias '" + alias + "' to class " + clazz.getSimpleName() + "'"); aliasToClassMap.put(alias, clazz); } } return (clazz); }
From source file:nc.noumea.mairie.appock.core.viewmodel.AbstractViewModel.java
/** * Mthode utilitaire, pour lister les valeurs d'une numration (dans l'ordre de leur dclaration), avec la possibilit d'insrer en tte la valeur null. * // www . j a v a2 s . c om * @param enumClassName nom complet de la classe (avec le package, ex : "nc.noumea.mairie.appock.enums.TypeConfig") * @param insertNull indique s'il faut insrer en tte de la liste rsultat la valeur null * @return la liste des valeurs numres, dans l'ordre de leur dclaration (avec null en tte optionnellement) */ @SuppressWarnings({ "unchecked", "rawtypes" }) public ListModelList<?> getListeEnum(String enumClassName, boolean insertNull) { try { Class<?> classe = Class.forName(enumClassName); ListModelList result = new ListModelList(classe.getEnumConstants()); if (insertNull) { result.add(0, null); } return result; } catch (ClassNotFoundException e) { log.error("erreur sur getListeEnum", e); Messagebox.show(e.toString()); } return null; }
From source file:org.onecmdb.core.utils.bean.BeanClassInjector.java
public Class getClassForCi(CiBean ci) { if (ci == null) { return (null); }/*from ww w . j a v a2 s . c o m*/ String alias = ci.getAlias(); // Need a class name String className = null; // First check if the ci is configured with a javaClass // attribute, use that. List<ValueBean> clazzes = ci.fetchAttributeValueBeans(CLASS_ATTRIBUTE_NAME); if (clazzes != null && clazzes.size() == 1) { className = clazzes.get(0).getValue(); } // If no className is provided by the ci, // check the aliasToClassName map. if (className == null) { className = aliasToClassNameMap.get(alias); } Class clazz = aliasToClassMap.get(alias); if (clazz == null) { ClassLoader loader = getClassLoader(); if (className == null) { clazz = getClassForCi(provider.getBean(ci.getDerivedFrom())); } else { try { clazz = loader.loadClass(className); } catch (ClassNotFoundException e) { throw new IllegalArgumentException( "Class " + className + " for alias " + alias + " not found: " + e.toString(), e); } } if (clazz != null) { log.debug("Map alias '" + alias + "' to class " + clazz.getSimpleName() + "'"); aliasToClassMap.put(alias, clazz); } } return (clazz); }
From source file:org.apache.hadoop.chukwa.analysis.salsa.fsm.FSMBuilder.java
public int run(String args[]) throws Exception { int num_inputs; JobConf conf = new JobConf(getConf(), FSMBuilder.class); String[] args2 = args;/*from www . ja v a 2s .c om*/ if (args2.length < 4 || !"-in".equals(args2[0])) { System.err.println("Specifying mapper (full Java class): -D chukwa.salsa.fsm.mapclass="); System.err.println( "Application-specific arguments: -in <# inputs> [input dir 1] ... [input dir n] [output dir]"); return (1); } conf.setJobName("Salsa_FSMBuilder"); /* Get name of Mapper class to use */ String mapclassname = conf.get("chukwa.salsa.fsm.mapclass"); log.info("Mapper class: " + mapclassname); Class mapperClass = null; try { mapperClass = Class.forName(mapclassname); } catch (ClassNotFoundException c) { System.err.println("Mapper " + mapclassname + " not found: " + c.toString()); } /* Get on with usual job setup */ conf.setMapperClass(mapperClass); conf.setReducerClass(FSMReducer.class); conf.setOutputKeyClass(ChukwaRecordKey.class); conf.setOutputValueClass(ChukwaRecord.class); conf.setInputFormat(SequenceFileInputFormat.class); conf.setOutputFormat(ChukwaRecordOutputFormat.class); conf.setPartitionerClass(FSMIntermedEntryPartitioner.class); conf.setMapOutputValueClass(FSMIntermedEntry.class); conf.setMapOutputKeyClass(ChukwaRecordKey.class); conf.setNumReduceTasks(1); // fixed at 1 to ensure that all records are grouped together /* Setup inputs/outputs */ try { num_inputs = Integer.parseInt(args2[1]); } catch (NumberFormatException e) { System.err.println("Specifying mapper: -D chukwa.salsa.fsm.mapper="); System.err.println( "Application-specific arguments: -in <# inputs> -out <#outputs> [input dir] [output dir]"); return (1); } if (num_inputs <= 0) { System.err.println("Must have at least 1 input."); return (1); } for (int i = 2; i < 2 + num_inputs; i++) { Path in = new Path(args2[i]); FileInputFormat.addInputPath(conf, in); } Path out = new Path(args2[2 + num_inputs]); FileOutputFormat.setOutputPath(conf, out); JobClient.runJob(conf); return (0); }
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * This method is used to check conectiton is avalible for analysis or report ,when analysis or report runs. * // www.j av a2 s .c om * @param analysisDataProvider * @return */ public static ReturnCode isConnectionAvailable(Connection analysisDataProvider) { ReturnCode returnCode = new ReturnCode(); if (analysisDataProvider == null) { returnCode.setOk(false); returnCode.setMessage(Messages.getString("ConnectionUtils.checkConnFailTitle")); //$NON-NLS-1$ return returnCode; } // check hive connection IMetadataConnection metadataConnection = ConvertionHelper.convert(analysisDataProvider); if (metadataConnection != null) { if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(metadataConnection.getDbType())) { try { // need to do this first when check for hive embed connection. if (isHiveEmbedded(analysisDataProvider)) { JavaSqlFactory.doHivePreSetup(analysisDataProvider); } HiveConnectionManager.getInstance().checkConnection(metadataConnection); returnCode.setOk(true); return returnCode; } catch (ClassNotFoundException e) { returnCode.setOk(false); returnCode.setMessage(e.toString()); return returnCode; } catch (InstantiationException e) { returnCode.setOk(false); returnCode.setMessage(e.toString()); return returnCode; } catch (IllegalAccessException e) { returnCode.setOk(false); returnCode.setMessage(e.toString()); return returnCode; } catch (SQLException e) { returnCode.setOk(false); returnCode.setMessage(e.toString()); return returnCode; } } } // MOD klliu check file connection is available if (analysisDataProvider instanceof FileConnection) { FileConnection fileConn = (FileConnection) analysisDataProvider; // ADD msjian TDQ-4559 2012-2-28: when the fileconnection is context mode, getOriginalFileConnection. if (fileConn.isContextMode()) { IRepositoryContextService service = CoreRuntimePlugin.getInstance().getRepositoryContextService(); if (service != null) { fileConn = service.cloneOriginalValueConnection(fileConn); } } // TDQ-4559 ~ String filePath = fileConn.getFilePath(); try { BufferedReader filePathAvalible = FilesUtils.isFilePathAvailable(filePath, fileConn); if (filePathAvalible != null) { returnCode.setOk(true); return returnCode; } } catch (UnsupportedEncodingException e) { returnCode.setOk(false); returnCode.setMessage(filePath); return returnCode; } catch (FileNotFoundException e) { returnCode.setOk(false); returnCode.setMessage(filePath); return returnCode; } catch (IOException e) { returnCode.setOk(false); returnCode.setMessage(filePath); return returnCode; } } // ~ Properties props = new Properties(); props.put(TaggedValueHelper.USER, JavaSqlFactory.getUsername(analysisDataProvider)); props.put(TaggedValueHelper.PASSWORD, JavaSqlFactory.getPassword(analysisDataProvider)); if (analysisDataProvider instanceof DatabaseConnection) { // MOD qiongli TDQ-11507,for GeneralJdbc,should check connection too after validation jar and jdbc driver . if (isGeneralJdbc(analysisDataProvider)) { try { ReturnCode rcJdbc = checkGeneralJdbcJarFilePathDriverClassName( (DatabaseConnection) analysisDataProvider); if (!rcJdbc.isOk()) { return rcJdbc; } } catch (MalformedURLException e) { return new ReturnCode(e.getMessage(), false); } } // MOD qiongli 2014-5-14 in order to check and connect a dbConnection by a correct driver,replace // 'ConnectionUtils.checkConnection(...)' with 'managerConn.check(metadataConnection)'. ManagerConnection managerConn = new ManagerConnection(); boolean check = managerConn.check(metadataConnection); returnCode.setOk(check); if (!check) { returnCode.setMessage(managerConn.getMessageException()); } } return returnCode; }
From source file:com.streamsets.pipeline.stage.origin.jdbc.cdc.postgres.PostgresCDCSource.java
@Override public List<ConfigIssue> init() { // Call super init List<ConfigIssue> issues = super.init(); // default record handler errorRecordHandler = new DefaultErrorRecordHandler(getContext()); // Validate the HikarConfig driverClassName if (!hikariConfigBean.driverClassName.isEmpty()) { try {/*w w w . ja va 2s . c o m*/ Class.forName(hikariConfigBean.driverClassName); } catch (ClassNotFoundException e) { LOG.error("Hikari Driver class not found.", e); issues.add(getContext().createConfigIssue("PostgreSQL CDC", DRIVER_CLASSNAME, JdbcErrors.JDBC_28, e.toString())); } } // Validate the HikariConfigBean issues = hikariConfigBean.validateConfigs(getContext(), issues); // Validate the PostgresCDC ConfigBean validatePostgresCDCConfigBean(configBean).ifPresent(issues::addAll); try { walReceiver = new PostgresCDCWalReceiver(configBean, hikariConfigBean, getContext()); // Schemas and Tables if (!configBean.baseConfigBean.schemaTableConfigs.isEmpty()) { walReceiver.validateSchemaAndTables(configBean.baseConfigBean.schemaTableConfigs) .ifPresent(issues::addAll); } offset = walReceiver.createReplicationStream(offset); } catch (StageException | InterruptedException | SQLException | TimeoutException e) { LOG.error("Error while connecting to DB", e); issues.add(getContext().createConfigIssue(Groups.JDBC.name(), CONNECTION_STR, JdbcErrors.JDBC_00, e.toString())); return issues; } // Setup the SDC record queue as LinkedBlockingQueue of 2x MaxBatchSize cdcQueue = new LinkedList<>(); return issues; }