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:edu.cornell.kfs.vnd.batch.service.impl.VendorBatchServiceImpl.java

private String addVendor(VendorBatchDetail vendorBatch) {
    GlobalVariables.setMessageMap(new MessageMap());

    // create and route doc as system user
    //        GlobalVariables.setUserSession(new UserSession("kfs"));
    LOG.info("addVendor " + vendorBatch.getLogData());
    try {/*from   ww  w.  j  a  va2s  .  c o m*/

        MaintenanceDocument vendorDoc = (MaintenanceDocument) documentService
                .getNewDocument(VENDOR_DOCUMENT_TYPE_NAME);

        vendorDoc.getDocumentHeader().setDocumentDescription(getDocumentDescription(vendorBatch, true));

        VendorMaintainableImpl vImpl = (VendorMaintainableImpl) vendorDoc.getNewMaintainableObject();
        vImpl.setMaintenanceAction(KFSConstants.MAINTENANCE_NEW_ACTION);

        VendorDetail vDetail = (VendorDetail) vImpl.getBusinessObject();

        setupVendorDetailFields(vDetail, vendorBatch);
        setupInsuranceTracking((VendorDetailExtension) vDetail.getExtension(), vendorBatch);
        vDetail.setVendorAddresses(getVendorAddresses(vendorBatch.getVendorAddresses(), vDetail));

        vDetail.setVendorContacts(getVendorContacts(vendorBatch.getVendorContacts()));

        VendorHeader vHeader = vDetail.getVendorHeader();
        setupVendorHeaderFields(vHeader, vendorBatch);
        vHeader.setVendorSupplierDiversities(
                getVendorSupplierDiversities(vendorBatch.getVendorSupplierDiversities()));
        vDetail.setVendorHeader(vHeader);
        vImpl.setBusinessObject(vDetail);
        vendorDoc.setNewMaintainableObject(vImpl);
        addNotes(vendorDoc, vendorBatch);
        if (StringUtils.isNotBlank(vendorBatch.getAttachmentFiles())) {
            loadDocumentAttachments(vendorDoc,
                    Arrays.asList(vendorBatch.getAttachmentFiles().split(COLLECTION_FIELD_DELIMITER)));
        }

        documentService.routeDocument(vendorDoc, KFSConstants.EMPTY_STRING, null);

        return vendorDoc.getDocumentNumber();
    } catch (Exception e) {
        LOG.info("addVendor STE " + e.getStackTrace() + e.toString());
        return getFailRequestMessage(e);
    }
}

From source file:com.l2jfree.gameserver.model.entity.events.CTF.java

public static void spawnFlag(String teamName) {
    int index = _teams.indexOf(teamName);
    L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(_flagIds.get(index));

    try {//from w w w. j  a  v  a 2s . c  o m
        _flagSpawns.set(index, new L2Spawn(tmpl));

        _flagSpawns.get(index).setLocx(_flagsX.get(index));
        _flagSpawns.get(index).setLocy(_flagsY.get(index));
        _flagSpawns.get(index).setLocz(_flagsZ.get(index));
        _flagSpawns.get(index).setAmount(1);
        _flagSpawns.get(index).setHeading(0);
        _flagSpawns.get(index).setRespawnDelay(1);

        SpawnTable.getInstance().addNewSpawn(_flagSpawns.get(index), false);

        _flagSpawns.get(index).init();
        _flagSpawns.get(index).getLastSpawn().getStatus().setCurrentHp(999999999);
        _flagSpawns.get(index).getLastSpawn().setTitle(teamName + "'s Flag");
        _flagSpawns.get(index).getLastSpawn()._CTF_FlagTeamName = teamName;
        _flagSpawns.get(index).getLastSpawn()._isCTF_Flag = true;
        _flagSpawns.get(index).getLastSpawn().decayMe();
        _flagSpawns.get(index).getLastSpawn().spawnMe(_flagSpawns.get(index).getLastSpawn().getX(),
                _flagSpawns.get(index).getLastSpawn().getY(), _flagSpawns.get(index).getLastSpawn().getZ());
    } catch (Exception e) {
        _log.warn("CTF Engine[spawnFlag(" + teamName + ")]: exception: " + e.getStackTrace());
    }
}

From source file:io.personium.core.rs.PersoniumCoreExceptionMapper.java

@Override
public Response toResponse(final Exception exception) {
    // PersoniumCoreException ??
    if (exception instanceof PersoniumCoreException) {
        return this.handlePersoniumCoreException((PersoniumCoreException) exception);
    }/*from ww w.j  ava 2 s . c o  m*/
    // JaxRS ??
    if (exception instanceof WebApplicationException) {
        return this.handleWebApplicationException((WebApplicationException) exception);
    }
    /*
     * PersoniumCoreException???????WebApplicationException??????
     * JAX-RS???????????????Jersey?????????
     */
    // 
    // Unknown Exception????????????ID??????????
    String id = Math.abs(UUID.randomUUID().getMostSignificantBits() % ERROR_ID_ROOT) + "";
    StackTraceElement[] ste = exception.getStackTrace();
    StringBuilder sb = new StringBuilder("[PR500-SV-9999] - Unknown Exception [" + id + "] ");
    sb.append(exception.getMessage());
    if (ste != null && ste.length > 0) {
        sb.append(" @ ");
        sb.append(ste[0].getClassName() + "#" + ste[0].getMethodName() + ": " + ste[0].getLineNumber());
    }

    log.error(sb.toString(), exception);
    return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
            .entity(new ODataErrorMessage("PR500-SV-9999", "en_US", "Unknown Exception [" + id + "]")).build();
}

From source file:edu.cornell.kfs.vnd.batch.service.impl.VendorBatchServiceImpl.java

private String updateVendor(VendorBatchDetail vendorBatch) {
    GlobalVariables.setMessageMap(new MessageMap());

    // create and route doc as system user
    //      GlobalVariables.setUserSession(new UserSession("kfs"));

    try {/*ww w.  j av a  2s  .  c o  m*/

        MaintenanceDocument vendorDoc = (MaintenanceDocument) documentService
                .getNewDocument(VENDOR_DOCUMENT_TYPE_NAME);

        vendorDoc.getDocumentHeader().setDocumentDescription(getDocumentDescription(vendorBatch, false));

        LOG.info("updateVendor " + vendorBatch.getLogData());
        VendorDetail vendor = cuVendorService.getByVendorNumber(vendorBatch.getVendorNumber());
        if (vendor != null) {
            // Vendor does not eist
            VendorMaintainableImpl oldVendorImpl = (VendorMaintainableImpl) vendorDoc
                    .getOldMaintainableObject();
            oldVendorImpl.setBusinessObject(vendor);

        } else {
            // Vendor does not eist
            return "Failed request : Vendor " + vendorBatch.getVendorNumber() + " Not Found.";
        }

        VendorMaintainableImpl vImpl = (VendorMaintainableImpl) vendorDoc.getNewMaintainableObject();

        vImpl.setMaintenanceAction(KFSConstants.MAINTENANCE_EDIT_ACTION);
        vendorDoc.getNewMaintainableObject().setDocumentNumber(vendorDoc.getDocumentNumber());
        vImpl.setBusinessObject((VendorDetail) ObjectUtils.deepCopy(vendor));
        VendorDetail vDetail = (VendorDetail) vImpl.getBusinessObject();

        setupVendorDetailFields(vDetail, vendorBatch);
        setupInsuranceTracking((VendorDetailExtension) vDetail.getExtension(), vendorBatch);

        updateVendorAddresses(vendorBatch.getVendorAddresses(), vendor, vDetail);

        updateVendorContacts(vendorBatch.getVendorContacts(), vendor, vDetail);

        updateVendorSupplierDiversitys(vendorBatch.getVendorSupplierDiversities(), vendor, vDetail);

        setupVendorHeaderFields(vDetail.getVendorHeader(), vendorBatch);
        vImpl.setBusinessObject(vDetail);
        vendorDoc.setNewMaintainableObject(vImpl);
        addNotes(vendorDoc, vendorBatch);
        // attachment
        if (StringUtils.isNotBlank(vendorBatch.getAttachmentFiles())) {
            loadDocumentAttachments(vendorDoc,
                    Arrays.asList(vendorBatch.getAttachmentFiles().split(COLLECTION_FIELD_DELIMITER)));
        }
        // end attachment
        documentService.routeDocument(vendorDoc, KFSConstants.EMPTY_STRING, null);
        return vendorDoc.getDocumentNumber();
    } catch (Exception e) {
        LOG.info("updateVendor STE " + e.getStackTrace() + e.toString());
        return getFailRequestMessage(e);
    }
}

From source file:org.metis.cassandra.Client.java

/**
 * Execute the given list of Maps. Each Map is matched up against one of the
 * CQL statements assigned to this Cassandra Client.
 * /*w ww  .  j a v  a2s  .  co  m*/
 * @param listMap
 * @param method
 * @return
 * @throws Exception
 */
public List<Map<String, Object>> execute(List<Map<Object, Object>> listMap, Message inMsg) throws Exception {

    // see if request method is in the message
    String inMethod = (String) inMsg.getHeader(CASSANDRA_METHOD);
    if (inMethod == null || inMethod.isEmpty()) {
        LOG.trace(getBeanName() + ":execute - method was not provided, defaulting to {}", SELECT_STR);
        inMethod = SELECT_STR;
    }

    Method method = null;
    try {
        method = Method.valueOf(inMethod.toUpperCase());
        LOG.trace(getBeanName() + ":execute - processing this method: " + method.toString());
    } catch (IllegalArgumentException e) {
        throw new Exception(getBeanName() + ":execute: This method is not allowed [" + method + "]");
    }

    // based on the given method, attempt to find a set of candidate CQL
    // statements
    List<CqlStmnt> cqlStmnts = getCqlStmnts(method);
    if (cqlStmnts == null || cqlStmnts.isEmpty()) {
        throw new Exception(getBeanName() + ":execute - could not acquire " + "CQL statements for this method:"
                + method.toString());
    }

    // if no list of maps was passed in, then dummy one up
    List<Map<Object, Object>> myListMap = null;
    if (listMap == null) {
        LOG.trace(getBeanName() + ":execute - listMap was not provided");
        myListMap = new ArrayList<Map<Object, Object>>();
        myListMap.add(new HashMap<Object, Object>());
    } else {
        // create a copy of the given list.
        myListMap = new ArrayList<Map<Object, Object>>();
        for (Map<Object, Object> map : listMap) {
            myListMap.add(new HashMap<Object, Object>(map));
        }
    }

    LOG.trace(getBeanName() + ":execute - executing this many maps {}", myListMap.size());

    // Get the CQL statement that matches the given map(s)
    CqlStmnt cqlStmnt = CqlStmnt.getMatch(cqlStmnts, ((Map) myListMap.get(0)).keySet());

    if (cqlStmnt == null) {
        throw new Exception(getBeanName() + ":execute: this key set could not "
                + "be mapped to a CQL statement: [" + myListMap.get(0).keySet().toString() + "]");
    }

    // iterate through the given Maps (if any) and execute their
    // corresponding cql statement(s)
    try {
        List<ResultSet> resultSets = new ArrayList<ResultSet>();
        for (Map map : myListMap) {
            ResultSet resultSet = cqlStmnt.execute(map, inMsg);
            if (resultSet != null) {
                resultSets.add(resultSet);
            }
        } // for (Map map : listMap)

        LOG.trace(getBeanName() + ":execute: successfully executed statement(s)");
        LOG.trace(getBeanName() + ":execute: received this many result sets {}", resultSets.size());

        // if no result sets were returned, then we're done!
        if (resultSets.isEmpty()) {
            return null;
        }

        List<Map<String, Object>> listOutMaps = new ArrayList<Map<String, Object>>();
        Row row = null;
        // iterate through the returned result sets
        for (ResultSet resultSet : resultSets) {
            // grab the metadata for the result set
            ColumnDefinitions cDefs = resultSet.getColumnDefinitions();
            // transfer each row of the result set to a Map and place all
            // the maps in a List
            while ((row = resultSet.one()) != null) {
                Map<String, Object> map = new HashMap<String, Object>();
                for (Definition cDef : cDefs.asList()) {
                    map.put(cDef.getName(),
                            CqlToken.getObjectFromRow(row, cDef.getName(), cDef.getType().getName()));
                }
                listOutMaps.add(map);
            }
        }
        // return the List of Maps up into the Exchange's out message
        LOG.trace(getBeanName() + ":camelProcess: sending back this many Maps {}", listOutMaps.size());

        return listOutMaps;

    } catch (Exception exc) {
        LOG.error(getBeanName() + ":ERROR, caught this " + "Exception while executing CQL statement "
                + "message: " + exc.toString());
        LOG.error(getBeanName() + ": exception stack trace follows:");
        dumpStackTrace(exc.getStackTrace());
        if (exc.getCause() != null) {
            LOG.error(getBeanName() + ": Caused by " + exc.getCause().toString());
            LOG.error(getBeanName() + ": causing exception stack trace follows:");
            dumpStackTrace(exc.getCause().getStackTrace());
        }
        // throw the exception back
        throw exc;
    }
}

From source file:nl.b3p.kaartenbalie.service.ImageCollector.java

private void handleRequestException(Exception ex) {
    log.error("error callimage collector: ", ex);
    // check if client wants xml or image error
    OGCRequest ogcr = dw.getOgcrequest();
    if (ogcr.containsParameter(OGCConstants.WMS_PARAM_EXCEPTIONS) && OGCConstants.WMS_PARAM_EXCEPTION_XML
            .equalsIgnoreCase(ogcr.getParameter(OGCConstants.WMS_PARAM_EXCEPTIONS))) {
        // if xml handle it elsewhere
        setMessage(ex.getMessage());//from  ww w.jav  a  2  s.  c  o m
        setStatus(ERROR);
    } else {
        // if image it will be added to the stack of images collected
        try {
            ExceptionLayer el = new ExceptionLayer();
            Map parameterMap = new HashMap();
            parameterMap.put("type", ex.getClass());
            parameterMap.put("message", ex.getMessage());
            parameterMap.put("stacktrace", ex.getStackTrace());
            parameterMap.put("transparant", Boolean.TRUE);
            parameterMap.put("index", new Integer(index));
            setBufferedImage(el.drawImage(ogcr, parameterMap));
            setMessage(ex.getMessage());
            setStatus(WARNING);
        } catch (Exception e) {
            log.error("error during callimage collector error handling: ", e);
            // if no image produced revert to original error message
            setMessage(e.getMessage());
            setStatus(ERROR);
        }
    }
}

From source file:es.bsc.servicess.ide.PackagingUtils.java

private static void processPackageBuilding(String pack, List<String> subPacks, String runtimePath,
        ProjectMetadata prMeta, IFolder packFolder, IProgressMonitor myProgressMonitor) throws CoreException {
    try {/*from www  .ja v  a2s  .co  m*/
        for (String sp : subPacks) {
            IFolder spFolder = packFolder.getFolder(getPackageName(sp));
            if (spFolder != null && spFolder.exists()) {
                //TODO add runtimeLibraries
                log.warn("Jar packages not supported");
                IFile spFile = packFolder.getFile(getPackageNameWithExtension(sp));
                createJar(spFile, spFolder, myProgressMonitor);
                spFolder.delete(true, myProgressMonitor);
                FileUtils.copyFile(spFile.getRawLocation().toFile(), new File(sp));
            } else {
                throw (new CoreException(
                        new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Subpackage " + sp + " not found")));
            }
        }
        IFolder spFolder = packFolder.getFolder(getPackageName(pack));
        if (spFolder != null && spFolder.exists()) {

            if (pack.endsWith(".jar")) {
                //TODO Add runtime libraries
                log.warn("Jar packages not supported");
            } else {
                IFolder lib = spFolder.getFolder("WEB-INF").getFolder("lib");
                copyOrchestrationRuntimeFiles(runtimePath, lib);
            }
            IFile spFile = packFolder.getFile(getPackageNameWithExtension(pack));
            createJar(spFile, spFolder, myProgressMonitor);
            spFolder.delete(true, myProgressMonitor);
        } else {
            throw (new CoreException(
                    new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Package " + pack + " not found")));
        }

    } catch (Exception e) {
        if (e instanceof CoreException) {
            throw ((CoreException) e);
        } else {
            CoreException ce = new CoreException(
                    new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
            ce.setStackTrace(e.getStackTrace());
            throw (ce);
        }
    }
}

From source file:co.forsaken.api.json.JsonWebCall.java

public void execute(Object arg) {
    if (_log)//from w  w w.j  av  a 2  s.com
        System.out.println("Requested: [" + _url + "]");
    try {
        canConnect();
    } catch (Exception ex) {
        ex.printStackTrace();
        return;
    }
    HttpClient httpClient = new DefaultHttpClient(_connectionManager);
    try {
        Gson gson = new Gson();
        HttpPost request = new HttpPost(_url);
        if (arg != null) {
            StringEntity params = new StringEntity(gson.toJson(arg));
            params.setContentType(new BasicHeader("Content-Type", "application/json"));
            request.setEntity(params);
        }
        httpClient.execute(request);
    } catch (Exception ex) {
        System.out.println("JSONWebCall.executeNoRet() Error: \n" + ex.getMessage());
        StackTraceElement[] arrOfSTE;
        int max = (arrOfSTE = ex.getStackTrace()).length;
        for (int i = 0; i < max; i++) {
            StackTraceElement trace = arrOfSTE[i];
            System.out.println(trace);
        }
    } finally {
        httpClient.getConnectionManager().shutdown();
    }
    if (_log)
        System.out.println("Returned: [" + _url + "]");
}

From source file:com.castis.xylophone.adsmadapter.convert.axistree.ConvertContentAxisTreeDTO.java

public int mergeContentTreenode(ADSMSchedulerLogDTO schedulerLog, Date date, PlayInfo playInfo, int dataLogId,
        boolean updateTreeNode, PlacementOpportunityTypeEnum oppType, String publisher, Platform platformType)
        throws Exception {
    int treeID = 0;
    try {// w w  w . j a v a2 s  .com
        //         NodeDTO rootNodeDTO = getRootNode(ROOT_NODE_NAME);
        NodeDTO rootNodeDTO = getContentRootNode(ROOT_NODE_NAME);
        treeID = tambourineConnector.getAxisTreeId(TreeType.VOD_CONTENTS_AXIS, Constants.tree.CONTENT_TREE_NAME,
                publisher, platformType, false);
        //?
        if (treeID <= 0)
            treeID = tambourineConnector.registerContentAxisTree(getAxisTreeDTO(
                    Constants.tree.CONTENT_TREE_NAME, rootNodeDTO, false, null, publisher, platformType), date);

        if (playInfo != null)
            addContentToTargetMap(playInfo, oppType, TreeType.VOD_CONTENTS_AXIS, publisher, platformType);

        TargetedContentInfo targetedContentInfo = getAllTargettedContentIdList(TreeType.VOD_CONTENTS_AXIS,
                dataLogId, InventoryType.VOD);

        int linkTreeId = -1;
        linkTreeId = makeTreeNode(treeID, date, rootNodeDTO.getExternalNodeId(), targetedContentInfo,
                !updateTreeNode, dataLogId, publisher, platformType);

        tambourineConnector.insertTreeLogNSyncNoticeboard(linkTreeId, TreeType.VOD_CONTENTS_AXIS,
                Constants.tree.CONTENT_LINK_TREE_NAME, null, publisher, platformType);
        tambourineConnector.insertTreeLogNSyncNoticeboard(treeID, TreeType.VOD_CONTENTS_AXIS,
                Constants.tree.CONTENT_TREE_NAME, null, publisher, platformType);

        schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS);
        TheLogger.getWriter().info("Update Content Tree Success");
    } catch (Exception e) {
        //log.error("",e);
        TheLogger.getWriter().error("Fail to Update Content Tree");
        log.error("Fail to Update Content Tree");
        schedulerLog.setMessage(e.getMessage());
        schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL);
        StackTraceElement[] stackTraces = e.getStackTrace();
        if (stackTraces.length > 0) {
            schedulerLog.setFailProcess(stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName()
                    + "(" + stackTraces[0].getLineNumber() + ")");
        }
        throw e;
    }
    return treeID;
}

From source file:lucee.runtime.engine.CFMLEngineImpl.java

private CFMLFactoryImpl loadJSPFactory(ConfigServerImpl configServer, ServletConfig sg,
        int countExistingContextes) throws ServletException {
    try {// w  w w  .jav  a  2  s  . com
        // Load Config
        RefBoolean isCustomSetting = new RefBooleanImpl();
        Resource configDir = getConfigDirectory(sg, configServer, countExistingContextes, isCustomSetting);

        CFMLFactoryImpl factory = new CFMLFactoryImpl(this, sg);
        ConfigWebImpl config = XMLConfigWebFactory.newInstance(factory, configServer, configDir,
                isCustomSetting.toBooleanValue(), sg);
        factory.setConfig(config);
        return factory;
    } catch (Exception e) {
        ServletException se = new ServletException(e.getMessage());
        se.setStackTrace(e.getStackTrace());
        throw se;
    }

}