Example usage for java.lang ClassNotFoundException printStackTrace

List of usage examples for java.lang ClassNotFoundException printStackTrace

Introduction

In this page you can find the example usage for java.lang ClassNotFoundException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.softberries.klerk.dao.CompanyDao.java

@Override
public List<Company> findAll() throws SQLException {
    List<Company> companies = new ArrayList<Company>();
    try {/*from   ww w .  j  av  a 2  s.c o m*/
        init();
        ResultSetHandler<List<Company>> h = new BeanListHandler<Company>(Company.class);
        companies = run.query(conn, SQL_FIND_COMPANY_ALL, h);
        // find addresses
        AddressDao adrDao = new AddressDao();
        for (Company c : companies) {
            c.setAddresses(adrDao.findAllByCompanyId(c.getId(), run, conn));
        }
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } finally {
        close(conn, st, generatedKeys);
    }
    return companies;
}

From source file:org.apache.nifi.processors.r.RProcessor.java

protected void setupScriptingContainers(final ProcessContext context, int numberOfContainers) {
    engineQ = new LinkedBlockingQueue<>(numberOfContainers);
    ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
    try {//from w w  w .ja v a 2 s .  c o m
        ComponentLog log = getLogger();

        for (int i = 0; i < numberOfContainers; i++) {
            try {
                REngine rEngine = setupScriptingContainer(context);
                if (!engineQ.offer(rEngine)) {
                    log.error("Error adding R script container");
                }
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
                log.error("Error adding R script container: ClassNotFoundException");
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
                log.error("Error adding R script container: NoSuchMethodException");
            } catch (InvocationTargetException e) {
                e.printStackTrace();
                log.error("Error adding R script container: InvocationTargetException");
            } catch (IllegalAccessException e) {
                e.printStackTrace();
                log.error("Error adding R script container: IllegalAccessException");
            }

        }
    } finally {
        // Restore original context class loader
        Thread.currentThread().setContextClassLoader(originalContextClassLoader);
    }
}

From source file:br.inpe.XSDMiner.MineXSD.java

@Override
public void process(SCMRepository repo, Commit commit, PersistenceMechanism writer) {

    String projectName = "";
    String fullName = "";

    try {// w  w  w  . j  a  v  a2s  .  c  o  m
        if (!commit.getBranches().contains("master"))
            return;

        if (commit.isMerge())
            return;

        Class.forName("org.postgresql.Driver");
        projectName = repo.getPath().substring(repo.getPath().lastIndexOf("/") + 1);

        for (Modification m : commit.getModifications()) {
            String fName = m.getFileName();
            String addrem = "";
            String fullNameNew = m.getNewPath();
            String fullNameOld = m.getOldPath();
            if (fullNameNew.equals("/dev/null")) {
                addrem = "r";
                fullName = fullNameOld;
            } else {
                fullName = fullNameNew;
            }

            if (fullNameOld.equals("/dev/null")) {
                addrem = "a";
            }

            String fileExtension = fName.substring(fName.lastIndexOf(".") + 1);

            boolean isWSDL = fileExtension.equals("wsdl");
            boolean isXSD = fileExtension.equals("xsd");

            if (!(isWSDL || isXSD))
                continue;

            InputStream input = new ByteArrayInputStream(m.getSourceCode().getBytes(StandardCharsets.UTF_8));
            ByteArrayOutputStream outputXSD = new ByteArrayOutputStream();

            String[] schemas;
            if (fileExtension.equals("wsdl")) {
                XSDExtractor.wsdlToXSD(input, outputXSD);
                schemas = XSDExtractor.splitXSD(outputXSD.toString());

            } else {
                outputXSD.write(IOUtils.toString(input).getBytes());
                schemas = new String[1];
                schemas[0] = outputXSD.toString();
            }

            String url = "jdbc:postgresql://localhost/xsdminer";
            Properties props = new Properties();
            props.setProperty("user", "postgres");
            props.setProperty("password", "070910");
            Connection conn = DriverManager.getConnection(url, props);

            int schemaCount = schemas.length;

            for (int i = 0; i < schemaCount; i++) {
                String query = "INSERT INTO files VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
                PreparedStatement st = conn.prepareStatement(query);
                st.setInt(1, i + 1);
                st.setString(2, fullName);
                st.setString(3, projectName);
                st.setString(4, commit.getHash());
                st.setTimestamp(5, new java.sql.Timestamp(commit.getDate().getTimeInMillis()));
                st.setString(6, schemas[i]);
                st.setString(7, addrem);
                st.setBoolean(8, false);
                st.executeUpdate();
                st.close();
            }
            conn.close();
        }
    } catch (IOException ex) {
        Logger.getLogger(MineXSD.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        System.out.println("Failure - Project " + projectName + "; file: " + fullName);
        //e.printStackTrace();
    } finally {
        repo.getScm().reset();
    }
}

From source file:dbservlet.Servlet.java

public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    try {/*from w w w.  ja v a2 s.co m*/

        update(request, response);

    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.neo4j.ogm.auth.AuthenticationTest.java

private boolean isRunningWithNeo4j2Dot2OrLater() throws Exception {
    Class<?> versionClass = null;
    BigDecimal version = new BigDecimal(2.1);
    try {/*w  w  w. j a v  a 2  s.c  o  m*/
        versionClass = Class.forName("org.neo4j.kernel.Version");
        Method kernelVersion23x = versionClass.getDeclaredMethod("getKernelVersion", null);
        version = new BigDecimal(((String) kernelVersion23x.invoke(null)).substring(0, 3));
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        try {
            Method kernelVersion22x = versionClass.getDeclaredMethod("getKernelRevision", null);
            version = new BigDecimal(((String) kernelVersion22x.invoke(null)).substring(0, 3));
        } catch (NoSuchMethodException e1) {
            throw new RuntimeException("Unable to find a method to get Neo4js kernel version");
        }

    }
    return version.compareTo(new BigDecimal("2.1")) > 0;
}

From source file:eu.optimis.ip.gui.client.resources.Accounting.java

/**
 * If DB server is not running, runs it.
 * If Database tables are not created, it creates them.
 * Also prepares all the SQL statements.
 *//*from ww w  .  ja v  a 2s .  co m*/
private void start() {
    serverThread.startServer();
    try {
        Class.forName(dbconfig.getString("driver"));
    } catch (ClassNotFoundException ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex.getMessage(), ex);
    }

    // If SA user has no password (because the DB does not exist), it creates the SA user and a read-only-user
    try {
        Connection saConnection = DriverManager.getConnection(dbconfig.getString("url"),
                dbconfig.getString("sa.username"), "");
        PreparedStatement ps = saConnection
                .prepareStatement("SET PASSWORD '" + dbconfig.getProperty("sa.password") + "';");
        ps.executeUpdate();
        ps.close();
        saConnection.close();
    } catch (SQLInvalidAuthorizationSpecException ex) {
        Logger.getLogger(Accounting.class.getName()).log(Level.INFO,
                "SA user has already a password. Neither new users are creater nor permissions are re-assigned");
    } catch (SQLException ex) {
        ex.printStackTrace();
    }

    try {
        connection = DriverManager.getConnection(dbconfig.getString("url"), dbconfig.getString("sa.username"),
                dbconfig.getString("sa.password"));
        createDB();

    } catch (SQLException ex) {
        Logger.getLogger(Accounting.class.getName()).log(Level.SEVERE, null, ex);
    }

    // Drops already defined RO (read-only) user, and creates a new with the password specified in scheduler.properties
    try {
        PreparedStatement ps = connection
                .prepareStatement("DROP USER " + dbconfig.getProperty("ro.username") + ";");
        ps.executeUpdate();
        ps.close();
    } catch (SQLInvalidAuthorizationSpecException ex) {
        Logger.getLogger(Accounting.class.getName()).log(Level.INFO,
                "Don't dropping read-only user because does not exist. Creating...");
    } catch (SQLException ex) {
        Logger.getLogger(Accounting.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
    }
}

From source file:com.phonegap.api.PluginManager.java

/**
 * Add plugin to be loaded and cached.  This creates an instance of the plugin.
 * If plugin is already created, then just return it.
 * /*from www  .j  a  v  a2 s  .  c  o  m*/
 * @param className            The class to load
 * @return                  The plugin
 */
public Plugin addPlugin(String className) {
    try {
        return this.addPlugin(className, this.getClassByName(className));
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        System.out.println("Error adding plugin " + className + ".");
    }
    return null;
}

From source file:ClassFigure.java

protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new FillLayout());

    canvas = new Canvas(composite, SWT.NULL);
    canvas.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));

    LightweightSystem lws = new LightweightSystem(canvas);
    contents = new Figure();
    xyLayout = new XYLayout();
    contents.setLayoutManager(xyLayout);

    lws.setContents(contents);//from  w  w  w  .  ja  v  a2 s.  c  om

    showClass(this.getClass());

    // Creates tool bar items.
    getToolBarManager().add(new Action("Set class ...") {
        public void run() {
            InputDialog dialog = new InputDialog(getShell(), "", "Please enter the class name", "", null);
            if (dialog.open() != Dialog.OK)
                return;

            contents.removeAll();
            Class cls = null;
            try {
                cls = Class.forName(dialog.getValue());
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            if (cls != null) {
                showClass(cls);
            }
        }
    });
    getToolBarManager().update(true);

    return composite;
}

From source file:gov.nih.nci.migration.MigrationDriver.java

private Connection getConnection() {
    Connection connection = null;
    try {//from   w w w. ja  v  a2 s . c  om
        // Load the JDBC driver
        Class.forName(DATABASE_DRIVER);

        // Create a connection to the database
        String url = DATABASE_URL;
        /*
        String url ="";
        if("MySQL".equalsIgnoreCase(DATABASE_TYPE)){
         url = "jdbc:mysql://" + DATABASE_SERVER_NAME  +":"+DATABASE_SERVER_PORT_NUMBER+  "/" + DATABASE_NAME; // a JDBC url
        }
        if("Oracle".equalsIgnoreCase(DATABASE_TYPE)){
         url = "jdbc:oracle:thin:@" + DATABASE_SERVER_NAME + ":" + DATABASE_SERVER_PORT_NUMBER + ":" + DATABASE_NAME;
        }
        if("SQLServer".equalsIgnoreCase(DATABASE_TYPE)){
          url = "jdbc:JSQLConnect://" + DATABASE_SERVER_NAME + ":" + DATABASE_SERVER_PORT_NUMBER; // a JDBC url
        }
        */
        connection = DriverManager.getConnection(url, DATABASE_USERNAME, DATABASE_PASSWORD);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        // Could not find the database driver
    } catch (SQLException e) {
        e.printStackTrace();
        // Could not connect to the database
    }
    /*
              try {
            
      DatabaseMetaData dmd = connection.getMetaData();
      if (dmd.supportsResultSetConcurrency(
          ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE)) {
          // Updatable result sets are supported
      } else {
          // Updatable result sets are not supported
         return null;
      }
              } catch (SQLException e) {
              }
    */

    return connection;
}

From source file:hugonicolau.openbrailleinput.wordcorrection.BrailleWordCorrection.java

private float[] loadFrequencies(InputStream is) throws StreamCorruptedException, IOException {
    BufferedInputStream bis = new BufferedInputStream(is, 8 * 1024);
    ObjectInputStream ois = new ObjectInputStream(bis);

    float[] floats = null;

    try {/*from   www. ja  va2 s  .  c  om*/
        floats = (float[]) ois.readObject();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }

    return floats;
}