Example usage for com.fasterxml.jackson.core JsonProcessingException printStackTrace

List of usage examples for com.fasterxml.jackson.core JsonProcessingException printStackTrace

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonProcessingException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:eu.supersede.fe.application.ApplicationUtil.java

/**
 * Add a gadget with the given name for the given application with the given required profiles.
 * @param applicationName/*from   ww  w .  j  a  va2 s.  c o  m*/
 * @param applicationGadget
 * @param profilesRequired
 */
public void addApplicationGadget(String applicationName, String applicationGadget,
        List<String> profilesRequired) {
    ApplicationGadget gadget = new ApplicationGadget(applicationName, applicationGadget, profilesRequired);

    try {
        template.opsForHash().put(GADGET_KEY, gadget.getId(), mapper.writeValueAsString(gadget));
    } catch (JsonProcessingException e) {
        log.debug(e.getMessage());
        e.printStackTrace();
    }
}

From source file:org.apache.griffin.core.job.SparkSubmitJob.java

public void setSparkJobDO() {
    sparkJobDO.setFile(sparkJobProps.getProperty("sparkJob.file"));
    sparkJobDO.setClassName(sparkJobProps.getProperty("sparkJob.className"));

    List<String> args = new ArrayList<String>();
    args.add(sparkJobProps.getProperty("sparkJob.args_1"));
    ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
    String measureJson = "";
    try {/*w w  w .ja v a2 s . c  o  m*/
        measureJson = ow.writeValueAsString(measure);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    args.add(measureJson); //partition
    args.add(sparkJobProps.getProperty("sparkJob.args_3"));
    sparkJobDO.setArgs(args);

    sparkJobDO.setName(sparkJobProps.getProperty("sparkJob.name"));
    sparkJobDO.setQueue(sparkJobProps.getProperty("sparkJob.queue"));
    sparkJobDO.setNumExecutors(Long.parseLong(sparkJobProps.getProperty("sparkJob.numExecutors")));
    sparkJobDO.setExecutorCores(Long.parseLong(sparkJobProps.getProperty("sparkJob.executorCores")));
    sparkJobDO.setDriverMemory(sparkJobProps.getProperty("sparkJob.driverMemory"));
    sparkJobDO.setExecutorMemory(sparkJobProps.getProperty("sparkJob.executorMemory"));

    Map<String, String> conf = new HashMap<String, String>();
    conf.put("spark.jars.packages", sparkJobProps.getProperty("sparkJob.spark.jars.packages"));
    sparkJobDO.setConf(conf);

    List<String> jars = new ArrayList<>();
    jars.add(sparkJobProps.getProperty("sparkJob.jars_1"));
    jars.add(sparkJobProps.getProperty("sparkJob.jars_2"));
    jars.add(sparkJobProps.getProperty("sparkJob.jars_3"));
    sparkJobDO.setJars(jars);

    List<String> files = new ArrayList<>();
    sparkJobDO.setFiles(files);
}

From source file:bi.meteorite.util.ITestBootstrap.java

protected Response post(String url, String user, String pass, String type, Object data, Class c) {
    List<Object> providers = new ArrayList<Object>();
    providers.add(new JacksonJsonProvider());

    WebClient client = WebClient.create(url, providers);

    ObjectMapper objectMapper = new ObjectMapper();
    String s = null;//from w  w  w  .  j  a v a  2 s . co  m
    try {
        s = objectMapper.writeValueAsString(data);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }

    Response repo = client.type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)
            .header("Authorization", getBasicAuthentication(user, pass))
            //.post(Entity.entity(data, MediaType.APPLICATION_JSON), c);
            .post(data);
    return repo;
}

From source file:com.spotify.elasticsearch.plugins.indexwindow.IndexWindowAction.java

private void writeToElasticsearch(IndexWindow indexWindow) {
    String json = null;/* w  ww.  j ava 2  s  .c o  m*/
    try {
        json = mapper.writeValueAsString(indexWindow);
        client.prepareIndex(META_INDEX, META_TYPE, indexWindow.getIndexPrefix()).setSource(json).execute()
                .actionGet();
    } catch (final JsonProcessingException e) {
        e.printStackTrace();
    }
}

From source file:org.hawkular.apm.api.model.trace.TraceTest.java

@Test
public void testEqualityAfterDeserialization() {
    Trace trace = example1();//from  ww w.  ja  v  a  2  s.  c  o m

    // Serialize
    ObjectMapper mapper = new ObjectMapper();
    String json = null;

    try {
        json = mapper.writeValueAsString(trace);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        fail("Failed to serialize");
    }

    assertNotNull(json);

    Trace trace2 = null;

    try {
        trace2 = mapper.readValue(json.getBytes(), Trace.class);
    } catch (IOException e) {
        e.printStackTrace();
        fail("Failed to deserialize");
    }

    assertNotNull(trace2);

    assertEquals(trace, trace2);
}

From source file:io.samsungsami.example.samiiotsimplecontroller.SAMISession.java

private void sendActionInDeviceChannelWS(String actionName) {
    ActionIn actionIn = new ActionIn();
    ActionDetails action = new ActionDetails();
    ArrayList<ActionDetails> actions = new ArrayList<>();
    ActionDetailsArray actionDetailsArray = new ActionDetailsArray();

    action.setName(actionName);/*from ww  w  .  j  a va 2  s  .c  o  m*/
    actions.add(action);
    actionDetailsArray.setActions(actions);
    actionIn.setData(actionDetailsArray);
    actionIn.setCid(actionName);
    actionIn.setDdid(DEVICE_ID);
    actionIn.setTs(BigDecimal.valueOf(System.currentTimeMillis()));

    try {
        mWS.sendAction(actionIn);
        Log.d(TAG, "DeviceChannelWebSocket sendAction:" + actionIn.toString());
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }

}

From source file:com.github.hdl.tensorflow.yarn.app.ClusterSpec.java

public void testClusterString() {
    LOG.info("clusterspec: " + this.toString());
    try {/*from  w  ww.ja  v  a  2  s  . c om*/
        LOG.info("clusterspec JsonString: " + this.getJsonString());
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    } catch (ClusterSpecException e) {
        e.printStackTrace();
    }
    try {
        LOG.info("clusterspec encodeJsonString: " + this.getBase64EncodedJsonString());
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    } catch (ClusterSpecException e) {
        e.printStackTrace();
    }
    String base64DecodedString = null;
    try {
        base64DecodedString = ClusterSpec.decodeJsonString(this.getBase64EncodedJsonString());
        LOG.info("clusterspec decodeJsonString: " + base64DecodedString);
        if (base64DecodedString.equals(this.getJsonString())) {
            LOG.info("raw and decode is equal!");
        }
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    } catch (ClusterSpecException e) {
        e.printStackTrace();
    }

    try {
        Map<String, List<String>> cs = ClusterSpec.toClusterMapFromJsonString(base64DecodedString);
        if (cs.containsKey(WORKER)) {
            for (String s : cs.get(WORKER)) {
                LOG.info(s);
            }
        }

        if (cs.containsKey(PS)) {
            for (String s : cs.get(PS)) {
                LOG.info(s);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:ch.icclab.cyclops.services.iaas.openstack.persistence.TSDBResource.java

/**
 * Receives the transformed usage data from an external application in terms of an TSDBData POJO.
 * POJO is converted into a json object and the InfluxDB client is invoked to persist the data.
 * <p>//from   w  w  w  . j a v a2  s.  c  o m
 * Pseudo Code<br/>
 * 1. Convert the TSDB POJO consisting of the usage data into a JSON Obj<br/>
 * 2. Invoke the InfluxDB client<br/>
 * 3. Save the data in to the DB
 *
 * @param dbData
 * @return result A boolean output as a result of saving the meter data into the db
 */
public boolean saveExtData(TSDBData dbData) {
    InfluxDBClient dbClient = new InfluxDBClient();
    ObjectMapper mapper = new ObjectMapper();
    String jsonData;
    boolean result = true;

    try {
        jsonData = mapper.writeValueAsString(dbData);
        dbClient.saveExtData(jsonData);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        result = false;
        return result;
    }
    return result;
}

From source file:com.pavlovmedia.oss.osgi.gelf.impl.GelfLogSink.java

public void logged(LogEntry entry) {
    if (!active) {
        return; // We aren't running
    }/*from  ww  w . j a  v  a 2 s. c o m*/

    ensureConnection();

    if (null == transport) {
        return; // Not getting connected/reconnected
    }

    GelfMessage message = GelfMessageConverter.fromOsgiMessage(entry);
    try {
        byte[] messageBytes = mapper.writeValueAsBytes(message);
        transport.getOutputStream().write(messageBytes);
        // There is a bug in GELF that requires us to end with a null byte
        transport.getOutputStream().write(new byte[] { '\0' });
    } catch (JsonProcessingException e) {
        if (consoleMessages) {
            System.err.println("Failed serializing a GelfMessage " + e.getMessage());
            e.printStackTrace();
        }
    } catch (IOException e) {
        if (consoleMessages) {
            System.err.println("Failed writing GelfMessage " + e.getMessage());
            e.printStackTrace();
        }
        try {
            transport.close();
        } catch (IOException e1) {
            /* Do nothing */ }
        transport = null;
    }
}

From source file:org.verdictdb.core.scrambling.ScrambleMeta.java

public String toJsonString() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
    String jsonString;/*from  ww w.j a  v a 2s  .c  o m*/
    try {
        jsonString = objectMapper.writeValueAsString(this);
        return jsonString;
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        return null;
    }
}