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:com.sustainalytics.crawlerfilter.PDFTitleGeneration.java

/**
 * Method to initiate logger//from w  ww . j  av  a2  s .  c  om
 * @param file is a File object. The log file will be placed in this file's folder
 */
public static void initiateLogger(File file) {
    FileHandler fileHandler;
    try {
        // This block configure the logger with handler and formatter
        fileHandler = new FileHandler(file.getParentFile().getAbsolutePath() + "/" + "log.txt", true);
        logger.addHandler(fileHandler);
        SimpleFormatter formatter = new SimpleFormatter();
        fileHandler.setFormatter(formatter);

    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.mh.commons.utils.Reflections.java

/**
 * ?? trim() /*from  w  ww  .  jav  a 2s.  com*/
 * ?? trim();  ??
 * @param obj
 * @param escapeList ??trim()
 * @return
 */
public static Object trim(Object obj, List<String> escapeList) {
    if (obj == null)
        return null;
    try {
        Field[] fields = obj.getClass().getDeclaredFields();
        if (fields != null && fields.length > 0) {
            for (Field field : fields) {
                if (field.getModifiers() < 15 && field.getType().toString().equals("class java.lang.String")) {
                    Object val = FieldUtils.readField(field, obj, true);
                    if (val != null) {
                        if (escapeList != null && escapeList.indexOf(field.getName()) != -1)
                            continue;
                        FieldUtils.writeField(field, obj, val.toString().trim(), true);
                    }
                }
            }
        }
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return obj;
}

From source file:org.opencms.module.TestModuleExcludeResources.java

/**
 * Test suite for this test class.<p>
 *
 * @return the test suite/*from   www  .  j  a  v  a 2s.  com*/
 */
public static Test suite() {

    OpenCmsTestProperties.initialize(org.opencms.test.AllTests.TEST_PROPERTIES_PATH);

    TestSuite suite = new TestSuite();
    suite.setName(TestModuleExcludeResources.class.getName());

    suite.addTest(new TestModuleExcludeResources("testModuleExcludeResourcesRootPath"));
    suite.addTest(new TestModuleExcludeResources("testModuleExcludeResourcesSitePath"));

    TestSetup wrapper = new TestSetup(suite) {

        @Override
        protected void setUp() {

            setupOpenCms("simpletest", "/");
            String path = OpenCms.getSystemInfo().getPackagesRfsPath() + CmsSystemInfo.FOLDER_MODULES;
            File modulesDir = new File(path);

            if (!modulesDir.exists()) {
                System.out.println("creating directory: " + path);

                try {
                    modulesDir.mkdir();
                    System.out.println("created directory " + path);
                } catch (SecurityException se) {
                    System.err.println("unable to create directory " + path);
                    se.printStackTrace();
                }
            }

            // this test causes issues that are written to the error log channel
            OpenCmsTestLogAppender.setBreakOnError(false);
        }

        @Override
        protected void tearDown() {

            String path = OpenCms.getSystemInfo().getPackagesRfsPath() + CmsSystemInfo.FOLDER_MODULES;
            File modulesDir = new File(path);

            if (modulesDir.exists()) {
                System.out.println("removing directory: " + path);

                try {
                    FileUtils.deleteDirectory(modulesDir);
                    System.out.println("created directory " + path);
                } catch (IOException se) {
                    System.err.println("unable to create directory " + path);
                    se.printStackTrace();
                }
            }

            removeOpenCms();

        }
    };

    return wrapper;
}

From source file:com.microsoft.Malmo.Utils.TextureHelper.java

public static void hookIntoRenderPipeline() {
    // Subvert the render manager. This MUST be called at the right time (FMLInitializationEvent).
    // 1: Replace the MC entity renderer with our own:
    Minecraft.getMinecraft().entityRenderer = new MalmoEntityRenderer(Minecraft.getMinecraft(),
            Minecraft.getMinecraft().getResourceManager());
    // 2: Create a new RenderManager:
    RenderManager newRenderManager = new TextureHelper.MalmoRenderManager(Minecraft.getMinecraft().renderEngine,
            Minecraft.getMinecraft().getRenderItem());
    // 3: Use reflection to:
    //      a) replace Minecraft's RenderManager with our new RenderManager
    //      b) point Minecraft's RenderGlobal object to the new RenderManager

    // Are we in the dev environment or deployed?
    boolean devEnv = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
    // We need to know, because the names will either be obfuscated or not.
    String mcRenderManagerName = devEnv ? "renderManager" : "field_175616_W";
    String globalRenderManagerName = devEnv ? "renderManager" : "field_175010_j";
    // NOTE: obfuscated name may need updating if Forge changes - search in
    // ~\.gradle\caches\minecraft\de\oceanlabs\mcp\mcp_snapshot\20161220\1.11.2\srgs\mcp-srg.srg
    Field renderMan;/*  ww w .  j a va  2s  . c o m*/
    Field globalRenderMan;
    try {
        renderMan = Minecraft.class.getDeclaredField(mcRenderManagerName);
        renderMan.setAccessible(true);
        renderMan.set(Minecraft.getMinecraft(), newRenderManager);

        globalRenderMan = RenderGlobal.class.getDeclaredField(globalRenderManagerName);
        globalRenderMan.setAccessible(true);
        globalRenderMan.set(Minecraft.getMinecraft().renderGlobal, newRenderManager);
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
}

From source file:org.sakaiproject.kernel.test.KernelIntegrationBase.java

public static void afterClass(boolean shutdown) {

    if (false) {//from  w w  w  . jav  a 2 s.  c  o m
        try {
            kernelLifecycle.stop();
            KernelManager.clearTestMode();
        } catch (Exception ex) {
            LOG.info("Failed to stop kernel ", ex);
        }
        kernelManager = null;
        kernelLifecycle = null;
        KernelIntegrationBase.enableKernelStartup();
    } else {
        System.err.println("Keeping kernel alive ");
    }
    if (transactionManager != null) {

        try {
            if (transactionManager.getStatus() == Status.STATUS_ACTIVE) {
                LOG.error("Uncommitted Transaction Found at test shutdown");
                transactionManager.commit();
            }
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalStateException 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();
        } catch (SystemException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:com.titilink.camel.rest.util.OtherUtil.java

/**
 * ??//  w ww . j a v  a2s .  c  o m
 *
 * @param filename --??
 * @return long -- 0-????0
 */
public static long getFileLastModified(String filename) {
    long l = 0;
    File f = new File(filename);
    if (f.exists()) {
        try {
            l = f.lastModified();
        } catch (SecurityException se) {
            l = 0;
            se.printStackTrace(); //NOPMD
        }
    }
    return l;
}

From source file:de.unisb.cs.st.javalanche.mutation.util.AddOffutt96Sufficient.java

private static int getOriginalValue(String addInfo) {
    String substring = addInfo.substring("Replace ".length());
    int index = substring.indexOf(' ');
    String s = substring.substring(0, index);
    try {/*from   w  w  w.j  a  v  a  2s .  c  om*/
        Field field = Opcodes.class.getField(s);
        int val = (Integer) field.get(null);
        return val;
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return Integer.parseInt(s);
}

From source file:com.manydesigns.portofino.utils.ReflectUtil.java

/**
 * ?,?DeclaredMethod. ?Object?, null./*from ww w  .  j  av  a  2  s .c o  m*/
 */
protected static Method getDeclaredMethod(Object object, String methodName, Class<?>[] parameterTypes) {
    // Assert.notNull(object, "object?");

    for (Class<?> superClass = object.getClass(); superClass != Object.class; superClass = superClass
            .getSuperclass()) {
        try {
            return superClass.getDeclaredMethod(methodName, parameterTypes);
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return null;
}

From source file:io.github.wysohn.triggerreactor.tools.ReflectionUtil.java

/**
 * https://stackoverflow.com/questions/3301635/change-private-static-final-field-using-java-reflection
 * @param field//  www  . j  a  v  a  2s  . c  o m
 * @param newValue
 * @throws SecurityException
 * @throws NoSuchFieldException
 * @throws Exception
 */
private static void setFinalField(Object target, Field field, Object newValue) throws NoSuchFieldException {
    field.setAccessible(true);

    Field modifiersField = null;
    try {
        modifiersField = Field.class.getDeclaredField("modifiers");
    } catch (SecurityException e1) {
        e1.printStackTrace();
    }

    modifiersField.setAccessible(true);
    try {
        modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
    } catch (IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
    }

    try {
        field.set(target, newValue);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.hihframework.core.utils.ReflectUtil.java

/**
 * ?,?DeclaredMethod./*from  www. ja v a2  s  .  c o  m*/
 * 
 * ?Object?, null.
 */
protected static Method getDeclaredMethod(Object object, String methodName, Class<?>[] parameterTypes) {
    Assert.notNull(object, "object?");

    for (Class<?> superClass = object.getClass(); superClass != Object.class; superClass = superClass
            .getSuperclass()) {
        try {
            return superClass.getDeclaredMethod(methodName, parameterTypes);
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return null;
}