List of usage examples for java.lang ClassNotFoundException toString
public String toString()
From source file:MethodInspector.java
public static void main(String[] arguments) { Class inspect;//from w w w. ja va 2s .com try { if (arguments.length > 0) inspect = Class.forName(arguments[0]); else inspect = Class.forName("MethodInspector"); Method[] methods = inspect.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { Method methVal = methods[i]; Class returnVal = methVal.getReturnType(); int mods = methVal.getModifiers(); String modVal = Modifier.toString(mods); Class[] paramVal = methVal.getParameterTypes(); StringBuffer params = new StringBuffer(); for (int j = 0; j < paramVal.length; j++) { if (j > 0) params.append(", "); params.append(paramVal[j].getName()); } System.out.println("Method: " + methVal.getName() + "()"); System.out.println("Modifiers: " + modVal); System.out.println("Return Type: " + returnVal.getName()); System.out.println("Parameters: " + params + "\n"); } } catch (ClassNotFoundException c) { System.out.println(c.toString()); } }
From source file:net.sf.joost.Main.java
/** * Entry point/* www. j av a 2s. c o m*/ * @param args array of strings containing the parameter for Joost and * at least two URLs addressing xml-source and stx-sheet */ public static void main(String[] args) { // input filename String xmlFile = null; // the currently last processor (as XMLFilter) Processor processor = null; // output filename (optional) String outFile = null; // custom message emitter class name (optional) String meClassname = null; // log4j properties filename (optional) String log4jProperties = null; // log4j message level (this is an object of the class Level) Level log4jLevel = null; // set to true if a command line parameter was wrong boolean wrongParameter = false; // set to true if -help was specified on the command line boolean printHelp = false; // set to true if -pdf was specified on the command line boolean doFOP = false; // set to true if -nodecl was specified on the command line boolean nodecl = false; // set to true if -noext was specified on the command line boolean noext = false; // set to true if -doe was specified on the command line boolean doe = false; // debugging boolean dontexit = false; // timings boolean measureTime = false; long timeStart = 0, timeEnd = 0; // needed for evaluating parameter assignments int index; // serializer SAX -> XML text StreamEmitter emitter = null; // filenames for the usage and version info final String USAGE = "usage.txt", VERSION = "version.txt"; try { // parse command line argument list for (int i = 0; i < args.length; i++) { if (args[i].trim().length() == 0) { // empty parameter? ingore } // all options start with a '-', but a single '-' means stdin else if (args[i].charAt(0) == '-' && args[i].length() > 1) { if ("-help".equals(args[i])) { printHelp = true; continue; } else if ("-version".equals(args[i])) { printResource(VERSION); logInfoAndExit(); } else if ("-pdf".equals(args[i])) { doFOP = true; continue; } else if ("-nodecl".equals(args[i])) { nodecl = true; continue; } else if ("-noext".equals(args[i])) { noext = true; continue; } else if ("-doe".equals(args[i])) { doe = true; continue; } else if ("-wait".equals(args[i])) { dontexit = true; // undocumented continue; } else if ("-time".equals(args[i])) { measureTime = true; continue; } else if ("-o".equals(args[i])) { // this option needs a parameter if (++i < args.length && args[i].charAt(0) != '-') { if (outFile != null) { System.err.println("Option -o already specified with " + outFile); wrongParameter = true; } else outFile = args[i]; continue; } else { if (outFile != null) System.err.println("Option -o already specified with " + outFile); else System.err.println("Option -o requires a filename"); i--; wrongParameter = true; } } else if ("-m".equals(args[i])) { // this option needs a parameter if (++i < args.length && args[i].charAt(0) != '-') { if (meClassname != null) { System.err.println("Option -m already specified with " + meClassname); wrongParameter = true; } else meClassname = args[i]; continue; } else { if (meClassname != null) System.err.println("Option -m already specified with " + meClassname); else System.err.println("Option -m requires a classname"); i--; wrongParameter = true; } } else if (DEBUG && "-log-properties".equals(args[i])) { // this option needs a parameter if (++i < args.length && args[i].charAt(0) != '-') { log4jProperties = args[i]; continue; } else { System.err.println("Option -log-properties requires " + "a filename"); wrongParameter = true; } } else if (DEBUG && "-log-level".equals(args[i])) { // this option needs a parameter if (++i < args.length && args[i].charAt(0) != '-') { if ("off".equals(args[i])) { log4jLevel = Level.OFF; continue; } else if ("debug".equals(args[i])) { log4jLevel = Level.DEBUG; continue; } else if ("info".equals(args[i])) { log4jLevel = Level.INFO; continue; } else if ("warn".equals(args[i])) { log4jLevel = Level.WARN; continue; } else if ("error".equals(args[i])) { log4jLevel = Level.ERROR; continue; } else if ("fatal".equals(args[i])) { log4jLevel = Level.FATAL; continue; } else if ("all".equals(args[i])) { log4jLevel = Level.ALL; continue; } else { System.err.println("Unknown parameter for -log-level: " + args[i]); wrongParameter = true; continue; } } else { System.err.println("Option -log-level requires a " + "parameter"); wrongParameter = true; } } else { System.err.println("Unknown option " + args[i]); wrongParameter = true; } } // command line argument is not an option with a leading '-' else if ((index = args[i].indexOf('=')) != -1) { // parameter assignment if (processor != null) processor.setParameter(args[i].substring(0, index), args[i].substring(index + 1)); else { System.err.println("Assignment " + args[i] + " must follow an stx-sheet parameter"); wrongParameter = true; } continue; } else if (xmlFile == null) { xmlFile = args[i]; continue; } else { // xmlFile != null, i.e. this is an STX sheet ParseContext pContext = new ParseContext(); pContext.allowExternalFunctions = !noext; if (measureTime) timeStart = System.currentTimeMillis(); Processor proc = new Processor(new InputSource(args[i]), pContext); if (nodecl) proc.outputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); if (measureTime) { timeEnd = System.currentTimeMillis(); System.err.println("Parsing " + args[i] + ": " + (timeEnd - timeStart) + " ms"); } if (processor != null) proc.setParent(processor); // XMLFilter chain processor = proc; } } // PDF creation requested if (doFOP && outFile == null) { System.err.println("Option -pdf requires option -o"); wrongParameter = true; } // missing filenames if (!printHelp && processor == null) { if (xmlFile == null) System.err.println("Missing filenames for XML source and " + "STX transformation sheet"); else System.err.println("Missing filename for STX transformation " + "sheet"); wrongParameter = true; } if (meClassname != null && !wrongParameter) { // create object StxEmitter messageEmitter = null; try { messageEmitter = (StxEmitter) Class.forName(meClassname).newInstance(); } catch (ClassNotFoundException ex) { System.err.println("Class not found: " + ex.getMessage()); wrongParameter = true; } catch (InstantiationException ex) { System.err.println("Instantiation failed: " + ex.getMessage()); wrongParameter = true; } catch (IllegalAccessException ex) { System.err.println("Illegal access: " + ex.getMessage()); wrongParameter = true; } catch (ClassCastException ex) { System.err.println( "Wrong message emitter: " + meClassname + " doesn't implement the " + StxEmitter.class); wrongParameter = true; } if (messageEmitter != null) { // i.e. no exception occurred // set message emitter for all processors in the filter chain Processor p = processor; do { p.setMessageEmitter(messageEmitter); Object o = p.getParent(); if (o instanceof Processor) p = (Processor) o; else p = null; } while (p != null); } } if (printHelp) { printResource(VERSION); printResource(USAGE); logInfoAndExit(); } if (wrongParameter) { System.err.println("Specify -help to get a detailed help message"); System.exit(1); } if (DEBUG) { // use specified log4j properties file if (log4jProperties != null) PropertyConfigurator.configure(log4jProperties); // set log level specified on the the command line if (log4jLevel != null) Logger.getRootLogger().setLevel(log4jLevel); } // The first processor re-uses its XMLReader for parsing the input // xmlFile. // For a real XMLFilter usage you have to call // processor.setParent(yourXMLReader) // Connect a SAX consumer if (doFOP) { // pass output events to FOP // // Version 1: use a FOPEmitter object as XMLFilter // processor.setContentHandler( // new FOPEmitter( // new java.io.FileOutputStream(outFile))); // Version 2: use a static method to retrieve FOP's content // handler and use it directly processor.setContentHandler(FOPEmitter.getFOPContentHandler(new java.io.FileOutputStream(outFile))); } else { // Create XML output if (outFile != null) { emitter = StreamEmitter.newEmitter(outFile, processor.outputProperties); emitter.setSystemId(new File(outFile).toURI().toString()); } else emitter = StreamEmitter.newEmitter(System.out, processor.outputProperties); processor.setContentHandler(emitter); processor.setLexicalHandler(emitter); // the previous line is a short-cut for // processor.setProperty( // "http://xml.org/sax/properties/lexical-handler", emitter); emitter.setSupportDisableOutputEscaping(doe); } InputSource is; if (xmlFile.equals("-")) { is = new InputSource(System.in); is.setSystemId("<stdin>"); is.setPublicId(""); } else is = new InputSource(xmlFile); // Ready for take-off if (measureTime) timeStart = System.currentTimeMillis(); processor.parse(is); if (measureTime) { timeEnd = System.currentTimeMillis(); System.err.println("Processing " + xmlFile + ": " + (timeEnd - timeStart) + " ms"); } // // check if the Processor copy constructor works // Processor pr = new Processor(processor); // java.util.Properties props = new java.util.Properties(); // props.put("encoding", "ISO-8859-2"); // StreamEmitter em = // StreamEmitter.newEmitter(System.err, props); // pr.setContentHandler(em); // pr.setLexicalHandler(em); // pr.parse(is); // // end check // this is for debugging with the Java Memory Profiler if (dontexit) { System.err.println("Press Enter to exit"); System.in.read(); } } catch (java.io.IOException ex) { System.err.println(ex.toString()); System.exit(1); } catch (SAXException ex) { if (emitter != null) { try { // flushes the internal BufferedWriter, i.e. outputs // the intermediate result emitter.endDocument(); } catch (SAXException exx) { // ignore } } Exception embedded = ex.getException(); if (embedded != null) { if (embedded instanceof TransformerException) { TransformerException te = (TransformerException) embedded; SourceLocator sl = te.getLocator(); String systemId; // ensure that systemId is not null; is this a bug? if (sl != null && (systemId = sl.getSystemId()) != null) { // remove the "file://" scheme prefix if it is present if (systemId.startsWith("file://")) systemId = systemId.substring(7); else if (systemId.startsWith("file:")) // bug in JDK 1.4 / Crimson? (see rfc1738) systemId = systemId.substring(5); System.err.println(systemId + ":" + sl.getLineNumber() + ":" + sl.getColumnNumber() + ": " + te.getMessage()); } else System.err.println(te.getMessage()); } else { // Fatal: this mustn't happen embedded.printStackTrace(System.err); } } else System.err.println(ex.toString()); System.exit(1); } }
From source file:com.tethrnet.manage.util.DSPool.java
/** * register the data source for H2 DB//from w ww.ja va 2 s . c o m * * @return pooling database object */ private static PoolingDataSource registerDataSource() { // create a database connection String user = "tethrnetbox"; String password = "filepwd 45WJLnwhpA47EepT162hrVnDn3vYRvJhpZi0sVdvN9Sdsf"; String connectionURI = "jdbc:h2:" + DB_PATH + "/tethrnetbox;CIPHER=AES"; String validationQuery = "select 1"; try { Class.forName("org.h2.Driver"); } catch (ClassNotFoundException ex) { log.error(ex.toString(), ex); } GenericObjectPool connectionPool = new GenericObjectPool(null); connectionPool.setMaxActive(25); connectionPool.setTestOnBorrow(true); connectionPool.setMinIdle(2); connectionPool.setMaxWait(15000); connectionPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectionURI, user, password); new PoolableConnectionFactory(connectionFactory, connectionPool, null, validationQuery, false, true); return new PoolingDataSource(connectionPool); }
From source file:com.keybox.manage.util.DSPool.java
/** * register the data source for H2 DB/*from w w w. j a v a 2 s .c o m*/ * * @return pooling database object */ private static PoolingDataSource registerDataSource() { // create a database connection String user = "keybox"; String password = "filepwd 45WJLnwhpA47EepT162hrVnDn3vYRvJhpZi0sVdvN9Sdsf"; String connectionURI = "jdbc:h2:" + getDBPath() + "/keybox;CIPHER=AES"; String validationQuery = "select 1"; try { Class.forName("org.h2.Driver"); } catch (ClassNotFoundException ex) { log.error(ex.toString(), ex); } GenericObjectPool connectionPool = new GenericObjectPool(null); connectionPool.setMaxActive(MAX_ACTIVE); connectionPool.setTestOnBorrow(TEST_ON_BORROW); connectionPool.setMinIdle(MIN_IDLE); connectionPool.setMaxWait(MAX_WAIT); connectionPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectionURI, user, password); new PoolableConnectionFactory(connectionFactory, connectionPool, null, validationQuery, false, true); return new PoolingDataSource(connectionPool); }
From source file:com.ec2box.manage.util.DSPool.java
/** * register the data source for H2 DB//from ww w. j a v a 2 s . c o m * * @return pooling database object */ private static PoolingDataSource registerDataSource() { // create a database connection String user = "ec2box"; String password = "filepwd 0WJLnwhpA47EepT1A4drVnDn3vYRvJhpZi0sVdvN9SmlbKw"; String connectionURI = "jdbc:h2:" + getDBPath() + "/ec2box;CIPHER=AES;"; if (StringUtils.isNotEmpty(DB_OPTIONS)) { connectionURI = connectionURI + DB_OPTIONS; } String validationQuery = "select 1"; try { Class.forName("org.h2.Driver"); } catch (ClassNotFoundException ex) { log.error(ex.toString(), ex); } GenericObjectPool connectionPool = new GenericObjectPool(null); connectionPool.setMaxActive(MAX_ACTIVE); connectionPool.setTestOnBorrow(TEST_ON_BORROW); connectionPool.setMinIdle(MIN_IDLE); connectionPool.setMaxWait(MAX_WAIT); connectionPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectionURI, user, password); new PoolableConnectionFactory(connectionFactory, connectionPool, null, validationQuery, false, true); return new PoolingDataSource(connectionPool); }
From source file:ConnectionUtil.java
/** Get a Connection for the given config name from a provided Properties */ public static Connection getConnection(Properties p, String config) throws Exception { try {/*from w ww . j a v a2 s . c o m*/ String db_driver = p.getProperty(config + "." + "DBDriver"); String db_url = p.getProperty(config + "." + "DBURL"); String db_user = p.getProperty(config + "." + "DBUser"); String db_password = p.getProperty(config + "." + "DBPassword"); if (db_driver == null || db_url == null) { throw new IllegalStateException("Driver or URL null: " + config); } return createConnection(db_driver, db_url, db_user, db_password); } catch (ClassNotFoundException ex) { throw new Exception(ex.toString()); } catch (SQLException ex) { throw new Exception(ex.toString()); } }
From source file:info.extensiblecatalog.OAIToolkit.db.DButil.java
public static void init(String fileName) throws Exception { if (ConnectionType.equals(ConnectionTypes.STANDARD)) { try {// ww w . jav a2s.c o m load(fileName); Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { prglog.info("[PRG] Class not found: " + e.toString()); throw e; } catch (Exception e) { prglog.info("[PRG] " + e); throw e; } } else if (ConnectionType.equals(ConnectionTypes.DATASOURCE)) { load(fileName); initDataSource(); } }
From source file:org.omegat.util.ProjectFileStorage.java
/** * Load a tokenizer class from its canonical name. * @param className Name of tokenizer class * @return Class object of specified tokenizer, or of fallback tokenizer * if the specified one could not be loaded for whatever reason. *///from w w w. j a va 2 s. c o m private static Class<?> loadTokenizer(String className, Language fallback) { if (!StringUtil.isEmpty(className)) { try { return ProjectFileStorage.class.getClassLoader().loadClass(className); } catch (ClassNotFoundException e) { Log.log(e.toString()); } } return PluginUtils.getTokenizerClassForLanguage(fallback); }
From source file:com.psiphon3.psiphonlibrary.WebViewProxySettings.java
@TargetApi(Build.VERSION_CODES.KITKAT) // for android.util.ArrayMap methods @SuppressWarnings("rawtypes") private static boolean setWebkitProxyLollipop(Context appContext, String host, int port) { System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", port + ""); System.setProperty("https.proxyHost", host); System.setProperty("https.proxyPort", port + ""); try {//from ww w. j a va2 s . co m Class applictionClass = Class.forName("android.app.Application"); Field mLoadedApkField = applictionClass.getDeclaredField("mLoadedApk"); mLoadedApkField.setAccessible(true); Object mloadedApk = mLoadedApkField.get(appContext); Class loadedApkClass = Class.forName("android.app.LoadedApk"); Field mReceiversField = loadedApkClass.getDeclaredField("mReceivers"); mReceiversField.setAccessible(true); ArrayMap receivers = (ArrayMap) mReceiversField.get(mloadedApk); for (Object receiverMap : receivers.values()) { for (Object receiver : ((ArrayMap) receiverMap).keySet()) { Class clazz = receiver.getClass(); if (clazz.getName().contains("ProxyChangeListener")) { Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); onReceiveMethod.invoke(receiver, appContext, intent); } } } return true; } catch (ClassNotFoundException e) { MyLog.d("Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString()); } catch (NoSuchFieldException e) { MyLog.d("Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString()); } catch (IllegalAccessException e) { MyLog.d("Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString()); } catch (NoSuchMethodException e) { MyLog.d("Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString()); } catch (InvocationTargetException e) { MyLog.d("Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString()); } return false; }
From source file:com.psiphon3.psiphonlibrary.WebViewProxySettings.java
@TargetApi(Build.VERSION_CODES.KITKAT) @SuppressWarnings("rawtypes") private static boolean setWebkitProxyKitKat(Context appContext, String host, int port) { System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", port + ""); System.setProperty("https.proxyHost", host); System.setProperty("https.proxyPort", port + ""); try {//from www . j a v a 2s.c om Class applicationClass = Class.forName("android.app.Application"); Field loadedApkField = applicationClass.getDeclaredField("mLoadedApk"); loadedApkField.setAccessible(true); Object loadedApk = loadedApkField.get(appContext); Class loadedApkClass = Class.forName("android.app.LoadedApk"); Field receiversField = loadedApkClass.getDeclaredField("mReceivers"); receiversField.setAccessible(true); ArrayMap receivers = (ArrayMap) receiversField.get(loadedApk); for (Object receiverMap : receivers.values()) { for (Object receiver : ((ArrayMap) receiverMap).keySet()) { Class receiverClass = receiver.getClass(); if (receiverClass.getName().contains("ProxyChangeListener")) { Method onReceiveMethod = receiverClass.getDeclaredMethod("onReceive", Context.class, Intent.class); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); final String CLASS_NAME = "android.net.ProxyProperties"; Class proxyPropertiesClass = Class.forName(CLASS_NAME); Constructor constructor = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE, String.class); constructor.setAccessible(true); Object proxyProperties = constructor.newInstance(host, port, null); intent.putExtra("proxy", (Parcelable) proxyProperties); onReceiveMethod.invoke(receiver, appContext, intent); } } } return true; } catch (ClassNotFoundException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } catch (NoSuchFieldException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } catch (IllegalAccessException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } catch (IllegalArgumentException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } catch (NoSuchMethodException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } catch (InvocationTargetException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } catch (InstantiationException e) { MyLog.d("Exception setting WebKit proxy on KitKat through ProxyChangeListener: " + e.toString()); } return false; }