Example usage for java.lang ExceptionInInitializerError getCause

List of usage examples for java.lang ExceptionInInitializerError getCause

Introduction

In this page you can find the example usage for java.lang ExceptionInInitializerError getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:com.kotcrab.vis.editor.Main.java

public static void main(String[] args) throws Exception {
    App.init();/*w  w  w . j  a v  a 2s  .  c  o m*/
    if (OsUtils.isMac())
        System.setProperty("java.awt.headless", "true");

    LaunchConfiguration launchConfig = new LaunchConfiguration();

    //TODO: needs some better parser
    for (int i = 0; i < args.length; i++) {
        String arg = args[i];
        if (arg.equals("--scale-ui")) {
            launchConfig.scaleUIEnabled = true;
            continue;
        }

        if (arg.equals("--project")) {
            if (i + 1 >= args.length) {
                throw new IllegalStateException("Not enough parameters for --project <project path>");
            }

            launchConfig.projectPath = args[i + 1];
            i++;
            continue;
        }

        if (arg.equals("--scene")) {
            if (i + 1 >= args.length) {
                throw new IllegalStateException("Not enough parameters for --scene <scene path>");
            }

            launchConfig.scenePath = args[i + 1];
            i++;
            continue;
        }

        Log.warn("Unrecognized command line argument: " + arg);
    }

    launchConfig.verify();

    editor = new Editor(launchConfig);

    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.setWindowedMode(1280, 720);
    config.setWindowSizeLimits(1, 1, 9999, 9999);
    config.useVsync(true);
    config.setIdleFPS(2);
    config.setWindowListener(new Lwjgl3WindowAdapter() {
        @Override
        public boolean closeRequested() {
            editor.requestExit();
            return false;
        }
    });

    try {
        new Lwjgl3Application(editor, config);
        Log.dispose();
    } catch (Exception e) {
        Log.exception(e);
        Log.fatal("Uncaught exception occurred, error report will be saved");
        Log.flush();

        if (App.eventBus != null)
            App.eventBus.post(new ExceptionEvent(e, true));

        try {
            File crashReport = new CrashReporter(Log.getLogFile().file()).processReport();
            if (new File(App.TOOL_CRASH_REPORTER_PATH).exists() == false) {
                Log.warn("Crash reporting tool not present, skipping crash report sending.");
            } else {
                CommandLine cmdLine = new CommandLine(PlatformUtils.getJavaBinPath());
                cmdLine.addArgument("-jar");
                cmdLine.addArgument(App.TOOL_CRASH_REPORTER_PATH);
                cmdLine.addArgument(ApplicationUtils.getRestartCommand().replace("\"", "%"));
                cmdLine.addArgument(crashReport.getAbsolutePath(), false);
                DefaultExecutor executor = new DefaultExecutor();
                executor.setStreamHandler(new PumpStreamHandler(null, null, null));
                executor.execute(cmdLine);
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        Log.dispose();
        System.exit(-3);
    } catch (ExceptionInInitializerError err) {
        if (OsUtils.isMac() && err.getCause() instanceof IllegalStateException) {
            if (ExceptionUtils.getStackTrace(err).contains("XstartOnFirstThread")) {
                System.out.println(
                        "Application was not launched on first thread. Restarting with -XstartOnFirstThread, add VM argument -XstartOnFirstThread to avoid this.");
                ApplicationUtils.startNewInstance();
            }
        }

        throw err;
    }
}

From source file:org.apache.hawq.pxf.api.utilities.ProfilesConfTest.java

@Test
public void malformedProfileFile() throws Exception {
    writeFile(mandatoryFile, "I'm a malford x.m.l@#$#<%");
    writeFile(optionalFile,//from   www  .j ava 2 s.  co m
            "<profiles><profile><name>HBase</name><plugins><plugin1>Y</plugin1></plugins></profile></profiles>");
    when(classLoader.getResource("pxf-profiles-default.xml")).thenReturn(mandatoryFile.toURI().toURL());
    when(classLoader.getResource("pxf-profiles.xml")).thenReturn(optionalFile.toURI().toURL());
    try {
        ProfilesConf.getProfilePluginsMap("HBase");
        fail("malformed profile file should have thrown exception");
    } catch (ExceptionInInitializerError pce) {
        assertTrue(pce.getCause().getMessage()
                .contains(mandatoryFileName + " could not be loaded: org.xml.sax.SAXParseException"));
    }
}

From source file:org.apache.hawq.pxf.api.utilities.ProfilesConfTest.java

@Test
public void missingMandatoryProfileFile() throws Exception {
    when(classLoader.getResource("pxf-profiles-default.xml")).thenReturn(null);
    try {/*from www  . jav  a2  s .  c  o  m*/
        ProfilesConf.getProfilePluginsMap("HBase");
        fail("missing mandatory profile file should have thrown exception");
    } catch (ExceptionInInitializerError pce) {
        Mockito.verify(LOG).warn("pxf-profiles-default.xml not found in the classpath");
        assertEquals(pce.getCause().getMessage(),
                String.format(PROFILES_FILE_NOT_FOUND.getFormat(), "pxf-profiles-default.xml"));
    }
}

From source file:eu.stratuslab.marketplace.server.MarketPlaceApplication.java

public MarketPlaceApplication() {
    try {/*w  w w.j  av  a2  s.com*/
        String storeType = Configuration.getParameterValue(STORE_TYPE);
        String fileStoreType = Configuration.getParameterValue(FILESTORE_TYPE);
        String dataDir = Configuration.getParameterValue(DATA_DIR);
        init(dataDir, storeType, fileStoreType);
    } catch (ExceptionInInitializerError e) {
        LOGGER.severe("incorrect configuration: " + e.getCause().getMessage());
        invalidConfig = true;
    }
}