List of usage examples for java.lang NullPointerException printStackTrace
public void printStackTrace()
From source file:jdbc.pool.JDBCPoolOracleConnectionTest.java
public void testEmptyAllPools() { System.out.println("testEmptyAllPools Start"); testGetInstanceNull();// w ww.ja va2 s .c o m CConnectionPoolManager manager = null; try { manager = create(); Connection con = manager.getConnection("ORACLE"); // MYSQL is load // on startup. con.close(); manager.emptyAllPools(false); try { manager.getPoolStatistics("ORACLE"); fail("Should have thrown NullPointerException."); } catch (NullPointerException e) { assertTrue("Caught NullPointerException", true); } try { manager.getPoolStatistics("MYSQL"); fail(); } catch (NullPointerException e) { assertTrue("Caught NullPointerException", true); } } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } finally { manager.destroy(true); testGetInstanceNull(); } System.out.println("testEmptyAllPools end."); }
From source file:edu.harvard.iq.dvn.ingest.dsb.impl.DvnRDataAnalysisServiceImpl.java
/** ************************************************************* * returns zelig-configuration data as an XML string * * @return XML string/*from w w w . ja va 2 s . co m*/ */ public String getGUIconfigData() { String zlgcnfg = null; try { // get connected to Rserve //String RSERVE_HOST = "vdc-build.hmdc.harvard.edu";//"140.247.115.232" //int RSERVE_PORT = 6311; RConnection c = new RConnection(RSERVE_HOST, RSERVE_PORT); // login(String user, String pwd) //String RSERVE_USER = "rserve"; //String RSERVE_PWD = "rserve"; c.login(RSERVE_USER, RSERVE_PWD); // get the hostname of the caller String hostname = null; Map<String, String> env = System.getenv(); for (String envName : env.keySet()) { if (envName.equals("HOST")) { hostname = env.get(envName); } } dbgLog.fine("hostname=" + hostname); setupWorkingDirectory(c); // set-up R command lines // temp file String R_TMP_DIR = "/tmp/VDC/"; // Why is this directory hard-coded here? Wasn't the point of // running setupWorkingDirectory, in the previous step, to set // up the configured directories? -- L.A. //String cnfgfl = R_TMP_DIR +"configZeligGUI."+RandomStringUtils.randomNumeric(6)+ ".xml"; String cnfgfl = R_TMP_DIR + "configZeligGUI.xml"; dbgLog.fine("cnfgfl=" + cnfgfl); // remove the existing config file if exists String removeOLdLine = "if (file.exists('" + cnfgfl + "')){file.remove('" + cnfgfl + "');}"; c.voidEval(removeOLdLine); // R code line part 1 String cmndline = "library(VDCutil); printZeligSchemaInstance('" + cnfgfl + "')"; // cnfgfl + "'," + "'" + RSERVE_HOST + "')"; dbgLog.fine("comand line=" + cmndline); // write zelig GUI-config data to the temp ifle c.voidEval(cmndline); //dbgLog.fine("commandline output="+outString); // check whether the temp file exists (Rserve is local) long filelength = 0; try { if (RSERVE_HOST.equals("localhost") || RSERVE_HOST.equals(hostname)) { File flnm = new File(cnfgfl); boolean exists = flnm.exists(); if (exists) { dbgLog.fine("configuration xml file (" + cnfgfl + ") was found"); filelength = flnm.length(); // Get the number of bytes in the file dbgLog.fine("The size of the file =" + filelength); } else { dbgLog.fine("configuration xml file (" + cnfgfl + ") was not found"); } } } catch (NullPointerException e) { e.printStackTrace(); } //if (filelength > 0){ // read-back the config file c.voidEval("zz<-file('" + cnfgfl + "', 'r')"); c.voidEval("open(zz)"); zlgcnfg = c.eval("paste(readLines(zz),collapse='')").asString(); dbgLog.fine("string length=" + zlgcnfg.length()); if (zlgcnfg.length() > 0) { dbgLog.fine("first 20 bytes=[\n" + zlgcnfg.substring(0, 19) + "\n]\n"); } //} } catch (Exception ex) { ex.printStackTrace(); } return zlgcnfg; }
From source file:jdbc.pool.JDBCPoolOracleConnectionTest.java
public void testForceShutdown() { System.out.println("testForceShutdown Start"); testGetInstanceNull();//from w w w . j a va2s .c o m CConnectionPoolManager manager = null; try { manager = create(); Connection con = manager.getConnection("ORACLE"); // MYSQL is load // on startup. manager.emptyAllPools(true); if (con instanceof ConnectionWrapper) { ConnectionWrapper realCon = (ConnectionWrapper) con; assertTrue("Is realConnection closed?", realCon.realConnection().isClosed()); } assertTrue("Passed. Even if the pool was in use it did not throw any exception.", true); try { manager.getPoolStatistics("ORACLE"); fail("Should have thrown NullPointerException."); } catch (NullPointerException e) { assertTrue("Caught NullPointerException", true); } try { manager.getPoolStatistics("ORACLE"); fail(); } catch (NullPointerException e) { assertTrue("Caught NullPointerException", true); } } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } finally { manager.destroy(true); testGetInstanceNull(); } System.out.println("testForceShutdown end."); }
From source file:edu.ucsd.sbrg.escher.model.EscherMap.java
/** * Post-processes {@link EscherMap} and populates internal helper fields. *//*w w w .j av a 2 s .c o m*/ public void processMap() { try { // Set mid-marker for every reaction by going through its nodes and checking which // one is a mid-marker. reactions.forEach((k, r) -> { r.getNodes().forEach((s) -> { if (nodes.get(s).getType() == Node.Type.midmarker) { r.setMidmarker(nodes.get(s)); } }); }); // Set nodeRefIds for metabolites. reactions.forEach((k, r) -> { r.getMetabolites().forEach((mk, mv) -> { r.getNodes().forEach((s) -> { try { Node node = nodes.get(s); if (node.getBiggId() == null) { return; } if (node.getBiggId().equals(mv.getId())) { mv.setNodeRefId(node.getId()); } } catch (NullPointerException ex) { ex.getMessage(); } }); }); }); // Bigg2Reactions. reactions.forEach((k, v) -> { if (!bigg2reactions.containsKey(v.getBiggId())) { Set<String> reactionSet = new HashSet<>(); reactionSet.add(v.getId()); bigg2reactions.put(v.getBiggId(), reactionSet); } }); // Bigg2Nodes. nodes.forEach((k, v) -> { if (v.getBiggId() == null) { return; } if (!bigg2nodes.containsKey(v.getBiggId())) { Set<String> nodeSet = new HashSet<>(); nodeSet.add(v.getId()); bigg2nodes.put(v.getBiggId(), nodeSet); } else { bigg2nodes.get(v.getBiggId()).add(v.getId()); } }); // Store compartments. nodes.forEach((k, v) -> { EscherCompartment compartment = new EscherCompartment(); if (v.getCompartment() == null) { return; } compartment.setId(v.getCompartment()); if (!compartments.containsKey(compartment.getId())) { compartments.put(compartment.getId(), compartment); } }); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
@Override protected void onDestroy() { try {/* ww w.ja v a 2s . co m*/ closeKeyBoard(); } catch (NullPointerException e) { e.printStackTrace(); } super.onDestroy(); }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
public void savedAFile(GreatUri uri, boolean updateList) { if (uri != null) { greatUri = uri;//from w w w. ja v a2s . co m String name = uri.getFileName(); fileExtension = FilenameUtils.getExtension(name).toLowerCase(); toolbar.setTitle(name); if (updateList) { refreshList(uri, true, false); arrayAdapter.selectPosition(uri); } } mEditor.clearHistory(); mEditor.fileSaved(); invalidateOptionsMenu(); try { closeKeyBoard(); } catch (NullPointerException e) { e.printStackTrace(); } }
From source file:eu.brokeratcloud.fpr.model.DivaRoot.java
public void runSimulation(Boolean isAdmin) { ServiceCategory serviceCategory = ServiceCategory.INSTANCE; Map<String, String> remember = new HashMap<String, String>(); if (isAdmin) { for (Dimension dim : root.getDimension()) for (Variant variant : dim.getVariant()) { String dep = null; try { dep = variant.getDependency().getText(); } catch (NullPointerException e) { continue; }/*w w w.j av a 2 s . c om*/ if (dep == null || dep.length() == 0) continue; List<String> atoms = ServiceDependency.INSTANCE.getDependency(variant.getId()); List<String> strauss = new ArrayList<String>(); for (String atom : atoms) { List<String> group = serviceCategory.getGroup(atom.trim()); if (group != null && group.size() != 0) { String alternative = org.apache.commons.lang.StringUtils.join(group, " or "); strauss.add("(" + alternative + ")"); } } String alternative = org.apache.commons.lang.StringUtils.join(strauss, " and "); remember.put(variant.getName(), dep); variant.getDependency().setText(alternative); try { Term term = DivaExpressionParser.parse(root, alternative.trim()); variant.getDependency().setTerm(term); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } _runSimulation(); if (isAdmin) { for (Dimension dim : root.getDimension()) for (Variant variant : dim.getVariant()) { String original = remember.get(variant); if (original == null || original.length() == 0) continue; variant.getDependency().setText(original); try { Term term = DivaExpressionParser.parse(root, original.trim()); variant.getDependency().setTerm(term); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
/** * Setup the navigation drawer/*from ww w . ja v a2s . c o m*/ */ private void setupNavigationDrawer() { mDrawerLayout = (CustomDrawerLayout) findViewById(R.id.drawer_layout); /* Action Bar final ActionBar ab = toolbar; ab.setDisplayHomeAsUpEnabled(true); ab.setHomeButtonEnabled(true);*/ /* Navigation drawer */ mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.nome_app_turbo_editor, R.string.nome_app_turbo_editor) { @Override public void onDrawerOpened(View drawerView) { supportInvalidateOptionsMenu(); try { closeKeyBoard(); } catch (NullPointerException e) { e.printStackTrace(); } } @Override public void onDrawerClosed(View view) { supportInvalidateOptionsMenu(); } }; /* link the mDrawerToggle to the Drawer Layout */ mDrawerLayout.setDrawerListener(mDrawerToggle); //mDrawerLayout.setFocusableInTouchMode(false); ListView listView = (ListView) findViewById(android.R.id.list); listView.setEmptyView(findViewById(android.R.id.empty)); greatUris = new LinkedList<>(); arrayAdapter = new AdapterDrawer(this, greatUris, this); listView.setAdapter(arrayAdapter); listView.setOnItemClickListener(this); }
From source file:jdbc.pool.JDBCPoolMySQLTest.java
public void testEmptyAllPools() { testGetInstanceNull();//from w w w . ja v a 2 s .co m logger.debug("testEmptyAllPools Start"); CConnectionPoolManager manager = null; try { manager = create(); Connection con = manager.getConnection("MYSQL2"); // MYSQL is load // on startup. con.close(); manager.emptyAllPools(false); try { manager.getPoolStatistics("MYSQL2"); fail("Should have thrown NullPointerException."); } catch (NullPointerException e) { assertTrue("Caught NullPointerException", true); } try { manager.getPoolStatistics("MYSQL"); fail(); } catch (NullPointerException e) { assertTrue("Caught NullPointerException", true); } } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } finally { manager.destroy(true); testGetInstanceNull(); } logger.debug("testEmptyAllPools end."); }
From source file:jdbc.pool.JDBCPoolMySQLTest.java
public void testForceShutdown() { testGetInstanceNull();/*from w ww . ja va 2 s. c o m*/ logger.debug("testForceShutdown Start"); CConnectionPoolManager manager = null; try { manager = create(); Connection con = manager.getConnection("MYSQL2"); // MYSQL is load // on startup. manager.emptyAllPools(true); if (con instanceof ConnectionWrapper) { ConnectionWrapper realCon = (ConnectionWrapper) con; assertTrue("Is realConnection closed?", realCon.realConnection().isClosed()); } assertTrue("Passed. Even if the pool was in use it did not throw any exception.", true); try { manager.getPoolStatistics("MYSQL2"); fail("Should have thrown NullPointerException."); } catch (NullPointerException e) { assertTrue("Caught NullPointerException", true); } try { manager.getPoolStatistics("MYSQL"); fail(); } catch (NullPointerException e) { assertTrue("Caught NullPointerException", true); } } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } finally { manager.destroy(true); testGetInstanceNull(); } logger.debug("testForceShutdown end."); }