List of usage examples for java.lang ClassNotFoundException toString
public String toString()
From source file:org.ralasafe.servlet.UtilAction.java
private void getJavaBeanProperties(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { String clazz = req.getParameter("clazz"); Class c;// w ww.j a v a 2 s . c o m Properties prop = new Properties(); try { c = Class.forName(clazz); Field[] fields = c.getDeclaredFields(); int length = fields.length; String[] properties = new String[length]; String[] javaTypes = new String[length]; for (int i = 0; i < fields.length; i++) { Field field = fields[i]; properties[i] = field.getName(); javaTypes[i] = field.getType().getName(); } prop.setJavaTypes(javaTypes); prop.setProperties(properties); } catch (ClassNotFoundException e) { prop.setErrorMsg(e.toString()); } Gson gson = new Gson(); String json = gson.toJson(prop); if (log.isDebugEnabled()) { log.debug("The json is:" + json); } resp.setContentType("application/json;charset=UTF-8"); resp.setCharacterEncoding("UTF-8"); PrintWriter pw = resp.getWriter(); pw.write(json); pw.flush(); }
From source file:com.netspective.commons.report.tabular.calc.TabularReportCalcs.java
/** * Returns a freshly instantiated ColumnDataCalculator named "cmd". If "cmd" is an already-existing named * class it will return a newInstance() of that class. If the "cmd" is a class name, a newInstance() of that * particular class will be created and the class will be cached in the calcsClasses Map. *///from ww w.j a va2 s .co m public ColumnDataCalculator createDataCalc(String id) { Class cls = (Class) calcsClassesMap.get(id); if (cls == null) { try { cls = Class.forName(id); registerColumnDataCalc(cls); } catch (ClassNotFoundException e) { return null; } } try { return (ColumnDataCalculator) cls.newInstance(); } catch (Exception e) { throw new RuntimeException(e.toString()); } }
From source file:com.quattroresearch.antibody.plugin.PluginLoader.java
/** * Loads the plugins that are offered in a domains context menu. * //www. j a v a 2 s .co m * @param popup * @param domain */ public void loadDomainPopupPlugins(JPopupMenu popup, Domain domain) { String popupConfig = PreferencesService.getInstance().getApplicationPrefs() .getString("plugins.popup.domain"); if (popupConfig == null) { return; } String[] popupPlugins = popupConfig.split(";"); try { for (String singleConfig : popupPlugins) { Class<?> clazz = classLoader.findClass(singleConfig); if (clazz != null) { Constructor<?> constructor; constructor = clazz.getDeclaredConstructor(JFrame.class, Domain.class); JMenuItem item = (JMenuItem) constructor.newInstance(UIService.getInstance().getMainFrame(), domain); popup.add(item); } } } catch (ClassNotFoundException exc) { System.err.println("Toolbar Plugin class was not found: " + exc.toString()); } catch (Exception exc) { System.err.println(exc.toString()); } }
From source file:com.quattroresearch.antibody.plugin.PluginLoader.java
/** * Loads the toolbar plugins and inserts them into the toolbar. */// ww w.j a v a 2 s.c o m public void loadToolbarPlugins() { String toolbarPluginConfig = PreferencesService.getInstance().getApplicationPrefs() .getString("plugins.toolbar"); if (toolbarPluginConfig == null) { return; } String[] toolbarPlugins = toolbarPluginConfig.split(";"); for (String singleConfig : toolbarPlugins) { try { Class<?> clazz = classLoader.findClass(singleConfig); if (clazz != null) { Constructor<?> constructor; constructor = clazz.getDeclaredConstructor(JFrame.class); ToolBarToggleButton toolBarButton = (ToolBarToggleButton) constructor .newInstance(UIService.getInstance().getMainFrame()); UIService.getInstance().getToolBar().add(toolBarButton); } } catch (ClassNotFoundException exc) { System.err.println("Toolbar Plugin class was not found: " + exc.toString()); } catch (Exception exc) { System.err.println(exc.toString()); } } }
From source file:com.quattroresearch.antibody.plugin.PluginLoader.java
/** * Loads custom sequence file reader plugin that is used when opening file for domain detection. When multiple * filereaders are configured, only the first is returned. * //ww w. j a va 2s. co m * @return sequence file reader */ public ISequenceFileReader loadSequenceFileReaderPlugin() { String readerPluginConfig = PreferencesService.getInstance().getApplicationPrefs() .getString("plugins.filereader.sequence"); if (readerPluginConfig == null) return null; String[] readerPlugins = readerPluginConfig.split(";"); try { for (String singleConfig : readerPlugins) { Class<?> clazz = classLoader.findClass(singleConfig); if (clazz != null) { Constructor<?> constructor; constructor = clazz.getDeclaredConstructor(); ISequenceFileReader reader = (ISequenceFileReader) constructor.newInstance(); return reader; } } } catch (ClassNotFoundException exc) { System.err.println("Sequence Reader Plugin class was not found: " + exc.toString()); } catch (Exception exc) { System.err.println(exc.toString()); } return null; }
From source file:com.quattroresearch.antibody.plugin.PluginLoader.java
/** * Loads the menu plugins and inserts them into the menu. *//*from ww w . jav a 2 s . c om*/ public void loadMenuPlugins() { String menuPluginConfig = PreferencesService.getInstance().getApplicationPrefs().getString("plugins.menu"); if (menuPluginConfig == null) { return; } String[] menuPlugins = menuPluginConfig.split(";"); for (String singleConfig : menuPlugins) { try { Class<?> clazz = classLoader.findClass(singleConfig); if (clazz != null) { Constructor<?> constructor; constructor = clazz.getDeclaredConstructor(JFrame.class); AbstractEditorAction action = (AbstractEditorAction) constructor .newInstance(UIService.getInstance().getMainFrame()); boolean isAdded = false; JMenuBar menubar = UIService.getInstance().getMainFrame().getJMenuBar(); for (int i = 0; i < menubar.getMenuCount(); i++) { JMenu menu = menubar.getMenu(i); if (menu.getText().equals(action.getMenuName())) { menu.add(action); isAdded = true; break; } } if (!isAdded) { JMenu newMenu = new JMenu(action.getMenuName()); newMenu.add(action); menubar.add(newMenu, menubar.getMenuCount() - 1); } } } catch (ClassNotFoundException exc) { System.err.println("Menu Plugin class was not found: " + exc.toString()); } catch (Exception exc) { System.err.println(exc.toString()); } } }
From source file:org.onecmdb.core.internal.job.workflow.CiToJavaObject.java
public Class getClassForAlias(String alias) { Class clazz = aliasToClassMap.get(alias); if (clazz == null) { ClassLoader loader = getClassLoader(); String className = aliasToClassNameMap.get(alias); if (className == null) { return (null); }//from w w w . j a va 2s . c om try { clazz = loader.loadClass(className); } catch (ClassNotFoundException e) { throw new IllegalArgumentException( "Class " + className + " for alias " + alias + " not found: " + e.toString(), e); } aliasToClassMap.put(alias, clazz); } return (clazz); }
From source file:org.mule.util.scan.ClasspathScanner.java
protected Class<?> loadClass(String name) { String c = name.replace("/", "."); try {//from w w w . j a v a2 s . c o m return ClassUtils.loadClass(c, classLoader); } catch (ClassNotFoundException e) { if (logger.isWarnEnabled()) { logger.warn(String.format("%s : %s", c, e.toString())); } return null; } }
From source file:org.apache.flume.sink.customhdfs.add.ImpalaTableFill.java
private Connection getConnection() { Connection con = null;/*from w w w .j a v a2 s. com*/ try { Class.forName("org.apache.hive.jdbc.HiveDriver"); con = DriverManager.getConnection(this.impalaUrl); LOG.info("impalaurl:" + this.impalaUrl); } catch (ClassNotFoundException var3) { LOG.error("impalaTableFillError:" + var3.toString()); } catch (SQLException var4) { LOG.error("impalaTableFillError:" + var4.toString()); } return con; }
From source file:com.cloudera.sqoop.orm.TestClassWriter.java
@Before public void setUp() { testServer = new HsqldbTestServer(); org.apache.log4j.Logger root = org.apache.log4j.Logger.getRootLogger(); root.setLevel(org.apache.log4j.Level.DEBUG); try {//from w w w . j ava 2 s. c o m 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(); options = testServer.getSqoopOptions(); // sanity check: make sure we're in a tmp dir before we blow anything away. assertTrue("Test generates code in non-tmp dir!", CODE_GEN_DIR.startsWith(ImportJobTestCase.TEMP_BASE_DIR)); assertTrue("Test generates jars in non-tmp dir!", JAR_GEN_DIR.startsWith(ImportJobTestCase.TEMP_BASE_DIR)); // start out by removing these directories ahead of time // to ensure that this is truly generating the code. File codeGenDirFile = new File(CODE_GEN_DIR); File classGenDirFile = new File(JAR_GEN_DIR); if (codeGenDirFile.exists()) { LOG.debug("Removing code gen dir: " + codeGenDirFile); if (!DirUtil.deleteDir(codeGenDirFile)) { LOG.warn("Could not delete " + codeGenDirFile + " prior to test"); } } if (classGenDirFile.exists()) { LOG.debug("Removing class gen dir: " + classGenDirFile); if (!DirUtil.deleteDir(classGenDirFile)) { LOG.warn("Could not delete " + classGenDirFile + " prior to test"); } } }