Exits with an exception if Classpath not set up properly.
543602
private static void sanityCheck() {
        List<TestContainerFactory> factories = new ArrayList<TestContainerFactory>();

        Iterator<TestContainerFactory> iter = ServiceLoader.load(TestContainerFactory.class)
            .iterator();
        while (iter.hasNext()) {
            factories.add(iter.next());
        }
        if (factories.size() == 0) {
            throw new TestContainerException("No TestContainer implementation in Classpath");
        }
        else if (factories.size() > 1) {
            for (TestContainerFactory fac : factories) {
                LOG.error("Ambiguous TestContainer:  " + fac.getClass().getName());
            }
            throw new TestContainerException("Too many TestContainer implementations in Classpath");
        }
        else {
            // good!
            return;
        }
    }
421872
public void init() throws Exception {
        userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
        System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());

        if (!cfg.exists()) {

            ConfigurationManager manager = new ConfigurationManager(cfg, false, locateConfigurationProvider());

            try {

                manager.runProjectConfigurationInitializers();

                if (options.isVerbose()) {
                    log.info("CONFIGURATION FILE [" + cfg.getAbsolutePath() + "] CREATION COMPLETE");
                }

            } catch (IOException aux) {
                if (options.isVerbose()) {
                    log.error("The system can't create the file [ " + cfg.getAbsolutePath() + "]");
                }
                if (options.isThrowException()) {
                    System.setProperty("user.dir", userDir);
                    throw aux;
                }
            }

        } else {
            if (options.isVerbose()) {
                log.error("The configuration file [" + cfg.getAbsolutePath() + "] already exists");
            }
        }
        System.setProperty("user.dir", userDir);
    }
1054541
public void start() throws Exception {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "start", this);

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            SibTr.debug(tc, "Start ME, mode defaulting to ME_START_DEFAULT");
        start(JsConstants.ME_START_DEFAULT);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "start");
    }
1185353
protected boolean isHostUnavailableException(Throwable throwable, Set<Throwable> path) {
    // Check if the exception is an IOException and check if the
    // message indicates an end of stream on a Connection.
    if ( IOException.class.isInstance(throwable) && throwable.getMessage().contains("unexpected end of stream on") ) {
      return true;
    }
    // we need to check our recursion path to avoid infinite recursion if a
    // getCause() pointed to itself or an ancestor
    if ( throwable.getCause() != null && !path.contains(throwable.getCause()) ) {
      path.add(throwable.getCause());
      boolean isCauseHostUnavailableException = isHostUnavailableException(throwable.getCause(), path);
      if ( isCauseHostUnavailableException == true )
        return true;
    }
    return false;
  }
166348
@Override
  protected void run() throws Exception {
    final ResourceLoader resourceLoader = new MojoResourceLoader(getRuntimeRealm(), getScriptpath());
    final Map<String, Object> context = createContext();
    final Map<String, Object> options = Maps.newHashMap();
    final ConsoleWindow console = getRuntime().createConsoleWindow();

    WindowHandle handle = console.open(getRuntimeRealm(), resourceLoader, context, options);
    handle.await();
  }
140611
@SuppressWarnings("resource")
    @Override
    @Trivial
    public void close() throws ClassSource_Exception {
        String methodName = "close";
        if ( tc.isEntryEnabled() ) {
            Tr.entry(tc, methodName, getHashText());
        }

        JarFile useJarFile = getJarFile();
        if ( (opens < 0) ||
             ((opens == 0) && (useJarFile != null)) ||
             ((opens > 0) && (useJarFile == null)) ) {

            Tr.warning(tc, "ANNO_CLASSSOURCE_JAR_STATE_BAD", getHashText(), getJarPath(), Integer.valueOf(opens));

            opens = 0;
            useJarFile = clearJarFile();
            if ( useJarFile != null ) {
                try {
                    useJarFile.close(); // throws IOException
                } catch ( IOException e ) {
                    // defect 84235:we are generating multiple Warning/Error messages for each error due to each level reporting them.
                    // Disable the following warning and defer message generation to a higher level, 
                    // preferably the ultimate consumer of the exception.
                    //Tr.warning(tc, "ANNO_CLASSSOURCE_CLOSE5_EXCEPTION", getHashText(), getJarPath());

                    String eMsg = "[ " + getHashText() + " ] Failed to close [ " + getJarPath() + " ]";
                    throw getFactory().wrapIntoClassSourceException(CLASS_NAME, methodName, eMsg, e);
                }
            }

            String eMsg = "[ " + getHashText() + " ] Close with open count [ " + opens + " ]";
            throw getFactory().newClassSourceException(eMsg);
        }

        if ( --opens == 0 ) {
            useJarFile = clearJarFile();

            try {
                useJarFile.close(); // throws IOException
            } catch ( IOException e ) {
                // defect 84235:we are generating multiple Warning/Error messages for each error due to each level reporting them.
                // Disable the following warning and defer message generation to a higher level, 
                // preferably the ultimate consumer of the exception.
                //Tr.warning(tc, "ANNO_CLASSSOURCE_CLOSE5_EXCEPTION", getHashText(), getJarPath());

                String eMsg = "[ " + getHashText() + " ] Failed to close [ " + getJarPath() + " ]";
                throw getFactory().wrapIntoClassSourceException(CLASS_NAME, methodName, eMsg, e);
            }
        }

        if ( tc.isEntryEnabled() ) {
            Tr.exit(tc, methodName, getHashText());
        }
    }
11451
private static void handleResourceLoader(final Object resourceLoader, final ClassLoader classLoader,
            final ClasspathOrder classpathOrderOut, final ScanSpec scanSpec, final LogNode log) {
        if (resourceLoader == null) {
            return;
        }
        // PathResourceLoader has root field, which is a Path object
        final Object root = ReflectionUtils.getFieldVal(resourceLoader, "root", false);
        // type VirtualFile
        final File physicalFile = (File) ReflectionUtils.invokeMethod(root, "getPhysicalFile", false);
        String path = null;
        if (physicalFile != null) {
            final String name = (String) ReflectionUtils.invokeMethod(root, "getName", false);
            if (name != null) {
                // getParentFile() removes "contents" directory
                final File file = new File(physicalFile.getParentFile(), name);
                if (FileUtils.canRead(file)) {
                    path = file.getAbsolutePath();
                } else {
                    // This is an exploded jar or classpath directory
                    path = physicalFile.getAbsolutePath();
                }
            } else {
                path = physicalFile.getAbsolutePath();
            }
        } else {
            path = (String) ReflectionUtils.invokeMethod(root, "getPathName", false);
            if (path == null) {
                // Try Path or File
                final File file = root instanceof Path ? ((Path) root).toFile()
                        : root instanceof File ? (File) root : null;
                if (file != null) {
                    path = file.getAbsolutePath();
                }
            }
        }
        if (path == null) {
            final File file = (File) ReflectionUtils.getFieldVal(resourceLoader, "fileOfJar", false);
            if (file != null) {
                path = file.getAbsolutePath();
            }
        }
        if (path != null) {
            classpathOrderOut.addClasspathEntry(path, classLoader, scanSpec, log);
        } else {
            if (log != null) {
                log.log("Could not determine classpath for ResourceLoader: " + resourceLoader);
            }
        }
    }
179611
public void processException(Class sourceClass,
                                 String methodName,
                                 Throwable throwable,
                                 String probe) {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(cclass,
                        "processException",
                        new Object[] { sourceClass,
                                      methodName,
                                      throwable,
                                      probe });
        print(null,
              sourceClass,
              methodName,
              throwable,
              probe,
              null,
              null);

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(cclass,
                       "processException");

    }
406349
protected final void bail(final ExitCode e) {
        if (e.isFailure()) {
            final StringBuilder bldr = new StringBuilder();
            bldr.append("\n");
            bldr.append(getApplicationShortName());
            bldr.append(" failed with error ");
            bldr.append(e);
            bldr.append(".");
            err.println(bldr.toString());
        }

        systemExit(e);
    }
1124487
def add_system_classpath():
    
    if 'CLASSPATH' in os.environ:
        parts = os.environ['CLASSPATH'].split(os.pathsep)
        for part in parts:
            javabridge.JARS.append(part)
1253269
def do_exit(*args):
    '''
        
    '''

    try:
        import java.lang.System

        java.lang.System.exit(1)
    except ImportError:
        if len(args) == 1:
            os._exit(args[0])
        else:
            os._exit(0)
1191728
protected void doStop() throws Exception
    {
        MultiException mex=new MultiException();
        
        
        Thread thread= Thread.currentThread();
        ClassLoader lastContextLoader= thread.getContextClassLoader();
        
        try
        {
            // Context listeners
            if (_contextListeners != null)
            {
                if (_webAppHandler != null)
                {
                    ServletContextEvent event= new ServletContextEvent(getServletContext());
                    
                    for (int i= LazyList.size(_contextListeners); i-- > 0;)
                    {
                        try 
                        {
                            ((ServletContextListener)LazyList.get(_contextListeners, i)).contextDestroyed(event);
                        }
                        catch (Exception e)
                        {
                            mex.add(e);
                        }
                    }
                }
            }
            _contextListeners= null;
            
            // Stop the context
            try
            {
                super.doStop();
            }
            catch (Exception e)
            {
                mex.add(e);
            }
            
            // clean up
            clearSecurityConstraints();
            
            if (_webAppHandler != null)
                removeHandler(_webAppHandler);
            _webAppHandler= null;
            
            if (_errorPages != null)
                _errorPages.clear();
            _errorPages= null;
            
            _webApp=null;
            _webInf=null;
            
            _configurations=null;
            
        }
        finally
        {
            thread.setContextClassLoader(lastContextLoader);
        }
        
        if (mex!=null)
            mex.ifExceptionThrow();
    }
1209358
private void buildClassPath() throws InterruptedException, IOException, CheckedAnalysisException {
        IClassPathBuilder builder = classFactory.createClassPathBuilder(bugReporter);

        {
            HashSet<String> seen = new HashSet<>();
            for (String path : project.getFileArray()) {
                if (seen.add(path)) {
                    builder.addCodeBase(classFactory.createFilesystemCodeBaseLocator(path), true);
                }
            }
            for (String path : project.getAuxClasspathEntryList()) {
                if (seen.add(path)) {
                    builder.addCodeBase(classFactory.createFilesystemCodeBaseLocator(path), false);
                }
            }
        }

        builder.scanNestedArchives(analysisOptions.scanNestedArchives);

        builder.build(classPath, progressReporter);

        appClassList = builder.getAppClassList();

        if (PROGRESS) {
            System.out.println(appClassList.size() + " classes scanned");
        }

        // If any of the application codebases contain source code,
        // add them to the source path.
        // Also, use the last modified time of application codebases
        // to set the project timestamp.
        List<String> pathNames = new ArrayList<>();
        for (Iterator<? extends ICodeBase> i = classPath.appCodeBaseIterator(); i.hasNext();) {
            ICodeBase appCodeBase = i.next();

            if (appCodeBase.containsSourceFiles()) {
                String pathName = appCodeBase.getPathName();
                if (pathName != null) {
                    pathNames.add(pathName);
                }
            }

            project.addTimestamp(appCodeBase.getLastModifiedTime());
        }

        project.addSourceDirs(pathNames);
    }
1117
public void setClasspath(String classpath) {
        this.classpath = new LinkedList<String>();
        StringTokenizer tokenizer = new StringTokenizer(classpath, File.pathSeparator);
        while (tokenizer.hasMoreTokens()) {
            this.classpath.add(tokenizer.nextToken());
        }
    }
1078259
public void finishEnvSetup(boolean transactional) throws Exception {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
            logger.logp(Level.FINE, CLASS_NAME, "finishEnvSetup", "enter");
        }
        // unset the classloader
        UnsynchronizedStack envObjectStack = (UnsynchronizedStack) envObject.get();
        EnvObject env = null;
        if (envObjectStack != null) {
            env = (EnvObject) envObjectStack.pop();
            final ClassLoader origLoader = env.origClassLoader;
            if (origLoader != null) {
                ThreadContextHelper.setClassLoader(origLoader);
            }
            if (envObjectStack.isEmpty()) {
                envObject.remove();
            }
        }

        // namespace postinvoke
        webAppNameSpaceCollab.postInvoke();

        if (transactional && env != null)
            txCollab.postInvoke(null, env.txConfig, this.isServlet23);
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
            logger.logp(Level.FINE, CLASS_NAME, "finishEnvSetup", "exit");
        }
    }
374358
public static String getAbsolutePath(String classPath) {
        URL configUrl = Thread.currentThread().getContextClassLoader().getResource(classPath.substring(1));
        if (configUrl == null) {
            configUrl = ResourceUtil.class.getResource(classPath);
        }
        if (configUrl == null) {
            return null;
        }
        try {
            return configUrl.toURI().getPath();
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }
345185
public static void exit(final int exitCode, final Exception ex) {
        System.err.println(JPService.getApplicationName() + " crashed...");
        ExceptionPrinter.printHistory(ex, System.err);
        System.exit(exitCode);
    }