Example usage for java.lang IllegalArgumentException printStackTrace

List of usage examples for java.lang IllegalArgumentException printStackTrace

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:adminviews.MCCView.java

private List<Property> parseXMLFactors(Sample s) {
    try {/*  w  ww.j  a  va 2s. c  o m*/
        return p.getExpFactorsFromXML(s.getProperties().get("Q_PROPERTIES"));
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (JAXBException e) {
        e.printStackTrace();
    }
    logger.error("Error while parsing Q_PROPERTIES XML");
    return null;
}

From source file:de.clusteval.data.dataset.format.DataSetFormat.java

@Override
public final DataSetFormat clone() {
    try {/*  ww w  . j a va  2s.  c o  m*/
        return this.getClass().getConstructor(this.getClass()).newInstance(this);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
    this.log.warn("Cloning instance of class " + this.getClass().getSimpleName() + " failed");
    return null;
}

From source file:com.jpeterson.util.http.RangeInputStreamTest.java

public void test_illegalRange() {
    // Stream of bytes: 0123456789abcdef
    // Range: bytes=0-9
    // RangeInputStream: 0123456789
    // Range: bytes=5-6
    // RangeInputStream: 56

    String data = "0123456789abcdef";
    ByteArrayInputStream dataStream;
    RangeInputStream in;//from  w  ww.  j a  va2  s  .c  o  m
    Range range;
    byte[] b;
    int count;

    try {
        dataStream = new ByteArrayInputStream(data.getBytes());

        range = new Range(0, 5);
        in = new RangeInputStream(dataStream, range);

        b = new byte[10];
        count = in.read(b, 0, b.length);

        assertEquals("Unexpected number of bytes read", 6, count);

        assertEquals('0', b[0]);
        assertEquals('1', b[1]);
        assertEquals('2', b[2]);
        assertEquals('3', b[3]);
        assertEquals('4', b[4]);
        assertEquals('5', b[5]);

        try {
            in.setRange(range);
            fail("Should throw and exception");
        } catch (IllegalArgumentException e) {
            // expected
        }
    } catch (IOException e) {
        e.printStackTrace();
        fail("Unexpected exception");
    }
}

From source file:org.kuali.rice.krad.dao.impl.BusinessObjectDaoOjb.java

private <T extends BusinessObject> Criteria buildCriteria(Class<T> clazz, Object primaryKey) {
    Map<String, Object> fieldValues = new HashMap<String, Object>();
    List<String> fieldNames = getPersistenceStructureService().getPrimaryKeys(clazz);

    //create map of values
    for (String fieldName : fieldNames) {
        Object fieldValue;/*from  w  w  w.j a  va2 s.co  m*/

        try {
            fieldValue = primaryKey.getClass().getMethod("get" + StringUtils.capitalize(fieldName))
                    .invoke(primaryKey);
            fieldValues.put(fieldName, fieldValue);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }
    return this.buildCriteria(fieldValues);
}

From source file:org.kalypso.afgui.internal.TaskPerspectiveStore.java

private Version getVersion(final XMLMemento definition) {
    final String versionText = definition.getString(KEY_KALYPSO_VERISON);
    if (StringUtils.isBlank(versionText))
        return null;

    try {/*  w w  w.j  av  a2s  .  c  o  m*/
        return new Version(versionText);
    } catch (final IllegalArgumentException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:fr.bmartel.fadecandy.activity.MainActivity.java

@Override
protected void onDestroy() {
    super.onDestroy();
    Log.v(TAG, "onDestroy()");

    if (mDialog != null) {
        mDialog.dismiss();/*from   w  w  w .  ja v  a2 s.c  o  m*/
    }

    mSingleton.removeListener(mListener);

    mStarted = false;
    try {
        if (mSingleton != null) {
            mSingleton.disconnect();
        }
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }
}

From source file:org.apache.hadoop.hdfs.AvatarZKShell.java

/**
 * run//from  ww  w .  j  a v  a2s. c o  m
 */
public int run(String argv[]) throws Exception {

    if (argv.length < 1) {
        printUsage("");
        return -1;
    }

    int exitCode = 0;
    String zkCmd = null;
    String serviceName = null;
    String instance = null;
    boolean force = false;

    // enforce to specify service if configured
    if (!AvatarShell.isServiceSpecified("AvatarZKShell", conf, argv)) {
        return -1;
    }

    for (int i = 0; i < argv.length; i++) {
        String cmd = argv[i];

        //
        // verify that we have enough command line parameters
        //
        if ("-service".equals(cmd)) {
            if (i + 1 == argv.length) {
                printUsage(cmd);
                return -1;
            }
            serviceName = argv[++i];
        } else if ("-updateZK".equals(cmd)) {
            zkCmd = cmd;
            if (i + 1 == argv.length) {
                printUsage(cmd);
                return -1;
            }
            instance = argv[++i];
            if (i + 1 < argv.length && argv[i + 1].equals("-force")) {
                force = true;
                i++;
            }
        } else if ("-clearZK".equals(cmd)) {
            zkCmd = cmd;
        } else if ("-createZK".equals(cmd)) {
            zkCmd = cmd;
            if (i + 1 == argv.length) {
                printUsage(cmd);
                return -1;
            }
            instance = argv[++i];
        } else if ("-getZK".equals(cmd)) {
            zkCmd = cmd;
        } else {
            exitCode = -1;
            System.err.println(cmd.substring(1) + ": Unknown command");
            printUsage("");
        }
    }

    // make sure that command is provided
    if (zkCmd == null) {
        printUsage("");
        return -1;
    }

    Collection<String> services;
    if (serviceName != null) { // for one service
        if (!AvatarNode.validateServiceName(conf, serviceName)) {
            return -1;
        }
        services = new ArrayList<String>(1);
        services.add(serviceName);
    } else { // for all configured services
        services = DFSUtil.getNameServiceIds(conf);
        if (services.size() == 0) {
            //non-federation
            services.add("");
        }
    }

    try {
        for (String service : services) {
            AvatarNode.initializeGenericKeys(originalConf, service);
            if ("-updateZK".equals(zkCmd) || "-createZK".equals(zkCmd)) {
                if (instance == null || (conf = updateConf(instance, originalConf)) == null) {
                    printUsage(zkCmd);
                    return -1;
                }
            }

            if ("-updateZK".equals(zkCmd)) {
                updateZooKeeper(force, service, instance);
            } else if ("-clearZK".equals(zkCmd)) {
                clearZooKeeper(service);
            } else if ("-createZK".equals(zkCmd)) {
                updateZooKeeper(true, false, service, instance);
            } else if ("-getZK".equals(zkCmd)) {
                getZooKeeper(service);
            }
        }
    } catch (IllegalArgumentException arge) {
        exitCode = -1;
        arge.printStackTrace();
        System.err.println(zkCmd.substring(1) + ": " + arge.getLocalizedMessage());
        printUsage(zkCmd);
    } catch (RemoteException e) {
        exitCode = -1;
        try {
            String[] content;
            content = e.getLocalizedMessage().split("\n");
            System.err.println(zkCmd.substring(1) + ": " + content[0]);
        } catch (Exception ex) {
            System.err.println(zkCmd.substring(1) + ": " + ex.getLocalizedMessage());
        }
    } catch (IOException e) {
        //
        // IO exception encountered locally.
        //
        exitCode = -1;
        System.err.println(zkCmd.substring(1) + ": " + e.getLocalizedMessage());
        e.printStackTrace();
    } catch (Throwable re) {
        exitCode = -1;
        System.err.println(zkCmd.substring(1) + ": " + re.getLocalizedMessage());
        re.printStackTrace();
    } finally {
    }
    return exitCode;
}

From source file:it.lilik.capturemjpeg.CaptureMJPEG.java

private void setErrorImage(TextImage error) {

    try {// www  .j ava2 s .c o  m
        captureEventMethod.invoke(parent, new Object[] { this.assign(error) });
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.apache.hadoop.hbase.mapreduce.CompositeKeyTsvImporterMapper.java

/**
 * Convert a line of TSV text into an HBase table row.
 *//*from  w w w  . j  a va  2 s .c  o m*/
@Override
public void map(LongWritable offset, Text value, Context context) throws IOException {
    byte[] lineBytes = value.getBytes();

    try {
        CompositeKeyImportTsv.TsvParser.ParsedLine parsed = parser.parse(lineBytes, value.getLength());
        ImmutableBytesWritable rowKey = parsed.getRowKey();
        // Retrieve timestamp if exists
        ts = parsed.getTimestamp(ts);
        Collection<Integer> rowkeyValues = parser.getRowKeyColumnsIndex().values();
        Put put = new Put(rowKey.copyBytes());
        for (int i = 0; i < parsed.getColumnCount(); i++) {
            if (rowkeyValues.contains(i) || i == parser.getTimestampKeyColumnIndex()) {
                continue;
            }
            KeyValue kv = new KeyValue(rowKey.copyBytes(), 0, rowKey.copyBytes().length, parser.getFamily(i), 0,
                    parser.getFamily(i).length, parser.getQualifier(i), 0, parser.getQualifier(i).length, ts,
                    KeyValue.Type.Put, lineBytes, parsed.getColumnOffset(i), parsed.getColumnLength(i));
            put.add(kv);
        }
        context.write(rowKey, put);
    } catch (CompositeKeyImportTsv.TsvParser.BadTsvLineException badLine) {
        if (skipBadLines) {
            LOG.error("Bad line at offset: " + offset.get() + ":\n" + badLine.getMessage());
            //badLine.printStackTrace();
            incrementBadLineCount(1);
            return;
        } else {
            throw new IOException(badLine);
        }
    } catch (IllegalArgumentException e) {
        if (skipBadLines) {
            LOG.error("Bad line at offset: " + offset.get() + ":\n" + e.getMessage());
            incrementBadLineCount(1);
            return;
        } else {
            throw new IOException(e);
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}