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:de.tudarmstadt.ukp.similarity.experiments.coling2012.util.StopwordFilter.java

@SuppressWarnings("unchecked")
@Override/*  w  ww. ja  v  a2s  . c om*/
public void initialize(UimaContext context) throws ResourceInitializationException {
    super.initialize(context);

    try {
        annotationType = (Class<? extends Annotation>) Class.forName(annotationTypeName);
    } catch (ClassNotFoundException e) {
        throw new ResourceInitializationException(e);
    }

    PathMatchingResourcePatternResolver r = new PathMatchingResourcePatternResolver();
    Resource res = r.getResource(stopwordList);

    File f;
    try {
        f = res.getFile();
    } catch (IOException e) {
        throw new ResourceInitializationException(e);
    }

    try {
        loadStopwords(new FileInputStream(f));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:assignment3.Populate.java

CreateReview() {

    try {//from  www.j a  va  2s  .  co m

        Class.forName("oracle.jdbc.driver.OracleDriver");

    } catch (ClassNotFoundException e) {

        System.out.println("JDBC Driver Missing");
        e.printStackTrace();
        return;

    }

    System.out.println("Oracle JDBC Driver Connected");

    Connection conn = null;
    PreparedStatement ps = null;
    try {

        conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "MAYUR", "123456");

        JSONParser parser = new JSONParser();
        BufferedReader br = new BufferedReader(new FileReader(
                "C:\\Users\\mayur\\Downloads\\YelpDataset\\YelpDataset-CptS451\\yelp_review.json"));
        // BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\mayur\\Downloads\\YelpDataset\\YelpDataset-CptS451\\reviewshortfile.json"));

        int batch = 250;
        int count = 0;
        String sCurrentLine = "";
        String temp = "";
        while ((sCurrentLine = br.readLine()) != null) {

            conn.setAutoCommit(false);

            Object obj = parser.parse(sCurrentLine);

            JSONObject t = (JSONObject) obj;

            JSONObject votes = (JSONObject) t.get("votes"); // get all votes details
            Long votes_funny = (Long) votes.get("funny");
            Long votes_useful = (Long) votes.get("useful");
            Long votes_cool = (Long) votes.get("cool");
            String user_id = t.get("user_id").toString();
            String review_id = t.get("review_id").toString();
            Long stars = (Long) t.get("stars");
            String c = t.get("date").toString();
            Date review_date = (Date) java.sql.Date.valueOf(c);

            String text = t.get("text").toString();
            if (text.length() > 1600) {
                temp = text.substring(0, 1600);
                text = "";
                text = temp;
                System.out.println("String truncated " + text.length() + "at record" + count);
                temp = "";
            }
            String type = t.get("type").toString();
            String business_id = t.get("business_id").toString();

            ps = conn.prepareStatement("insert into review values (?, ?, ?,?, ?, ?,?, ?, ?,?)");

            ps.setLong(1, votes_funny);
            ps.setLong(2, votes_useful);
            ps.setLong(3, votes_cool);
            ps.setString(4, user_id);
            ps.setString(5, review_id);
            ps.setLong(6, stars);
            ps.setDate(7, review_date);

            ps.setString(8, text);

            ps.setString(9, type);
            ps.setString(10, business_id);

            ps.executeUpdate();
            count++;
            System.out.println("Record Number :" + count);
            if (count % batch == 0) {
                conn.commit();
                ps.close();
                conn.close();
                conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "MAYUR", "123456");

            }

        }

        System.out.println("Record inserted Finally in Review Table " + count);
        conn.commit();
        ps.close();
        conn.close();

    } catch (Exception e) {

        System.out.println("Connection Failed! Check output console");
        e.printStackTrace();
        return;

    } finally {
        try {
            ps.close();
            conn.close();
        } catch (Exception e) {

        }
    }

}

From source file:org.cfr.capsicum.propertyset.CayenneRuntimeContextProvider.java

@SuppressWarnings("unchecked")
@Override/* w  w  w .  jav  a2s . c  o  m*/
public void setup(Map<String, Object> configurationProperties) {
    DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
    if (this.cayenneRuntimeContext != null) {
        throw new RuntimeException("CayenneRuntimeContextProvider is already configured.");
    }
    ServerRuntimeFactoryBean factory = new ServerRuntimeFactoryBean();
    DataDomainDefinition dataDomainDefinition = new DataDomainDefinition();
    dataDomainDefinition.setDomainResource(resourceLoader.getResource("classpath:cayenne-propertyset.xml"));
    factory.setDataDomainDefinitions(Lists.newArrayList(dataDomainDefinition));
    dataDomainDefinition.setName(DOMAIN_NAME);

    Iterator<String> itr = configurationProperties.keySet().iterator();
    while (itr.hasNext()) {
        String key = itr.next();

        if (key.startsWith(ICayenneConfigurationProvider.DATASOURCE_PROPERTY_KEY)) {
            dataDomainDefinition.setDataSource((DataSource) configurationProperties.get(key));
            factory.setDataSource((DataSource) configurationProperties.get(key));
        }
        if (key.startsWith(ICayenneConfigurationProvider.ADAPTER_PROPERTY_KEY)) {
            try {
                dataDomainDefinition.setAdapterClass((Class<? extends DbAdapter>) ClassLoaderUtils
                        .loadClass((String) configurationProperties.get(key), this.getClass()));
            } catch (ClassNotFoundException e) {
                throw new CayenneRuntimeException(e);
            }
        }
        if (key.startsWith(ICayenneConfigurationProvider.SCHEMA_UPDATE_STRATEGY_PROPERTY_KEY)) {
            dataDomainDefinition.setSchemaUpdateStrategy(
                    (Class<? extends SchemaUpdateStrategy>) configurationProperties.get(key));
        }

    }
    try {
        factory.afterPropertiesSet();
        this.cayenneRuntimeContext = factory;

    } catch (Exception e) {
        ///CLOVER:OFF
        e.printStackTrace();
        ///CLOVER:ON
    }
}

From source file:com.web.server.SARDeployer.java

/**
 * This method extracts the SAR archive and configures for the SAR and starts the services
 * @param file//from  ww w .java2  s . c o m
 * @param warDirectoryPath
 * @throws IOException
 */
public void extractSar(File file, String warDirectoryPath) throws IOException {
    ZipFile zip = new ZipFile(file);
    ZipEntry ze = null;
    String fileName = file.getName();
    fileName = fileName.substring(0, fileName.indexOf('.'));
    fileName += "sar";
    String fileDirectory;
    CopyOnWriteArrayList classPath = new CopyOnWriteArrayList();
    Enumeration<? extends ZipEntry> entries = zip.entries();
    int numBytes;
    while (entries.hasMoreElements()) {
        ze = entries.nextElement();
        // //System.out.println("Unzipping " + ze.getName());
        String filePath = deployDirectory + "/" + fileName + "/" + ze.getName();
        if (!ze.isDirectory()) {
            fileDirectory = filePath.substring(0, filePath.lastIndexOf('/'));
        } else {
            fileDirectory = filePath;
        }
        // //System.out.println(fileDirectory);
        createDirectory(fileDirectory);
        if (!ze.isDirectory()) {
            FileOutputStream fout = new FileOutputStream(filePath);
            byte[] inputbyt = new byte[8192];
            InputStream istream = zip.getInputStream(ze);
            while ((numBytes = istream.read(inputbyt, 0, inputbyt.length)) >= 0) {
                fout.write(inputbyt, 0, numBytes);
            }
            fout.close();
            istream.close();
            if (ze.getName().endsWith(".jar")) {
                classPath.add(filePath);
            }
        }
    }
    zip.close();
    URLClassLoader loader = (URLClassLoader) ClassLoader.getSystemClassLoader();
    URL[] urls = loader.getURLs();
    WebClassLoader sarClassLoader = new WebClassLoader(urls);
    for (int index = 0; index < classPath.size(); index++) {
        System.out.println("file:" + classPath.get(index));
        new WebServer().addURL(new URL("file:" + classPath.get(index)), sarClassLoader);
    }
    new WebServer().addURL(new URL("file:" + deployDirectory + "/" + fileName + "/"), sarClassLoader);
    sarsMap.put(fileName, sarClassLoader);
    System.out.println(sarClassLoader.geturlS());
    try {
        Sar sar = (Sar) sardigester.parse(new InputSource(
                new FileInputStream(deployDirectory + "/" + fileName + "/META-INF/" + "mbean-service.xml")));
        CopyOnWriteArrayList mbeans = sar.getMbean();
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        System.out.println(mbs);
        ObjectName objName;
        for (int index = 0; index < mbeans.size(); index++) {
            Mbean mbean = (Mbean) mbeans.get(index);
            System.out.println(mbean.getObjectname());
            System.out.println(mbean.getCls());
            objName = new ObjectName(mbean.getObjectname());
            Class helloWorldService = sarClassLoader.loadClass(mbean.getCls());
            Object obj = helloWorldService.newInstance();
            if (mbs.isRegistered(objName)) {
                mbs.invoke(objName, "stopService", null, null);
                //mbs.invoke(objName, "destroy", null, null);
                mbs.unregisterMBean(objName);
            }
            mbs.registerMBean(obj, objName);
            CopyOnWriteArrayList attrlist = mbean.getMbeanAttribute();
            if (attrlist != null) {
                for (int count = 0; count < attrlist.size(); count++) {
                    MBeanAttribute attr = (MBeanAttribute) attrlist.get(count);
                    Attribute mbeanattribute = new Attribute(attr.getName(), attr.getValue());
                    mbs.setAttribute(objName, mbeanattribute);
                }
            }
            mbs.invoke(objName, "startService", null, null);
        }
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MalformedObjectNameException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InstanceAlreadyExistsException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MBeanRegistrationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NotCompliantMBeanException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InstanceNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ReflectionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MBeanException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvalidAttributeValueException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (AttributeNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.aegamesi.steamtrade.MainActivity.java

@Override
protected void onStart() {
    super.onStart();

    // fragments from intent
    String fragmentName = getIntent().getStringExtra("fragment");
    if (fragmentName != null) {
        Class<? extends Fragment> fragmentClass = null;
        try {//from  w  w w .ja  v  a  2 s. co  m
            fragmentClass = (Class<? extends Fragment>) Class.forName(fragmentName);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        if (fragmentClass != null) {
            Fragment fragment = null;
            try {
                fragment = fragmentClass.newInstance();
            } catch (Exception e) {
                e.printStackTrace();
            }

            if (fragment != null) {
                Bundle arguments = getIntent().getBundleExtra("arguments");
                if (arguments != null)
                    fragment.setArguments(arguments);
                browseToFragment(fragment, getIntent().getBooleanExtra("fragment_subfragment", true));
            }
        }
    }
}

From source file:uk.ac.ebi.intact.editor.controller.curate.ChangesController.java

public List<String> getDeletedAcsByClassName(String className, String parentAc) {
    try {//from   w w  w .  j a  va  2  s.co m
        return getDeletedAcs(Thread.currentThread().getContextClassLoader().loadClass(className), parentAc);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return Collections.EMPTY_LIST;
}

From source file:com.thoughtworks.selenium.SeleneseTestBaseVir.java

/**
 * Gets the default port.//from   w w w  . j a va  2 s  . com
 * 
 * @return the default port
 */
private int getDefaultPort() {
    final int num = 4444;
    try {
        Class<?> c = Class.forName("org.openqa.selenium.server.RemoteControlConfiguration");
        Method getDefaultPort = c.getMethod("getDefaultPort", new Class[0]);
        Integer portNumber = (Integer) getDefaultPort.invoke(null, new Object[0]);
        return portNumber.intValue();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (Exception e) {

        e.printStackTrace();
    }
    return Integer.getInteger("selenium.port", num).intValue();
}

From source file:org.accada.hal.impl.sim.SimulatorController.java

public SimulatorController(String halName, String propFile) {
    this.halName = halName;
    this.propFile = propFile;
    this.initialize();

    log.debug("Simulator: " + simType);
    reader = new HashMap();

    for (int i = 0; i < nOfReadPoints; i++) {
        reader.put(readPointNames[i], new HashSet());
    }/*w  ww .  j a v  a  2 s . c o  m*/

    try {
        //Dynamic class loading
        //1.) The full package path 
        Class clazz = Class.forName(simType);
        //2.) State the types of the constructors arguments. here: only one argument, of type String
        java.lang.reflect.Constructor co = clazz.getConstructor(new Class[] {});
        //3.) Create new instance with the argument's values
        simulator = (SimulatorEngine) co.newInstance(null);
        simulator.initialize(this, simTypePropFile);
    } catch (ClassNotFoundException cnfe) {
        cnfe.printStackTrace();
        System.exit(1);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:fr.cobaltians.cobalt.Cobalt.java

public Intent getIntentForController(String controller, String page) {
    Intent intent = null;/*from  w ww. ja v  a  2  s .  co  m*/

    Bundle configuration = getConfigurationForController(controller);

    if (!configuration.isEmpty()) {
        String activity = configuration.getString(kActivity);

        // Creates intent
        Class<?> pClass;
        try {
            pClass = Class.forName(activity);
            // Instantiates intent only if class inherits from Activity
            if (Activity.class.isAssignableFrom(pClass)) {
                configuration.putString(kPage, page);

                intent = new Intent(mContext, pClass);
                intent.putExtra(kExtras, configuration);
            } else if (Cobalt.DEBUG)
                Log.e(Cobalt.TAG,
                        TAG + " - getIntentForController: " + activity + " does not inherit from Activity!");
        } catch (ClassNotFoundException exception) {
            if (Cobalt.DEBUG)
                Log.e(Cobalt.TAG, TAG + " - getIntentForController: " + activity + " class not found for id "
                        + controller + "!");
            exception.printStackTrace();
        }
    }

    return intent;
}

From source file:kupkb_experiments.OntologyBuilder.java

public IDMapper getIDMApper() {

    try {//from  w w w.  ja  v  a2  s. c  o m
        System.out.println(taxonomy);
        Class.forName("org.bridgedb.rdb.IDMapperRdb");
        IDMapper idm = BridgeDb.connect(
                "idmapper-pgdb:bridgedb-1.0.2/data/gene_database/" + getSpeciesToDBMap().get(taxonomy));
        return idm;
    } catch (ClassNotFoundException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    } catch (IDMapperException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }
    return null;
}