List of usage examples for java.lang Exception getStackTrace
public StackTraceElement[] getStackTrace()
From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.IndividualTypeRetryController.java
public void doGet(HttpServletRequest request, HttpServletResponse response) { if (!isAuthorizedToDisplayPage(request, response, SimplePermission.DO_BACK_END_EDITING.ACTION)) { return;/*from ww w .java 2s . c o m*/ } //create an EditProcessObject for this and put it in the session EditProcessObject epo = super.createEpo(request); VitroRequest vreq = new VitroRequest(request); WebappDaoFactory wadf = vreq.getUnfilteredAssertionsWebappDaoFactory(); IndividualDao iDao = wadf.getIndividualDao(); VClassDao vcDao = wadf.getVClassDao(); String individualURI = request.getParameter("IndividualURI"); Individual ind = iDao.getIndividualByURI(individualURI); if (ind == null) { ind = new IndividualImpl(individualURI); } request.setAttribute("individual", ind); List<VClass> allVClasses = vcDao.getAllVclasses(); sortForPickList(allVClasses, vreq); Set<String> prohibitedURIset = new HashSet<String>(); for (Iterator<VClass> indClassIt = ind.getVClasses(false).iterator(); indClassIt.hasNext();) { VClass vc = indClassIt.next(); if (vc.isAnonymous()) { continue; } prohibitedURIset.add(vc.getURI()); for (Iterator<String> djURIIt = vcDao.getDisjointWithClassURIs(vc.getURI()).iterator(); djURIIt .hasNext();) { String djURI = djURIIt.next(); prohibitedURIset.add(djURI); } } List<VClass> eligibleVClasses = new ArrayList<VClass>(); for (VClass vc : allVClasses) { if (vc.getURI() != null && !(prohibitedURIset.contains(vc.getURI()))) { eligibleVClasses.add(vc); } } FormObject foo = new FormObject(); epo.setFormObject(foo); HashMap optionMap = new HashMap(); foo.setOptionLists(optionMap); List<Option> typeOptionList = new ArrayList<Option>(); for (VClass vc : eligibleVClasses) { Option opt = new Option(vc.getURI(), vc.getPickListName()); typeOptionList.add(opt); } optionMap.put("types", typeOptionList); RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); request.setAttribute("editAction", "individualTypeOp"); request.setAttribute("bodyJsp", "/templates/edit/formBasic.jsp"); request.setAttribute("scripts", "/templates/edit/formBasic.js"); request.setAttribute("formJsp", "/templates/edit/specific/individualType_retry.jsp"); request.setAttribute("title", "Individual Type Editing Form"); request.setAttribute("_action", "insert"); setRequestAttributes(request, epo); try { rd.forward(request, response); } catch (Exception e) { log.error(this.getClass().getName() + " could not forward to view."); log.error(e.getMessage()); log.error(e.getStackTrace()); } }
From source file:org.apache.pig.impl.logicalLayer.LOStore.java
/** * @param plan//from w ww . j av a2s . c om * LogicalPlan this operator is a part of. * @param key * OperatorKey for this operator * @param outputFileSpec * the file to be stored */ public LOStore(LogicalPlan plan, OperatorKey key, FileSpec outputFileSpec, String alias) throws IOException { super(plan, key); mOutputFile = outputFileSpec; // TODO // The code below is commented out as PigContext pulls in // HExecutionEngine which in turn is completely commented out // Also remove the commented out import org.apache.pig.impl.PigContext try { mStoreFunc = (StoreFuncInterface) PigContext.instantiateFuncFromSpec(outputFileSpec.getFuncSpec()); this.mAlias = alias; this.signature = constructSignature(mAlias, outputFileSpec.getFileName(), mOutputFile.getFuncSpec()); mStoreFunc.setStoreFuncUDFContextSignature(this.signature); } catch (Exception e) { IOException ioe = new IOException(e.getMessage()); ioe.setStackTrace(e.getStackTrace()); throw ioe; } }
From source file:edu.harvard.i2b2.crc.dao.setfinder.querybuilder.temporal.TemporalPanelCellQueryItem.java
@Override protected String buildSql() throws I2B2DAOException { try {/*from ww w .j av a 2 s.com*/ this.callCellUrlWithRequest(); this.dimCode = patientNums; } catch (Exception e) { log.debug(e.getStackTrace()); e.printStackTrace(); return ""; } if (returnEncounterNum() || returnInstanceNum() || this.hasItemDateConstraint() || this.hasModiferConstraint() || this.hasPanelDateConstraint() || this.hasPanelOccurrenceConstraint() || this.hasValueConstraint() //||parent.isTimingQuery() ) { return super.buildSql(); } else { return "select " + this.factTableColumn + " from " + noLockSqlServer + parent.getDatabaseSchema() + this.tableName + " " + " where " + this.columnName + " " + this.operator + " " + this.dimCode + ""; } }
From source file:dbmods.InsertTemplateName.java
private String log(Exception ex) { StackTraceElement[] trace = ex.getStackTrace(); StringBuilder message = new StringBuilder(); message.append(ex.getClass() + ": "); message.append(ex.getMessage());/*from w ww . java2 s.co m*/ for (StackTraceElement element : trace) { message.append("\n\t" + element); } PrintWriter pw = null; try { //pw = new PrintWriter("D:\\Temp\\InsertTemplateName.log"); //pw.append(message); //pw.flush(); return message.toString(); } catch (Exception e) { e.printStackTrace(); return null; } finally { if (pw != null) { pw.close(); } } }
From source file:FileSplitter.java
public boolean split(long size) { if (size <= 0) return false; try {/*from www . j a va2 s .c om*/ int parts = ((int) (f.length() / size)); long flength = 0; if (f.length() % size > 0) parts++; File[] fparts = new File[parts]; FileInputStream fis = new FileInputStream(f); FileOutputStream fos = null; for (int i = 0; i < fparts.length; i++) { fparts[i] = new File(f.getPath() + ".part." + i); fos = new FileOutputStream(fparts[i]); int read = 0; long total = 0; byte[] buff = new byte[1024]; int origbuff = buff.length; while (total < size) { read = fis.read(buff); if (read != -1) { buff = FileEncoder.invertBuffer(buff, 0, read); total += read; flength += read; fos.write(buff, 0, read); } if (i == fparts.length - 1 && read < origbuff) break; } fos.flush(); fos.close(); fos = null; } fis.close(); // f.delete(); f = fparts[0]; System.out.println("Length Readed (KB): " + flength / 1024.0); return true; } catch (Exception ex) { System.out.println(ex); System.out.println(ex.getLocalizedMessage()); System.out.println(ex.getStackTrace()[0].getLineNumber()); ex.printStackTrace(); return false; } }
From source file:com.predic8.membrane.osgi.CoreActivator.java
@Override public void start(BundleContext context) throws Exception { super.start(context); if (new File("configuration/log4j.properties").exists()) PropertyConfigurator.configure("configuration/log4j.properties"); Platform.addLogListener(logListener); final MembraneCommandLine cl = new MembraneCommandLine(); cl.parse(fixArguments(Platform.getCommandLineArgs())); if (cl.hasConfiguration()) { log.info("loading monitor beans from command line argument: " + getConfigurationFileName(cl)); router = Router.init(getConfigurationFileName(cl), this.getClass().getClassLoader()); } else {// w ww .j a va2 s . c o m try { if (ClassloaderUtil.fileExists(getConfigurationFileName())) { log.info("Eclipse framework found config file: " + getConfigurationFileName()); readBeanConfigWhenStartedAsProduct(); } else { readBeanConfigWhenStartedInEclipse(); } } catch (Exception e1) { log.error("Unable to read bean configuration file: " + e1.getMessage()); log.error("Unable to read bean configuration file: " + e1.getStackTrace()); e1.printStackTrace(); } } sr = context.registerService(router.getClass().getName(), router, null); }
From source file:org.apache.reef.runtime.yarn.driver.restart.DFSEvaluatorPreserver.java
private void handleException(final Exception e, final String errorMsg, final String fatalMsg) { if (this.failDriverOnEvaluatorLogErrors) { LOG.log(Level.SEVERE, errorMsg, e); try {//from ww w . j av a2 s.c o m this.close(); } catch (Exception e1) { LOG.log(Level.SEVERE, "Failed on closing resource with " + Arrays.toString(e1.getStackTrace())); } if (fatalMsg != null) { throw new DriverFatalRuntimeException(fatalMsg, e); } else { throw new DriverFatalRuntimeException("Driver failed on Evaluator log error.", e); } } else { LOG.log(Level.WARNING, errorMsg, e); } }
From source file:nl.meta.mobile.chat.MobileChatActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mobile_chat); // Declares//from w ww . j a v a2 s .co m tvConnectStatus = (TextView) findViewById(R.id.tvConnected); etName = (EditText) findViewById(R.id.etName); llMessages = (LinearLayout) findViewById(R.id.llMessages); svMessages = (ScrollView) findViewById(R.id.svMessages); etMessage = (EditText) findViewById(R.id.etMessage); btnSend = (Button) findViewById(R.id.btnSend); mHandler = new Handler(); // Update connection label setConnectionLabel(); // Send message button handler btnSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // check connection if (connected) { // check name not null if (!etName.getText().toString().equals("")) { if (!etMessage.getText().toString().equals("")) { // Send message mClient.send(etName.getText().toString() + ": " + etMessage.getText().toString()); etMessage.setText(""); } } else { // Name is empty addMessageToChat(CONSTANT_NO_NAME_ERROR_MSG); } } } }); // Websockets setup List<BasicNameValuePair> extraHeaders = Arrays.asList(new BasicNameValuePair("Cookie", "session=abcd")); mClient = new WebSocketClient(URI.create(CONSTANT_WEBSOCKETS_URL), new WebSocketClient.Listener() { @Override public void onMessage(byte[] data) { // Byte array not used System.out.println(data); } @Override public void onMessage(String message) { // Process message - Handler required because it's on the UI // thread. final String messageForHandler = message; mHandler.post(new Runnable() { @Override public void run() { addMessageToChat(messageForHandler); } }); } @Override public void onError(Exception error) { // Should handle these errors... error.getStackTrace(); Thread.currentThread().getStackTrace(); } @Override public void onDisconnect(int code, String reason) { connected = false; // This is already on a handler mHandler.post(new Runnable() { @Override public void run() { setConnectionLabel(); } }); } @Override public void onConnect() { connected = true; // This is already on a handler mHandler.post(new Runnable() { @Override public void run() { setConnectionLabel(); } }); } }, extraHeaders); // Tell the client to connect mClient.connect(); }
From source file:com.turn.splicer.SplicerServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { try {// w ww. j a v a2 s . com doPostWork(request, response); } catch (Exception e) { LOG.error("Exception which processing POST request", e); String stackTrace = ""; if (e.getStackTrace() != null && e.getStackTrace().length > 2) { stackTrace += e.getStackTrace()[0] + ", " + e.getStackTrace()[1]; } else { stackTrace = "<empty>"; } response.getWriter().write("{\"error\": \"" + e.getMessage() + ", stacktrace=" + stackTrace + "\"}\n"); } }
From source file:edu.duke.cabig.c3pr.infrastructure.BaseResolver.java
/** * Gets the correlation nodes from payload xml. * //from www .jav a 2 s . c o m * @param correlationNodeXmlPayload the correlation node xml payload * @return the correlation nodes from payload xml */ public List<CorrelationNode> getCorrelationNodesFromPayloadXml(String correlationNodeXmlPayload) { String correlationNodeArrayXml = ""; try { correlationNodeArrayXml = personOrganizationResolverUtils .broadcastSearchCorrelationsWithEntities(correlationNodeXmlPayload, true, true); } catch (Exception e) { log.error(e.getStackTrace()); } List<String> correlationNodes = XMLUtils.getObjectsFromCoppaResponse(correlationNodeArrayXml); List<CorrelationNode> correlationNodeList = new ArrayList<CorrelationNode>(); //creating a list of correlationNodes for (String correlationNode : correlationNodes) { correlationNodeList.add(CoppaObjectFactory.getCorrelationNodeObjectFromXml(correlationNode)); } return correlationNodeList; }