Example usage for java.lang SecurityException printStackTrace

List of usage examples for java.lang SecurityException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:gov.llnl.lc.smt.command.config.SmtConfig.java

/**
 * Describe the method here//w  w  w  . j  a v  a 2  s .  c om
 *
 * @see     describe related java objects
 *
 * @param options
 ***********************************************************/
private boolean configLogging() {
    boolean status = false;
    // fix any changes to the logging system
    if (sConfigMap.containsKey(SmtProperty.SMT_LOG_FILE.getName())) {
        status = true; // a valid argument
        String pattern = sConfigMap.get(SmtProperty.SMT_LOG_FILE.getName());

        java.util.logging.Handler hpcHandlerF = null;
        try {
            // set the file pattern
            hpcHandlerF = new java.util.logging.FileHandler(pattern, true);
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block, probably because path to logging is not set up
            // a typical error is;
            // java.io.IOException: Couldn't get lock for %h/.smt/smt-console%u.log
            e.printStackTrace();
        }
        logger.addHandler(hpcHandlerF);
        Handler[] lhand = logger.getHandlers();

        if (lhand.length > 1) {
            // changing to a new handler, get rid of the original one
            lhand[0].close();
            logger.removeHandler(lhand[0]);
            logger.info("Replaced the original log handler");
        }
        // Done, may want to clean up previous log file,if any??

    }

    if (sConfigMap.containsKey(SmtProperty.SMT_LOG_LEVEL.getName())) {
        status = true; // a valid argument
        Level level = logger.getLevel(); // just keep the default
        try {
            Level l = Level.parse(sConfigMap.get(SmtProperty.SMT_LOG_LEVEL.getName()));
            level = l;
        } catch (IllegalArgumentException iae) {

        }
        logger.info("Setting the log level to: " + level.toString());
        logger.setLevel(level);
    }
    return status;
}

From source file:org.mrgeo.mapalgebra.MapAlgebraParser.java

private void init() {
    OpImageRegistrar.registerMrGeoOps();

    // include any computationally expensive operations in the cached ops list.
    // This will cause the tiles to be cached. It is also a good idea to add
    // operations that read from multiple sources to the cached list.
    cachedOps.add("slope");

    parser = ParserAdapterFactory.createParserAdapter();
    parser.initialize();/*from  w w w  .j a  v a2  s .  c  o m*/

    // register mapops
    Reflections reflections = new Reflections("org.mrgeo");

    Set<Class<? extends MapOp>> subTypes = reflections.getSubTypesOf(MapOp.class);

    log.debug("Registering MapOps:");
    for (Class<? extends MapOp> clazz : subTypes) {
        try {
            if (!Modifier.isAbstract(clazz.getModifiers())) {
                registerFunctions(clazz);
            }
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    for (String n : mapOps.keySet()) {
        parser.addFunction(n);
    }

    _loadFactoryFunctions();

    parser.afterFunctionsLoaded();
}

From source file:com.medsphere.fileman.FMRecord.java

/**
 * if the annotation is a method, get the setter for the method and invoke it.
 * @param ele/*from  www.j av  a  2s .c om*/
 * @param method
 * @param obj
 */
private void invokeSetter(AnnotatedElement ele, Method method, Object obj) {
    String getter = method.getName();
    String setterName = getter.replaceFirst("get", "set");
    try {
        Method setter = method.getDeclaringClass().getMethod(setterName, obj.getClass());
        setter.invoke(this, obj);
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
        logger.error("Unable to find setter for " + ele.toString()
                + ".  Ensure that a setter exists for this field.  Expecting " + setterName);
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:it.drwolf.ridire.index.cwb.CWBCollocatesExtractor.java

@PreDestroy
public void preDestroy() {
    try {/*  w  w  w . j a  va2 s . com*/
        this.dropDB();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.mrgeo.mapalgebra.MapAlgebraParser.java

@SuppressWarnings("unchecked")
private void _loadFactoryFunctions() {
    _factoryMap = new HashMap<String, MapOpFactory>();

    Reflections reflections = new Reflections("org.mrgeo");

    Set<Class<? extends MapOpFactory>> subTypes = reflections.getSubTypesOf(MapOpFactory.class);

    for (Class<? extends MapOpFactory> clazz : subTypes) {
        if (clazz != this.getClass()) {
            try {
                log.debug("Registering Factory: " + clazz.getCanonicalName());

                Object cl = clazz.newInstance();

                Method method;//from  ww w .  j  a  v  a2s.  c om
                method = clazz.getMethod("getMapOpNames");
                Object o = method.invoke(cl);

                ArrayList<String> names;
                if (o != null) {
                    names = (ArrayList<String>) o;

                    for (String name : names) {
                        log.debug("    " + name);
                        parser.addFunction(name);
                        ((MapOpFactory) cl).setRootFactory(this);
                        _factoryMap.put(name, (MapOpFactory) cl);
                    }
                }
            } catch (SecurityException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            }
        }
    }

    //    ServiceLoader<MapOpFactory> loader = ServiceLoader
    //        .load(org.mrgeo.mapreduce.MapOpFactory.class);
    //
    //    _factoryMap = new HashMap<String, org.mrgeo.mapreduce.MapOpFactory>();
    //
    //    for (MapOpFactory s : loader)
    //    {
    //      log.info("Found MapOpFactory: " + s.toString());
    //      s.setRootFactory(this);
    //      for (String n : s.getMapOpNames())
    //      {
    //        _factoryMap.put(n, s);
    //        log.debug("Added MapOp: " + n + " to MapOpFactory: " + s.toString());
    //        parser.addFunction(n, sum);
    //      }
    //    }
}

From source file:coral.service.ExpTemplateUtil.java

public String evalScriptR(String scriptname, ExpData data, ErrorFlag error, ExpServiceImpl service) {

    // Map<String, String> newOrChangedMap = new LinkedHashMap<String, sss
    // String>();

    // ScriptEngine jsEngine = m.getEngineByName("js");
    // ScriptContext context = new SimpleScriptContext();

    Context context = Context.enter();

    Scriptable scope = context.initStandardObjects();

    // context.setAttribute("data", data, ScriptContext.ENGINE_SCOPE);
    // context.setAttribute("error", error, ScriptContext.ENGINE_SCOPE);

    for (Map.Entry<String, Object> e : data.entrySet()) {
        if (e != null && e.getKey() != null && !e.getKey().toString().equals("")) {
            Object value = data.get(e.getKey());

            if (logger.isDebugEnabled()) {
                logger.debug("entered value: " + e.getKey() + " == " + value + " \t\t | " + value.getClass());
            }/*from w  ww.java 2  s  . c  om*/
            scope.put(e.getKey(), scope, value);
        }
    }

    if (service != null) {
        scope.put("agents", scope, service.getAllData().values().toArray());
    }

    try {
        BufferedReader br = new BufferedReader(new FileReader(new File(basepath + scriptname)));

        Object o = context.evaluateReader(scope, br, "coral", 1, null);
        if (logger.isDebugEnabled())
            logger.debug("JS OBJECT: " + o);

        for (Object keyOb : scope.getIds()) {
            String key = keyOb.toString();
            Object value = scope.get(key.toString(), scope);

            if (logger.isDebugEnabled())
                logger.debug("KEYS: " + key + " value: " + value);

            // TODO dirty way to unwrap NativeJavaObjects
            if (!(value instanceof Number) && !(value instanceof String)) {
                try {
                    Method m = value.getClass().getMethod("unwrap");
                    value = m.invoke(value);
                } catch (SecurityException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (NoSuchMethodException e1) {
                    // TODO Auto-generated catch block
                    // e1.printStackTrace();
                } catch (IllegalArgumentException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (IllegalAccessException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (InvocationTargetException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }

            if (value instanceof Number || value instanceof String) {
                if (!data.containsKey(key) || data.get(key) == null
                        || !data.get(key).toString().equals(value.toString())) {
                    data.put(key, value);
                    // newOrChangedMap.put(key, value.toString());
                    if (logger.isDebugEnabled()) {
                        logger.debug("SCRIPTED VALUE: " + key + " == " + value.toString() + " \t\t | "
                                + value.getClass());
                    }
                } else {
                    if (logger.isDebugEnabled()) {
                        logger.debug("retained: " + key + " == " + value.toString());
                    }
                }
            } else if (value instanceof List<?>) {
                Object[] array = ((List<?>) value).toArray();

                if (!data.containsKey(key) || data.get(key) == null
                        || !data.get(key).toString().equals(Arrays.asList(array).toString())) {
                    data.put(key, array);
                    // newOrChangedMap.put(key, array);
                    if (logger.isDebugEnabled()) {
                        logger.debug("SCRIPTED ARRAY: " + key + " == " + value.toString() + " \t\t | "
                                + value.getClass());
                    }
                } else {
                    if (logger.isDebugEnabled()) {
                        logger.debug("ARRAY retained: " + key + " == " + value.toString());
                    }
                }

                logger.debug("ARRAY: " + key + " == " + value.toString() + " \t\t | " + value.getClass());
            } else {
                logger.debug("NONVALUE: " + key + " == " + value.toString() + " \t\t | " + value.getClass());
            }
            // context.removeAttribute(key,
            // ScriptContext.ENGINE_SCOPE);

        }

    } catch (FileNotFoundException e1) {
        logger.error("File Not Found Exception ", e1);
        return errorPage(scriptname + " " + e1.getMessage());
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    return null;
}

From source file:bammerbom.ultimatecore.bukkit.resources.utils.BossbarUtil.java

public Object getDestroyPacket() {
    Class<?> PacketPlayOutEntityDestroy = Util.getCraftClass("PacketPlayOutEntityDestroy");

    Object packet = null;//w w w  . j  av  a 2s.c  o m
    try {
        packet = PacketPlayOutEntityDestroy.newInstance();
        Field a = PacketPlayOutEntityDestroy.getDeclaredField("a");
        a.setAccessible(true);
        a.set(packet, new int[] { this.id });
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }

    return packet;
}

From source file:com.wipro.sa349342.wmar.AbstractArchitectCamActivity.java

@Override
public void onMapReady(GoogleMap googleMap) {

    try {//from   w  w w. j  av a  2  s  .  c o  m
        mMap = googleMap;

        mMap.animateCamera(CameraUpdateFactory.zoomTo(13));

        mMap.setMyLocationEnabled(true);
        //mMap.setLocationSource(LocationSource.OnLocationChangedListener);
        mMap.getUiSettings().setCompassEnabled(true);

        mMap.getUiSettings().setZoomControlsEnabled(true);
        mMap.getUiSettings().setIndoorLevelPickerEnabled(true);
        mMap.getUiSettings().setMapToolbarEnabled(true);

        createFCListFromJsonFile();

        injectData();

        mapLoaded = true;
    } catch (SecurityException ex) {
        ex.printStackTrace();
    } catch (Exception ex) {

        ex.printStackTrace();

    }

}

From source file:cn.apputest.ctria.section2.Lucha2Activity.java

void SweepCard() {
    IDCService dcservice = new DCService();
    try {//  ww w.  j av a 2 s  .co m
        Set<String> scanresult = dcservice.inventory();
        if (scanresult == null || scanresult.size() == 0) {
            if (hastoast == false) {
                hastoast = true;
                Toast.makeText(context, "??", Toast.LENGTH_SHORT).show();
                mHandler.postDelayed(mRunnable, 2000);
            }
        } else {
            scanSuccess = true;

            Iterator<String> iter = scanresult.iterator();
            String tagCode = "";
            if (iter.hasNext()) {
                tagCode = iter.next();
            }

            Map<String, String> results = dcservice.checkDriver(tagCode);

            //            System.out.println("results:" + results);

            driverlicenseID.setText(results.get("DriverID"));
            qualificationsID.setText(results.get("CertificateCardNo"));
            getdriverCertStatus();
            getjobCertStatus();
        }

    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvalidParamException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.sldeditor.test.unit.tool.vector.VectorToolTest.java

/**
 * Test method for {@link com.sldeditor.tool.vector.VectorTool#supports(java.util.List, java.util.List, java.util.List)}.
 *//*from  w w w  . j  av a  2s .c o  m*/
@Test
public void testSupports() {

    try {
        FileTreeNode vectorTreeNode = new FileTreeNode(new File("/test"), "sld_cookbook_polygon.shp");
        vectorTreeNode.setFileCategory(FileTreeNodeTypeEnum.VECTOR);
        FileTreeNode rasterTreeNode = new FileTreeNode(new File("/test"), "sld_cookbook_polygon.tif");
        rasterTreeNode.setFileCategory(FileTreeNodeTypeEnum.RASTER);
        List<Class<?>> uniqueNodeTypeList = new ArrayList<Class<?>>();
        List<NodeInterface> nodeTypeList = new ArrayList<NodeInterface>();
        List<SLDDataInterface> sldDataList = new ArrayList<SLDDataInterface>();

        // Try vector file
        nodeTypeList.add(vectorTreeNode);
        VectorTool vectorTool = new VectorTool(null);
        assertTrue(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));

        // Try raster file
        nodeTypeList.clear();
        nodeTypeList.add(rasterTreeNode);
        assertFalse(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));

        // Try database feature class
        nodeTypeList.clear();
        DatabaseFeatureClassNode databaseFeatureClassNode = new DatabaseFeatureClassNode(null, null, "db fc");
        nodeTypeList.add(databaseFeatureClassNode);
        assertTrue(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));

        // Try invalid node class
        nodeTypeList.clear();
        nodeTypeList.add(new GeoServerStyleHeadingNode(null, null, "test"));
        assertFalse(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));

        // Try with no nodes
        nodeTypeList.clear();
        assertFalse(vectorTool.supports(uniqueNodeTypeList, nodeTypeList, sldDataList));

        // Try with null
        assertFalse(vectorTool.supports(uniqueNodeTypeList, null, sldDataList));
    } catch (SecurityException e) {
        e.printStackTrace();
        fail();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        fail();
    }

}