List of usage examples for java.lang ClassNotFoundException getMessage
public String getMessage()
From source file:com.openkm.servlet.admin.UnitTestingServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { log.debug("doGet({}, {})", request, response); String test = WebUtils.getString(request, "test"); response.setContentType("text/html; charset=UTF-8"); response.setCharacterEncoding("UTF-8"); OutputStream os = response.getOutputStream(); PrintStream ps = new PrintStream(os); header(ps, "Unit testing", breadcrumb); ps.flush();/*from w w w . ja va2 s .c om*/ RunListener listener = new CustomListener(ps); JUnitCore junit = new JUnitCore(); junit.addListener(listener); if (test != null && !test.isEmpty()) { try { Class<?> clazz = Class.forName(test); ps.println("<b>" + clazz.getCanonicalName() + "</b><br/>"); ps.flush(); ps.println("<pre>"); ps.flush(); junit.run(clazz); ps.println("</pre>"); ps.flush(); } catch (ClassNotFoundException e) { warn(ps, e.getMessage()); } } else { for (Class<?> clazz : new Reflections("com.openkm.test.api").getSubTypesOf(TestCase.class)) { ps.println("<a style=\"color: black; font-weight:bold;\" href=\"UnitTesting?test=" + clazz.getCanonicalName() + "\">" + clazz.getCanonicalName() + "</a><br/>"); ps.flush(); ps.println("<pre>"); ps.flush(); junit.run(clazz); ps.println("</pre>"); ps.flush(); } } ps.println( "<span style=\"color: blue; font-weight:bold;\">>>> End Of Unit Testing <<<</span>"); footer(ps); ps.flush(); IOUtils.closeQuietly(ps); IOUtils.closeQuietly(os); }
From source file:com.sketchy.server.JsonServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); String pathInfo = request.getPathInfo(); if (pathInfo.startsWith("/")) pathInfo = StringUtils.substringAfter(pathInfo, "/"); String action = ACTION_PACKAGE + pathInfo; JSONServletResult jsonServletResult = null; try {//from www. j a v a 2 s .co m ServletAction servletAction = ServletAction.getInstance(action); jsonServletResult = servletAction.execute(request); } catch (ClassNotFoundException e) { jsonServletResult = new JSONServletResult(Status.ERROR, "ServletAction '" + pathInfo + "' not found! " + e.getMessage()); } catch (Exception e) { jsonServletResult = new JSONServletResult(Status.ERROR, "Unexpected Exception from ServletAction '" + pathInfo + "'! " + e.getMessage()); } response.setStatus(HttpServletResponse.SC_OK); response.getWriter().println(jsonServletResult.toJSONString()); }
From source file:org.apache.airavata.datacat.parsers.gridchem.GridChemParser.java
private HashMap<String, String> loadAndParse(String classname, final FileReader reader) throws Exception { ClassLoader classLoader = ClassLoader.getSystemClassLoader(); Class parser = null;/* ww w . j a va 2 s .c o m*/ try { //todo: handle unparsed documents and log and ignore parser = classLoader.loadClass(classname); Constructor parserConstructor = parser.getConstructor(FileReader.class); GridChemQueueParser queueParser = (GridChemQueueParser) parserConstructor.newInstance(reader); HashMap<String, String> parsedData = queueParser.getParsedData(); return parsedData; } catch (ClassNotFoundException e) { logger.error("Could not load the class ..." + e.getMessage()); } catch (NoSuchMethodException e) { logger.error("Could not load the constructor ... " + e.getMessage()); } catch (InvocationTargetException e) { logger.error("Could not load the Class ... " + e.getMessage()); } catch (InstantiationException e) { logger.error("Could not load the Class ... " + e.getMessage()); } catch (IllegalAccessException e) { logger.error("Could not load the Class ... " + e.getMessage()); } return null; }
From source file:gridool.db.partitioning.monetdb.MonetDBPrepareCopyIntoOperation.java
@Override public Serializable execute() throws SQLException { final boolean firstTry = (createTableDDL != null); if (firstTry) {// prepare a table final Connection conn; try {//from ww w. j ava 2 s . com conn = getConnection(); } catch (ClassNotFoundException e) { LOG.error(e); throw new SQLException(e.getMessage()); } try { JDBCUtils.update(conn, createTableDDL); } catch (SQLException e) { conn.rollback(); if (LOG.isDebugEnabled()) { LOG.debug("Table already exists. Try to truncate " + tableName, e); } truncateTable(conn, tableName); // fall through } } prepareLoadFile(tableName, rowsData, !firstTry); this.rowsData = null; return Boolean.TRUE; }
From source file:gov.nih.nci.cacisweb.dao.virtuoso.VirtuosoCommonUtilityDAO.java
/** * This method wraps the exceptions and throws a single exception, to be handled by the calling object. * /*from ww w . j a v a2s . c o m*/ * @throws DBUnavailableException */ private void openCaCISConnection() throws DBUnavailableException { try { // DataSource dataSource = ServiceLocator.getInstance().getDataSourceByName(virtuosoDataSourceString); // cacisConnection = dataSource.getConnection(); String driverName = CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_DATABASE_VIRTUOSO_DRIVER); Class.forName(driverName); // Create a connection to the database cacisConnection = DriverManager.getConnection( CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_DATABASE_VIRTUOSO_URL), CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_DATABASE_VIRTUOSO_USERNAME), CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_DATABASE_VIRTUOSO_PASSWORD)); } catch (SQLException sqle) { log.error(sqle.getMessage()); throw new DBUnavailableException(sqle.getMessage()); // } catch (ServiceLocatorException sle) { // log.error(sle.getMessage()); // throw new DBUnavailableException(sle.getMessage()); } catch (ClassNotFoundException e) { log.error(e.getMessage()); throw new DBUnavailableException(e.getMessage()); } catch (CaCISWebException e) { log.error(e.getMessage()); throw new DBUnavailableException(e.getMessage()); } }
From source file:productClass.java
private Connection getConnection() throws SQLException { String url = "jdbc:as400:174.79.32.158"; String username = "IBM65"; String password = "IBM65"; Connection conn = null;/*w w w .j av a 2 s .c o m*/ try { Class.forName("com.ibm.as400.access.AS400JDBCDriver"); } catch (ClassNotFoundException e) { System.out.println("Class Not found " + e.getMessage()); } try { conn = DriverManager.getConnection(url, username, password); } catch (SQLException e) { System.out.println("SQL Error " + e.getMessage()); } return conn; }
From source file:net.ontopia.topicmaps.nav2.plugins.PluginContentHandler.java
private PluginIF createPlugin(String klass) { try {/*from w ww. j a v a 2 s .c om*/ ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Class pclass = Class.forName(klass, true, classLoader); return (PluginIF) pclass.newInstance(); } catch (ClassNotFoundException e) { log.error("Couldn't find class of plugin " + klass + ": " + e.getMessage()); PluginIF plugin = new DefaultPlugin(); plugin.setState(PluginIF.ERROR); return plugin; } catch (InstantiationException e) { log.error("Couldn't instantiate plugin (" + klass + "): " + e.getMessage()); } catch (IllegalAccessException e) { log.error("Couldn't access plugin instance " + klass + ": " + e.getMessage()); } catch (NoClassDefFoundError e) { log.error("Couldn't find class definition of plugin " + klass + ": " + e.getMessage()); } return null; }
From source file:ProductServlet.java
private Connection getConnection() throws SQLException, ClassNotFoundException { Connection conn = null;/*from w ww . j a va 2 s . c om*/ try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException ex) { System.err.println("JDBC Driver Not Found: " + ex.getMessage()); } try { String jdbc = "jdbc:mysql://ipro.lambton.on.ca/inventory"; conn = DriverManager.getConnection(jdbc, "products", "products"); } catch (SQLException ex) { System.err.println("Failed to Connect: " + ex.getMessage()); } return conn; }
From source file:SessionLogin.java
public void init(ServletConfig config) throws ServletException { super.init(config); try {//from w ww. j a va2 s. c o m // load the driver Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); } catch (ClassNotFoundException e) { throw new UnavailableException("Login init() ClassNotFoundException: " + e.getMessage()); } catch (IllegalAccessException e) { throw new UnavailableException("Login init() IllegalAccessException: " + e.getMessage()); } catch (InstantiationException e) { throw new UnavailableException("Login init() InstantiationException: " + e.getMessage()); } }
From source file:edu.jhu.hlt.parma.inference.transducers.StringEditModelTrainer.java
private StringEditModel readModel(String filename) { System.err.println("Reading model from: " + filename); try {//from w w w.j a v a2 s .co m ObjectInputStream objIn = new ObjectInputStream(new FileInputStream(filename)); return (StringEditModel) objIn.readObject(); } catch (IOException e) { System.out.println(e.getMessage()); e.printStackTrace(); System.exit(1); } catch (ClassNotFoundException c) { System.out.println(c.getMessage()); c.printStackTrace(); System.exit(1); } return null; }