Example usage for java.lang Exception getStackTrace

List of usage examples for java.lang Exception getStackTrace

Introduction

In this page you can find the example usage for java.lang Exception getStackTrace.

Prototype

public StackTraceElement[] getStackTrace() 

Source Link

Document

Provides programmatic access to the stack trace information printed by #printStackTrace() .

Usage

From source file:com.esri.geoevent.solutions.adapter.cot.CoTAdapterInbound.java

private List<Node> findChildNodes(Node node, String childName) throws Exception {
    try {/*w  w  w . ja  va 2  s.c  om*/
        ArrayList<Node> children = new ArrayList<Node>();
        NodeList childNodes = node.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node child = childNodes.item(i);
            if (child.getNodeName().equals(childName))
                children.add(child);
        }
        return children;
    } catch (Exception e) {
        log.error(e);
        log.error(e.getStackTrace());
        throw (e);
    }
}

From source file:com.esri.geoevent.solutions.adapter.cot.CoTAdapterInbound.java

private String getAttribute(Node node, String attributeName) throws Exception {
    try {/*from w w  w. j  a va2  s  .  c  o  m*/
        NamedNodeMap attributes = node.getAttributes();
        for (int i = 0; i < attributes.getLength(); i++) {
            Node attributeNode = attributes.item(i);
            if (attributeNode.getNodeName().equals(attributeName)) {
                return attributeNode.getNodeValue();
            }
        }
        return null;
    } catch (Exception e) {
        log.error(e);
        log.error(e.getStackTrace());
        throw (e);
    }
}

From source file:com.esri.geoevent.solutions.adapter.cot.CoTAdapterInbound.java

private String closePolygon() throws Exception {
    try {/* w  w  w . java2  s  . c  o m*/
        if (!firstVertex)
            addVertexToPolygon(cachedLat, cachedLon, cachedHae);
        generator.writeEndArray();
        generator.writeEndArray();
        generator.writeEndObject();
        generator.flush();
        String jsonString = jsonBuffer.toString();
        jsonBuffer.reset();
        return jsonString;
    } catch (Exception e) {
        log.error(e);
        log.error(e.getStackTrace());
        throw (e);
    }
}

From source file:no.ntnu.okse.protocol.wsn.WSNotificationServer.java

/**
 * The primary boot method for starting a WSNServer instance. Will only perform actions if the
 * server instance is not already running.
 * <p>//www .  ja  v a 2  s .c o  m
 * Initializes a HttpClient, and starts it. Also adds predefined connectors to the jetty server
 * instance. Constructs a new serverThread and starts the jetty server instance in this new thread.
 * </p>
 */
public void boot() {

    log.info("Booting WSNServer.");

    if (!_running) {
        try {
            // Initialize a plain HttpClient
            this._client = new HttpClient();
            // Turn off following HTTP 30x redirects for the client
            this._client.setFollowRedirects(false);
            this._client.start();
            log.info("Started WSNServer HTTPClient");

            // For all registered connectors in WSNotificationServer, add these to the Jetty Server
            this._connectors.stream().forEach(c -> this._server.addConnector(c));

            /* OKSE custom WS-Nu web services */

            // Initialize the CommandProxy
            WSNCommandProxy broker = new WSNCommandProxy();
            _commandProxy = broker;
            // Initialize the WSN SubscriptionManager and PublisherRegistrationManager
            WSNSubscriptionManager subscriptionManager = new WSNSubscriptionManager();
            WSNRegistrationManager registrationManager = new WSNRegistrationManager();
            // Add listener support from the OKSE SubscriptionService
            SubscriptionService.getInstance().addSubscriptionChangeListener(subscriptionManager);
            SubscriptionService.getInstance().addPublisherChangeListener(registrationManager);

            // QuickBuild the broker
            broker.quickBuild("broker", this._requestParser);
            // QuickBuild the WSN SubManager
            subscriptionManager.quickBuild("subscriptionManager", this._requestParser);
            subscriptionManager.initCoreSubscriptionService(SubscriptionService.getInstance());
            // QuickBuild the WSN PubRegManager
            registrationManager.quickBuild("registrationManager", this._requestParser);
            registrationManager.initCoreSubscriptionService(SubscriptionService.getInstance());
            // Register the WSN managers to the command proxy (proxied broker)
            broker.setSubscriptionManager(subscriptionManager);
            broker.setRegistrationManager(registrationManager);

            // Create a new thread for the Jetty Server to run in
            this._serverThread = new Thread(() -> {
                this.run();
            });
            this._serverThread.setName("WSNServer");
            // Start the Jetty Server
            this._serverThread.start();
            WSNotificationServer._running = true;
            log.info("WSNServer Thread started successfully.");
        } catch (Exception e) {
            totalErrors.incrementAndGet();
            log.trace(e.getStackTrace());
        }
    }
}

From source file:com.dungnv.vfw5.base.dao.BaseFWDAOImpl.java

public String printLog(Exception e) {
    String str;//from  w  w w. ja v  a 2 s  .co  m
    try {
        e.printStackTrace();
        str = " [DEATAIL]" + e.toString();
        if (e.getCause() != null && e.getCause().getMessage() != null) {
            str += " - Caused by " + e.getCause().getMessage();
        }
        StackTraceElement[] traceList = e.getStackTrace();
        for (StackTraceElement trace : traceList) {
            if (trace.getClassName().contains("com.dungnv.framework.interceptor.ActionInterceptor") || trace
                    .getClassName().contains("com.dungnv.config.tms.interceptor.LogActionInterceptor")) {
                break;
            } else if (trace.getClassName().contains("com.dungnv")) {
                str += "\n [" + trace.getClassName() + ".class][" + trace.getMethodName() + "]["
                        + trace.getLineNumber() + "]";
            }
        }
    } catch (Exception ex) {
        str = ":" + e.getMessage();
    }
    return str;
}

From source file:be.agiv.security.demo.Main.java

private void showException(Exception e) {
    StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(e.getMessage());
    stringBuffer.append("\n");
    for (StackTraceElement stackTraceElement : e.getStackTrace()) {
        stringBuffer.append(stackTraceElement.getClassName());
        stringBuffer.append(".");
        stringBuffer.append(stackTraceElement.getMethodName());
        stringBuffer.append(":");
        stringBuffer.append(stackTraceElement.getLineNumber());
        stringBuffer.append("\n");
    }//from  w w  w. j a v  a 2 s .  c o  m
    Throwable cause = e.getCause();
    while (null != cause) {
        stringBuffer.append("\n");
        stringBuffer.append("Caused by: ");
        stringBuffer.append(cause.getMessage());
        stringBuffer.append(" - ");
        stringBuffer.append(cause.getClass().getName());
        stringBuffer.append("\n");
        for (StackTraceElement stackTraceElement : e.getStackTrace()) {
            stringBuffer.append(stackTraceElement.getClassName());
            stringBuffer.append(".");
            stringBuffer.append(stackTraceElement.getMethodName());
            stringBuffer.append(":");
            stringBuffer.append(stackTraceElement.getLineNumber());
            stringBuffer.append("\n");
        }
        cause = cause.getCause();
    }
    JTextArea textArea = new JTextArea(stringBuffer.toString(), 10, 40);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setAutoscrolls(true);
    JOptionPane.showMessageDialog(this, scrollPane, e.getClass().getSimpleName(), JOptionPane.ERROR_MESSAGE);
}

From source file:com.esri.geoevent.solutions.adapter.cot.CoTAdapterInbound.java

private void addVertexToPolygon(double lat, double lon, double hae)
        throws JsonGenerationException, IOException {
    try {//from   ww w. j  a v a2s .c o m
        if (firstVertex) {
            firstVertex = false;
            cachedLat = lat;
            cachedLon = lon;
            cachedHae = hae;
            firstVertex = false;
        }

        generator.writeStartArray();
        generator.writeNumber(lon);
        generator.writeNumber(lat);
        // generator.writeNumber(hae);
        generator.writeEndArray();
    } catch (Exception e) {
        log.error(e);
        log.error(e.getStackTrace());
    }
}

From source file:com.sic.bb.jenkins.plugins.sicci_for_xcode.XcodeBuilder.java

@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) {
    PrintStream logger = listener.getLogger();
    XcodeBuilderDescriptor descr = getDescriptor();
    FilePath workspace = this.currentProjectDirectory;

    List<String> blackList = new ArrayList<String>();
    List<Boolean> returnCodes = new ArrayList<Boolean>();

    boolean rcode = true;

    logger.println("\n" + Messages.XcodeBuilder_perform_started() + "\n");

    try {/*from   w w w.j a v  a 2s . co  m*/
        EnvVars envVars = build.getEnvironment(listener);

        logger.println(Messages.XcodeBuilder_perform_cleanStarted() + "\n");

        if (!(descr.getCleanBeforeBuildGlobal() && !descr.getCleanBeforeBuild()))
            for (String toClean : getToPerformStep(CLEAN_BEFORE_BUILD_ARG,
                    (descr.getCleanBeforeBuildGlobal() && descr.getCleanBeforeBuild())))
                returnCodes.add(XcodebuildCommandCaller.getInstance().clean(launcher, envVars, listener,
                        workspace, createArgs(toClean)));

        logger.println(Messages.XcodeBuilder_perform_cleanFinished() + "\n\n");

        if (this.currentUsername != null && this.currentPassword != null) {
            if (!SecurityCommandCaller.getInstance().unlockKeychain(envVars, listener, workspace,
                    this.currentUsername, this.currentPassword)
                    && XcodePlatform.fromString(getXcodePlatform()) == XcodePlatform.IOS)
                return false;

            logger.print("\n");
        }

        logger.println(Messages.XcodeBuilder_perform_buildStarted() + "\n");

        for (String toBuild : getToPerformStep(BUILD_ARG, true)) {
            rcode = XcodebuildCommandCaller.getInstance().build(launcher, envVars, listener, workspace,
                    this.currentBuildIsUnitTest, createArgs(toBuild));

            if (!rcode)
                blackList.add(toBuild);

            returnCodes.add(rcode);
        }

        logger.println(Messages.XcodeBuilder_perform_buildFinished() + "\n\n");

        FilePath buildDir = workspace.child(BUILD_FOLDER_NAME);

        logger.println(Messages.XcodeBuilder_perform_archiveAppsStarted() + "\n");

        if (!(descr.getArchiveAppGlobal() && !descr.getArchiveApp())) {
            for (String toArchiveApp : getToPerformStep(ARCHIVE_APP_ARG,
                    (descr.getArchiveAppGlobal() && descr.getArchiveApp()))) {
                if (blackList.contains(toArchiveApp))
                    continue;

                String[] array = toArchiveApp.split(PluginUtils.stringToPattern(FIELD_DELIMITER));

                if (getBooleanPreference(array[0] + FIELD_DELIMITER + UNIT_TEST_TARGET_ARG))
                    continue;

                logger.print(Messages.XcodeBuilder_perform_archivingApp() + ": " + array[0] + " " + array[1]);

                FilePath tempBuildDir = getBuildDir(buildDir, array[1]);

                if (tempBuildDir != null && tempBuildDir
                        .act(new AppArchiverCallable(array[0], createFilename(build, array[0], array[1])))) {
                    logger.println(" " + Messages.XcodeBuilder_perform_archivingAppDone());
                    returnCodes.add(true);
                } else {
                    logger.println(" " + Messages.XcodeBuilder_perform_archivingAppFailed());
                    returnCodes.add(false);
                }
            }
        }

        logger.println("\n" + Messages.XcodeBuilder_perform_archiveAppsFinished() + "\n\n");
        logger.println(Messages.XcodeBuilder_perform_createIpasStarted() + "\n");

        if (!(descr.getCreateIpaGlobal() && !descr.getCreateIpa())) {
            for (String toCreateIpa : getToPerformStep(CREATE_IPA_ARG,
                    (descr.getCreateIpaGlobal() && descr.getCreateIpa()))) {
                if (blackList.contains(toCreateIpa))
                    continue;

                String[] array = toCreateIpa.split(PluginUtils.stringToPattern(FIELD_DELIMITER));

                if (getBooleanPreference(array[0] + FIELD_DELIMITER + UNIT_TEST_TARGET_ARG))
                    continue;

                logger.print(Messages.XcodeBuilder_perform_creatingIpa() + ": " + array[0] + " " + array[1]);

                FilePath tempBuildDir = getBuildDir(buildDir, array[1]);

                if (tempBuildDir != null && tempBuildDir
                        .act(new IpaPackagerCallable(array[0], createFilename(build, array[0], array[1])))) {
                    logger.println(" " + Messages.XcodeBuilder_perform_creatingIpaDone());
                    returnCodes.add(true);
                } else {
                    logger.println(" " + Messages.XcodeBuilder_perform_creatingIpaFailed());
                    returnCodes.add(false);
                }
            }
        }

        logger.println("\n" + Messages.XcodeBuilder_perform_createIpasFinished() + "\n\n");

        logger.println(Messages.XcodeBuilder_perform_finished() + "\n\n");

        if (returnCodes.contains(false))
            return false;

        return true;
    } catch (Exception e) {
        logger.println(e.getStackTrace());
    }

    return false;
}

From source file:com.esri.geoevent.solutions.adapter.cot.CoTAdapterInbound.java

private String appendToHow(String type) throws Exception {
    try {/*from w  ww.  ja v  a  2s  .  c  o m*/
        Matcher matcher;
        StringBuffer sb = new StringBuffer();
        for (CoTTypeDef cd : this.coTTypeMap) {
            // now only consider the value if it is:
            // 1. a predicate
            if (cd.isPredicate()) {
                Pattern pattern = Pattern.compile(cd.getKey());
                matcher = pattern.matcher(type);
                if (matcher.find()) {
                    // now only append the value if it is:
                    // 1. not prefixed with a dot notation
                    if (cd.getValue().startsWith("h.")) {
                        sb.append(cd.getValue() + " ");
                    }
                }
            }
        }

        return sb.toString();
    } catch (Exception e) {
        log.error(e);
        log.error(e.getStackTrace());
        throw (e);
    }
}

From source file:com.esri.geoevent.solutions.adapter.cot.CoTAdapterInbound.java

private String appendToType(String type) throws Exception {
    try {//  ww  w .  j a v  a  2s  .  c  o  m
        Matcher matcher;
        StringBuffer sb = new StringBuffer();
        for (CoTTypeDef cd : this.coTTypeMap) {
            // now only consider the value if it is:
            // 1. a predicate
            // 2. not prefixed with a dot notation
            if (cd.isPredicate() && !(cd.getValue().startsWith("h.") || cd.getValue().startsWith("t.")
                    || cd.getValue().startsWith("r.") || cd.getValue().startsWith("q.")
                    || cd.getValue().startsWith("o."))) {
                Pattern pattern = Pattern.compile(cd.getKey());
                matcher = pattern.matcher(type);
                if (matcher.find()) {

                    sb.append(cd.getValue() + " ");

                }
            }
        }

        return sb.toString();
    } catch (Exception e) {
        log.error(e);
        log.error(e.getStackTrace());
        throw (e);
    }
}