List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:net.orpiske.sas.service.main.Main.java
public static void main(String[] args) { int ret = 0;// www .j ava 2s .c om if (args.length == 0) { help(1); } try { ConfigurationWrapper.initConfiguration(Constants.SAS_SERVICE_CONFIG_DIR, Constants.CONFIG_FILE_NAME); } catch (ConfigurationException e) { System.err.println("Unable to load configuration file " + "'mdm-broker.properties': " + e.getMessage()); System.exit(-1); } catch (FileNotFoundException e) { System.err.println("Unable to find configuration file " + "'mdm-broker.properties': " + e.getMessage()); System.exit(-1); } String first = args[0]; String[] newArgs = Arrays.copyOfRange(args, 1, args.length); if (first.equals("run")) { RunAction runAction = new RunAction(newArgs); ret = runAction.run(); System.exit(ret); } help(-1); }
From source file:net.orpiske.mdm.broker.main.Main.java
public static void main(String[] args) { int ret = 0;//from w ww .j a v a 2 s . c om if (args.length == 0) { help(1); } try { ConfigurationWrapper.initConfiguration(Constants.MDM_BROKER_CONFIG_DIR, Constants.CONFIG_FILE_NAME); } catch (ConfigurationException e) { System.err.println("Unable to load configuration file " + "'mdm-broker.properties': " + e.getMessage()); System.exit(-1); } catch (FileNotFoundException e) { System.err.println("Unable to find configuration file " + "'mdm-broker.properties': " + e.getMessage()); System.exit(-1); } String first = args[0]; String[] newArgs = Arrays.copyOfRange(args, 1, args.length); if (first.equals("run")) { RunAction runAction = new RunAction(newArgs); ret = runAction.run(); System.exit(ret); } help(-1); }
From source file:edu.hawaii.soest.pacioos.text.TextSourceApp.java
/** * @param args/* w w w.j ava2s .c om*/ */ public static void main(String[] args) { String xmlConfiguration = null; if (args.length != 1) { log.error("Please provide the path to the instrument's XML configuration file " + "as a single parameter."); System.exit(1); } else { xmlConfiguration = args[0]; } try { textSource = TextSourceFactory.getSimpleTextSource(xmlConfiguration); if (textSource != null) { textSource.start(); } // Handle ctrl-c's and other abrupt death signals to the process Runtime.getRuntime().addShutdownHook(new Thread() { // stop the streaming process public void run() { log.info("Stopping the SimpleTextSource driver due to user request"); textSource.stop(); } }); } catch (ConfigurationException e) { if (log.isDebugEnabled()) { e.printStackTrace(); } log.error("There was a problem configuring the driver. The error message was: " + e.getMessage()); System.exit(1); } }
From source file:net.jradius.server.Main.java
public static void main(String[] args) { if (args.length != 1) { showUsage();/*from w w w . j av a2 s . co m*/ System.exit(1); } /** * CADBiS daemon run * ---> */ if (JRadiusConfigurator.getInstance().getProperty("cadbis_daemon").equals("enabled")) CADBiS.getInstance().start(); /** * <--- eof CADBiS */ String configFilePath = args[0]; try { File file = new File(configFilePath); Configuration.initialize(file); JRadiusServer server = new JRadiusServer(); server.start(); } catch (FileNotFoundException e) { System.err.println("Error: The configuration file '" + configFilePath + "' does not exist."); } catch (ConfigurationException e1) { System.err.println("Error: The configuration file could not be read," + " because the file contains an error: " + e1.getMessage()); showStackTrace(e1); } catch (SecurityException e2) { System.err.println("Error: The configuration file could not be read," + " because a security error occurred: " + e2.getMessage()); showStackTrace(e2); } catch (IllegalArgumentException e3) { System.err.println("Error: The configuration file could not be read," + " because an illegal argument error occurred: " + e3.getMessage()); showStackTrace(e3); } catch (ClassNotFoundException e4) { System.err.println("Error: The configuration file could not be read," + " because a class specified in the configuration file could not be found: " + e4.getMessage()); showStackTrace(e4); } catch (NoSuchMethodException e5) { System.err.println("Error: The configuration file could not be read," + " because a method does not exist in a class specified in the configuration file: " + e5.getMessage()); showStackTrace(e5); } catch (InstantiationException e6) { System.err.println("Error: The configuration file could not be read," + " because an object specified in the configuration file could not be instantiated: " + e6.getMessage()); showStackTrace(e6); } catch (IllegalAccessException e7) { System.err.println("Error: The configuration file could not be read," + " because an illegal access error occurred: " + e7.getMessage()); showStackTrace(e7); } catch (InvocationTargetException e8) { System.err.println("Error: The configuration file could not be read," + " because an invocation target exception was thrown: " + e8.getMessage()); showStackTrace(e8); } catch (Exception e) { e.printStackTrace(); } return; }
From source file:dk.dbc.opensearch.datadock.DatadockMain.java
/** * The datadocks main method./*from w ww . j ava 2s .c o m*/ * Starts the datadock and starts the datadockManager. */ public static void main(String[] args) { DatadockMain serverInstance = null; try { serverInstance = new DatadockMain(args); serverInstance.setServerMode(); } catch (ConfigurationException ex) { String error = String.format("Could not get configure DatadockMain object: %s", ex.getMessage()); log.fatal(error, ex); //we cannot guarantee a serverInstance to call shutdown on: System.exit(-1); } log.removeAppender("RootConsoleAppender"); log.addAppender(startupAppender); try { serverInstance.initializeServices(); } catch (Exception e) { System.out.println("Startup failed." + e.getMessage()); log.fatal(String.format("Startup failed: %s", e.getMessage()), e); serverInstance.shutdown(); } finally { log.removeAppender(startupAppender); } log.info("Daemonizing Datadock server"); serverInstance.daemonize(); serverInstance.addDaemonShutdownHook(); log.info("Starting processing of data"); long mainTimer = System.currentTimeMillis(); int mainJobsSubmitted = serverInstance.runServer(); log.info("Collecting and printing processing statistics"); serverInstance.collectStatistics(mainTimer, mainJobsSubmitted); }
From source file:edu.pitt.dbmi.facebase.hd.HumanDataController.java
/** Entry point to application. Firstly it gathers properties from hd.properties file on CLASSPATH * Most properties are localisms to do with file path information, database connection strings, * and TrueCrypt program operation. Hopefully the application can run by only editing entries in * hd.properties file. hd.properties has normal java properties fragility but also app-specific * fragility--for example, the sshServerUrl must end with a colon, as in root@server: * Notice that program properties can also be set below--by filling in the empty strings following * declaration AND commenting-out the try-catch clause that follows which gathers these properties * from hd.properties. // ww w. j a va 2 s.c o m */ public static void main(String[] args) { /** holds human-readable error data to be passed to addError() */ String errorString = ""; log.info("HumanDataController Started"); /** length of time to sleep in between each polling loop, 5secs is responsive, 5mins is alot */ String sleepFor = ""; /** Prefix path where TrueCrypt write operations will be performed (i.e. /tmp or /var/tmp), no trailing-slash */ String trueCryptBasePath = ""; /** TrueCrypt volume file extension (probably .tc or .zip) */ String trueCryptExtension = ""; /** Middle-of-path directory name to be created where TrueCrypt volume will be mounted */ String trueCryptMountpoint = ""; /** Human Data Server database credentials */ String hdDbUser = ""; String hdPasswd = ""; String hdJdbcUrl = ""; /** Hub database credentials */ String fbDbUser = ""; String fbPasswd = ""; String fbJdbcUrl = ""; /** Full path to truecrypt binary, (ie /usr/bin/truecrypt) */ String trueCryptBin = ""; /** Full path to scp binary, (ie /usr/bin/scp) */ String scpBin = ""; /** user@host portion of scp destination argument (ie. root@www.server.com:) */ String sshServerUrl = ""; /** file full path portion of scp destination argument (ie. /usr/local/downloads/) */ String finalLocation = ""; /** Full path to touch binary, (ie /bin/touch) */ String touchBin = ""; /** hardcoded truecrypt parameters; run "truecrypt -h" to learn about these */ String algorithm = ""; String hash = ""; String filesystem = ""; String volumeType = ""; String randomSource = ""; String protectHidden = ""; String extraArgs = ""; /** truecrypt parameters are packed into a map so we only pass one arg (this map) to method invoking truecrypt */ HashMap<String, String> trueCryptParams = new HashMap<String, String>(); trueCryptParams.put("trueCryptBin", ""); trueCryptParams.put("scpBin", ""); trueCryptParams.put("sshServerUrl", ""); trueCryptParams.put("finalLocation", ""); trueCryptParams.put("touchBin", ""); trueCryptParams.put("algorithm", ""); trueCryptParams.put("hash", ""); trueCryptParams.put("filesystem", ""); trueCryptParams.put("volumeType", ""); trueCryptParams.put("randomSource", ""); trueCryptParams.put("protectHidden", ""); trueCryptParams.put("extraArgs", ""); try { /** The properties file name is hardcoded to hd.properties--cannot be changed--this file must be on or at root of classpath */ final Configuration config = new PropertiesConfiguration("hd.properties"); sleepFor = config.getString("sleepFor"); hubURL = config.getString("hubURL"); responseTrigger = config.getString("responseTrigger"); trueCryptBasePath = config.getString("trueCryptBasePath"); trueCryptExtension = config.getString("trueCryptExtension"); trueCryptMountpoint = config.getString("trueCryptMountpoint"); hdDbUser = config.getString("hdDbUser"); hdPasswd = config.getString("hdPasswd"); hdJdbcUrl = config.getString("hdJdbcUrl"); fbDbUser = config.getString("fbDbUser"); fbPasswd = config.getString("fbPasswd"); fbJdbcUrl = config.getString("fbJdbcUrl"); trueCryptBin = config.getString("trueCryptBin"); scpBin = config.getString("scpBin"); sshServerUrl = config.getString("sshServerUrl"); finalLocation = config.getString("finalLocation"); touchBin = config.getString("touchBin"); algorithm = config.getString("algorithm"); hash = config.getString("hash"); filesystem = config.getString("filesystem"); volumeType = config.getString("volumeType"); randomSource = config.getString("randomSource"); protectHidden = config.getString("protectHidden"); extraArgs = config.getString("extraArgs"); trueCryptParams.put("trueCryptBin", trueCryptBin); trueCryptParams.put("scpBin", scpBin); trueCryptParams.put("sshServerUrl", sshServerUrl); trueCryptParams.put("finalLocation", finalLocation); trueCryptParams.put("touchBin", touchBin); trueCryptParams.put("algorithm", algorithm); trueCryptParams.put("hash", hash); trueCryptParams.put("filesystem", filesystem); trueCryptParams.put("volumeType", volumeType); trueCryptParams.put("randomSource", randomSource); trueCryptParams.put("protectHidden", protectHidden); trueCryptParams.put("extraArgs", extraArgs); log.debug("properties file loaded successfully"); } catch (final ConfigurationException e) { errorString = "Properties file problem"; String logString = e.getMessage(); addError(errorString, logString); log.error(errorString); } log.debug("initialize static class variable HumanDataManager declared earlier"); hdm = new HumanDataManager(hdDbUser, hdPasswd, hdJdbcUrl); log.debug("declare and initialize InstructionQueueManager"); InstructionQueueManager iqm = new InstructionQueueManager(fbDbUser, fbPasswd, fbJdbcUrl); log.debug("pass to the logfile/console all startup parameters for troubleshooting"); log.info("HumanDataController started with these settings from hd.properties: " + "hubURL=" + hubURL + " " + "responseTrigger=" + responseTrigger + " " + "trueCryptBasePath=" + trueCryptBasePath + " " + "trueCryptExtension=" + trueCryptExtension + " " + "trueCryptMountpoint=" + trueCryptMountpoint + " " + "hdDbUser=" + hdDbUser + " " + "hdPasswd=" + hdPasswd + " " + "hdJdbcUrl=" + hdJdbcUrl + " " + "fbDbUser=" + fbDbUser + " " + "fbPasswd=" + fbPasswd + " " + "fbJdbcUrl=" + fbJdbcUrl + " " + "trueCryptBin=" + trueCryptBin + " " + "scpBin=" + scpBin + " " + "sshServerUrl=" + sshServerUrl + " " + "finalLocation=" + finalLocation + " " + "touchBin=" + touchBin + " " + "algorithm=" + algorithm + " " + "hash=" + hash + " " + "filesystem=" + filesystem + " " + "volumeType=" + volumeType + " " + "randomSource=" + randomSource + " " + "protectHidden=" + protectHidden + " " + "extraArgs=" + extraArgs); log.debug("Enter infinite loop where program will continuously poll Hub server database for new requests"); while (true) { log.debug("LOOP START"); try { Thread.sleep(Integer.parseInt(sleepFor) * 1000); } catch (InterruptedException ie) { errorString = "Failed to sleep, got interrupted."; log.error(errorString, ie); addError(errorString, ie.getMessage()); } log.debug( "About to invoke InstructionQueueManager.queryInstructions()--Hibernate to fb_queue starts NOW"); List<InstructionQueueItem> aiqi = iqm.queryInstructions(); log.debug("Currently there are " + aiqi.size() + " items in the queue"); InstructionQueueItem iqi; String instructionName = ""; log.debug("About to send http request -status- telling Hub we are alive:"); httpGetter("status", "0"); if (aiqi.size() > 0) { log.debug( "There is at least one request, status=pending, queue item; commence processing of most recent item"); iqi = aiqi.get(0); log.debug("About to get existing user key, or create a new one, via fb_keychain Hibernate"); FbKey key = hdm.queryKey(iqi.getUid()); log.debug( "About to pull the JSON Instructions string, and other items, from the InstructionQueueItem"); String instructionsString = iqi.getInstructions(); instructionName = iqi.getName(); log.debug("About to create a new FileManager object with:"); log.debug(instructionName + trueCryptBasePath + trueCryptExtension + trueCryptMountpoint); FileManager fm = new FileManager(instructionName, trueCryptBasePath, trueCryptExtension, trueCryptMountpoint); ArrayList<Instructions> ali = new ArrayList<Instructions>(); log.debug( "FileManager.makeInstructionsObjects() creates multiple Instruction objects from the InstructionQueueItem.getInstructions() value"); if (fm.makeInstructionsObjects(instructionsString, ali)) { log.debug("FileManager.makeInstructionsObjects() returned true"); } else { errorString = "FileManager.makeInstructionsObjects() returned false"; log.error(errorString); addError(errorString, ""); } log.debug( "FileManager.makeFiles() uses its list of Instruction objects and calls its makeFiles() method to make/get requested data files"); if (fm.makeFiles(ali)) { log.debug("FileManager.makeFiles() returned true"); } else { errorString = "FileManager.makeFiles() returned false"; log.error(errorString); addError(errorString, ""); } //sends the size/100000 as seconds(100k/sec)...needs to be real seconds."); long bytesPerSecond = 100000; Long timeToMake = new Long(fm.getSize() / bytesPerSecond); String timeToMakeString = timeToMake.toString(); log.debug("Send http request -status- to Hub with total creation time estimate:"); log.debug(timeToMakeString); httpGetter("status", timeToMakeString); log.debug( "Update the queue_item row with the total size of the data being packaged with InstructionQueueManager.updateInstructionSize()"); if (iqm.updateInstructionSize(fm.getSize(), iqi.getQid())) { log.debug("InstructionQueueManager.updateInstructionSize() returned true"); } else { errorString = "InstructionQueueManager.updateInstructionSize() returned false"; log.error(errorString); addError(errorString, ""); } log.debug("About to make new TrueCryptManager with these args:"); log.debug(key.getEncryption_key() + fm.getSize() + fm.getTrueCryptPath() + fm.getTrueCryptVolumePath() + trueCryptParams); TrueCryptManager tcm = new TrueCryptManager(key.getEncryption_key(), fm.getSize(), fm.getTrueCryptPath(), fm.getTrueCryptVolumePath(), trueCryptParams); if (tcm.touchVolume()) { log.debug("TrueCryptManager.touchVolume() returned true, touched file"); } else { errorString = "TrueCryptManager.touchVolume() returned false"; log.error(errorString); addError(errorString, ""); } if (tcm.makeVolume()) { log.debug("TrueCryptManager.makeVolume() returned true, created TrueCrypt volume"); } else { errorString = "TrueCryptManager.makeVolume() returned false"; log.error(errorString); addError(errorString, ""); } if (tcm.mountVolume()) { log.debug("TrueCryptManager.mountVolume() returned true, mounted TrueCrypt volume"); } else { errorString = "TrueCryptManager.mountVolume() returned false"; log.error(errorString); addError(errorString, ""); } if (fm.copyFilesToVolume(ali)) { log.debug( "TrueCryptManager.copyFilesToVolume() returned true, copied requested files to mounted volume"); } else { errorString = "TrueCryptManager.copyFilesToVolume() returned false"; log.error(errorString); addError(errorString, ""); } if (tcm.disMountVolume()) { log.debug("TrueCryptManager.disMountVolume() returned true, umounted TrueCrypt volume"); } else { errorString = "TrueCryptManager.disMountVolume() returned false"; log.error(errorString); addError(errorString, ""); } if (tcm.sendVolumeToFinalLocation()) { log.debug( "TrueCryptManager.sendVolumeToFinalLocation() returned true, copied TrueCrypt volume to retreivable, final location"); } else { errorString = "TrueCryptManager.sendVolumeToFinalLocation() returned false"; log.error(errorString); addError(errorString, ""); } if (iqm.updateInstructionToCompleted(tcm.getFinalLocation() + fm.getTrueCryptFilename(), fm.getSize(), iqi.getQid(), getErrors(), getLogs())) { log.debug("InstructionQueueManager.updateInstructionToCompleted() returned true"); log.debug( "Processing of queue item is almost finished, updated fb_queue item row with location, size, status, errors, logs:"); log.debug(tcm.getFinalLocation() + fm.getTrueCryptFilename() + fm.getSize() + iqi.getQid() + getErrors() + getLogs()); } else { errorString = "InstructionQueueManager.updateInstructionToCompleted() returned false"; log.error(errorString); addError(errorString, ""); } log.debug("About to send http request -update- telling Hub which item is finished."); httpGetter("update", iqi.getHash()); log.debug("Finished processing pending queue item, status should now be complete or error"); } else { log.debug("Zero queue items"); } log.debug("LOOP END"); } }
From source file:it.polimi.tower4clouds.data_analyzer.DAServer.java
public static void main(String[] args) { PropertiesConfiguration releaseProperties = null; try {/*from w w w. j av a 2 s .c o m*/ releaseProperties = new PropertiesConfiguration("release.properties"); } catch (org.apache.commons.configuration.ConfigurationException e) { logger.error("Internal error", e); System.exit(1); } APP_NAME = releaseProperties.getString("application.name"); APP_FILE_NAME = releaseProperties.getString("dist.file.name"); APP_VERSION = releaseProperties.getString("release.version"); try { DAConfig config = new DAConfig(args, APP_FILE_NAME); if (config.isHelp()) { System.out.println(config.usage); } else if (config.isVersion()) { System.out.println("Version: " + APP_VERSION); } else { String[] rspArgs = new String[1]; rspArgs[0] = "da.properties"; System.setProperty(InputDataUnmarshaller.INPUT_DATA_UNMARSHALLER_IMPL_PROPERTY_NAME, DAInputDataUnmarshaller.class.getName()); System.setProperty(OutputDataMarshaller.OUTPUT_DATA_MARSHALLER_IMPL_PROPERTY_NAME, DAOutputDataMarshaller.class.getName()); System.setProperty("log4j.configuration", "log4j.properties"); // System.setProperty("rsp_server.static_resources.path", // config.getKBFolder()); NOT USED BY RSP!!! System.setProperty("csparql_server.port", Integer.toString(config.getPort())); logger.info("{} {}", APP_NAME, APP_VERSION); rsp_services_csparql_server.main(rspArgs); } } catch (ConfigurationException e) { logger.error("Configuration problem: " + e.getMessage()); logger.error("Run \"" + APP_FILE_NAME + " -help\" for help"); System.exit(1); } catch (Exception e) { logger.error("Unknown error", e); } }
From source file:com.appeligo.responsetest.ServerResponseChecker.java
/** * @param args//from w w w. ja v a 2 s .c o m */ public static void main(String[] args) { PatternLayout pattern = new PatternLayout("%d{ISO8601} %-5p [%-c{1} - %t] - %m%n"); ConsoleAppender consoleAppender = new ConsoleAppender(pattern); LevelRangeFilter infoFilter = new LevelRangeFilter(); infoFilter.setLevelMin(Level.INFO); consoleAppender.addFilter(infoFilter); BasicConfigurator.configure(consoleAppender); String configFile = "/etc/flip.tv/responsetest.xml"; if (args.length > 0) { if (args.length == 2 && args[0].equals("-config")) { configFile = args[1]; } else { log.error("Usage: java " + ServerResponseChecker.class.getName() + " [-config <xmlfile>]"); System.exit(1); } } try { XMLConfiguration config = new XMLConfiguration(configFile); logFile = config.getString("logFile", logFile); servlet = config.getString("servlet", servlet); timeoutSeconds = config.getLong("timeoutSeconds", timeoutSeconds); responseTimeThresholdSeconds = config.getLong("responseTimeThresholdSeconds", responseTimeThresholdSeconds); reporter = config.getString("reporter", reporter); smtpServer = config.getString("smtpServer", smtpServer); smtpUsername = config.getString("smtpUsername", smtpUsername); smtpPassword = config.getString("smtpPassword", smtpPassword); smtpDebug = config.getBoolean("smtpDebug", smtpDebug); mailTo = config.getString("mailTo", mailTo); } catch (ConfigurationException e) { e.printStackTrace(); } marker = logFile + ".mailed"; try { BasicConfigurator.configure(new RollingFileAppender(pattern, logFile, true)); } catch (IOException e1) { e1.printStackTrace(); } // Add email appender SMTPAppender mailme = new SMTPAppender(); LevelRangeFilter warnFilter = new LevelRangeFilter(); warnFilter.setLevelMin(Level.WARN); mailme.addFilter(warnFilter); mailme.setSMTPDebug(smtpDebug); mailme.setSMTPHost(smtpServer); mailme.setTo(mailTo); mailme.setFrom(reporter + " <" + smtpUsername + ">"); mailme.setBufferSize(1); mailme.setSubject(servlet + " Not Responding!"); mailme.setSMTPUsername(smtpUsername); mailme.setSMTPPassword(smtpPassword); mailme.setLayout(new SimpleLayout()); mailme.activateOptions(); mailme.setLayout(pattern); BasicConfigurator.configure(mailme); long before; ConnectionThread connectionThread = new ConnectionThread(); connectionThread.start(); synchronized (connectionThread) { connectionThread.setOkToGo(true); connectionThread.notifyAll(); before = System.currentTimeMillis(); long delay = timeoutSeconds * 1000; while (!done && delay > 0) { try { connectionThread.wait(delay); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } delay -= (System.currentTimeMillis() - before); } } long after = System.currentTimeMillis(); responseMillis = after - before; String reportStatus = "Could not report"; try { StringBuilder sb = new StringBuilder(); sb.append(servlet + "/responsetest/report.action"); sb.append("?reporter=" + URLEncoder.encode(reporter)); sb.append("&status=" + URLEncoder.encode(status)); sb.append("&bytesRead=" + bytesRead); sb.append("&timedOut=" + (!done)); if (throwable == null) { sb.append("&exception=none"); } else { sb.append("&exception=" + URLEncoder.encode(throwable.getClass().getName() + "-" + throwable.getMessage())); } sb.append("&responseMillis=" + responseMillis); URL reportURL = new URL(sb.toString()); connection = (HttpURLConnection) reportURL.openConnection(); connection.connect(); reportStatus = connection.getResponseCode() + " - " + connection.getResponseMessage(); } catch (Throwable t) { reportStatus = t.getClass().getName() + "-" + t.getMessage(); } StringBuilder sb = new StringBuilder(); sb.append(servlet + ": "); sb.append(status + ", " + bytesRead + " bytes, "); if (done) { sb.append("DONE, "); } else { sb.append("TIMED OUT, "); } sb.append(responseMillis + " millisecond response, "); sb.append(" report status=" + reportStatus); File markerFile = new File(marker); if (done && status.startsWith("200") && (throwable == null)) { if ((responseMillis / 1000) < responseTimeThresholdSeconds) { if (markerFile.exists()) { markerFile.delete(); } log.debug(sb.toString()); } else { if (markerFile.exists()) { log.info(sb.toString()); } else { try { new FileOutputStream(marker).close(); log.warn(sb.toString()); } catch (IOException e) { log.info(sb.toString()); log.info("Can't send email alert because could not write marker file: " + marker + ". " + e.getMessage()); } } } } else { if (throwable != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); throwable.printStackTrace(pw); sb.append(sw.toString()); } if (markerFile.exists()) { log.info(sb.toString()); } else { try { new FileOutputStream(marker).close(); log.fatal(sb.toString()); // chosen appender layout ignoresThrowable() } catch (IOException e) { log.info(sb.toString()); log.info("Can't send email alert because could not write marker file: " + marker + ". " + e.getMessage()); } } } }
From source file:com.github.ipaas.ideploy.plugin.util.XmlUtil.java
public static String getString(String fileName, String elementNames) { XMLConfiguration config;/*from w w w . j a v a 2 s . com*/ try { config = new XMLConfiguration(fileName); } catch (ConfigurationException e) { ConsoleHandler.error("??[" + fileName + "]:" + e.getMessage()); return null; } // ?????? String str = config.getString(elementNames); return str; }
From source file:com.github.ipaas.ideploy.plugin.util.XmlUtil.java
/** * ?//from w ww.j a va 2 s . com * * @param XML? * @param elementNames * ?? . * @param dufaultValue * ? * @return */ public static String getString(String fileName, String elementNames, String defaultValue) { XMLConfiguration config; try { config = new XMLConfiguration(fileName); } catch (ConfigurationException e) { ConsoleHandler.error("??[" + fileName + "]:" + e.getMessage()); return null; } // ?????? String str = config.getString(elementNames, defaultValue); return str; }