Example usage for java.lang ClassNotFoundException printStackTrace

List of usage examples for java.lang ClassNotFoundException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.twitter.pig.backend.hadoop.executionengine.tez.TezJobControlCompiler.java

public DAG createDAG(TezOperPlan tezPlan, FileSystem remoteFs, TezConfiguration conf, ApplicationId appId,
        Path remoteStagingDir) throws IOException, YarnException {

    DAG dag = new DAG("MRRSleepJob");
    /*// w w w . ja  v a  2 s.  c  o m
          String jarPath = ClassUtil.findContainingJar(getClass());
          Path remoteJarPath = remoteFs.makeQualified(
    new Path(remoteStagingDir, "dag_job.jar"));
          remoteFs.copyFromLocalFile(new Path(jarPath), remoteJarPath);
          FileStatus jarFileStatus = remoteFs.getFileStatus(remoteJarPath);
    */
    Map<String, LocalResource> commonLocalResources = new HashMap<String, LocalResource>();

    if (!pigContext.inIllustrator && pigContext.getExecType() != ExecType.TEZ_LOCAL) {

        // Setup the DistributedCache for this job
        for (URL extraJar : pigContext.extraJars) {
            //log.debug("Adding jar to DistributedCache: " + extraJar.toString());
            TezJobControlCompiler.putJarOnClassPathThroughDistributedCache(pigContext, conf, extraJar);
        }

        //Create the jar of all functions and classes required
        File submitJarFile = File.createTempFile("Job", ".jar");
        //log.info("creating jar file "+submitJarFile.getName());
        // ensure the job jar is deleted on exit
        submitJarFile.deleteOnExit();
        FileOutputStream fos = new FileOutputStream(submitJarFile);
        try {
            JarManager.createJar(fos, new HashSet<String>(), pigContext);
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        Path remoteJarPath = remoteFs.makeQualified(new Path(remoteStagingDir, "dag_job.jar"));
        remoteFs.copyFromLocalFile(new Path(submitJarFile.getAbsolutePath()), remoteJarPath);
        FileStatus jarFileStatus = remoteFs.getFileStatus(remoteJarPath);

        LocalResource dagJarLocalRsrc = LocalResource.newInstance(
                ConverterUtils.getYarnUrlFromPath(remoteJarPath), LocalResourceType.FILE,
                LocalResourceVisibility.APPLICATION, jarFileStatus.getLen(),
                jarFileStatus.getModificationTime());
        commonLocalResources.put("dag_job.jar", dagJarLocalRsrc);

        Path remoteTezJarPath = remoteFs.makeQualified(new Path(remoteStagingDir, "pig-tez.jar"));
        remoteFs.copyFromLocalFile(new Path("pig-tez.jar"), remoteTezJarPath);
        FileStatus tezJarFileStatus = remoteFs.getFileStatus(remoteTezJarPath);

        LocalResource tezJarLocalRsrc = LocalResource.newInstance(
                ConverterUtils.getYarnUrlFromPath(remoteTezJarPath), LocalResourceType.FILE,
                LocalResourceVisibility.APPLICATION, tezJarFileStatus.getLen(),
                tezJarFileStatus.getModificationTime());
        commonLocalResources.put("pig-tez.jar", tezJarLocalRsrc);

        //log.info("jar file "+submitJarFile.getName()+" created");
        //Start setting the JobConf properties
        conf.set("mapred.jar", submitJarFile.getPath());
    }

    /*
    LocalResource dagJarLocalRsrc = LocalResource.newInstance(
    ConverterUtils.getYarnUrlFromPath(remoteJarPath),
    LocalResourceType.FILE,
    LocalResourceVisibility.APPLICATION,
    jarFileStatus.getLen(),
    jarFileStatus.getModificationTime());
    commonLocalResources.put("dag_job.jar", dagJarLocalRsrc);
    */

    Hashtable<TezOperator, Pair<Vertex, Configuration>> vertexMap = new Hashtable<TezOperator, Pair<Vertex, Configuration>>();

    List<TezOperator> operators = tezPlan.getRoots();

    // add settings for pig statistics
    String setScriptProp = conf.get(ScriptState.INSERT_ENABLED, "true");
    ScriptState ss = null;

    if (setScriptProp.equalsIgnoreCase("true")) {
        ss = ScriptState.get();
    }

    while (operators != null && operators.size() != 0) {

        List<TezOperator> successors = new ArrayList<TezOperator>();

        for (TezOperator oper : operators) {

            Configuration operConf = oper.configure(pigContext, conf);
            /*
            if (ss != null){
               ss.addSettingsToConf(oper, conf);
            }
            */
            List<TezOperator> predecessors = plan.getPredecessors(oper);

            if (predecessors != null && predecessors.size() != 0) {
                MultiStageMRConfToTezTranslator.translateVertexConfToTez(operConf,
                        vertexMap.get(predecessors.get(0)).second);
            } else {
                MultiStageMRConfToTezTranslator.translateVertexConfToTez(operConf, null);
            }

            List<TezOperator> operSuccessors = tezPlan.getSuccessors(oper);
            if (operSuccessors != null) {
                successors.addAll(operSuccessors);
            }

            MRHelpers.doJobClientMagic(operConf);

            //mapStageConf.setInt(MRJobConfig.NUM_MAPS, numMapper);

            Vertex operVertex = new Vertex(oper.name(),
                    new ProcessorDescriptor(oper.getProcessor(), MRHelpers.createUserPayloadFromConf(operConf)),
                    oper.getParallelism(), MRHelpers.getMapResource(operConf));

            oper.configureVertex(operVertex, operConf, commonLocalResources, remoteStagingDir);

            dag.addVertex(operVertex);
            if (predecessors != null) {

                for (TezOperator predecessor : predecessors) {
                    dag.addEdge(new Edge(vertexMap.get(predecessor).first, operVertex,
                            tezPlan.getEdgeProperty(predecessor, oper)));
                }

            }

            vertexMap.put(oper, new Pair<Vertex, Configuration>(operVertex, operConf));
        }

        operators = successors;
    }
    return dag;
}

From source file:hu.sztaki.lpds.pgportal.portlets.workflow.EasyWorkflowPortlet.java

@Override
public void serveResource(ResourceRequest request, ResourceResponse response)
        throws PortletException, IOException {
    String key;//w  w  w  . j a v a 2  s.c om
    if ("editgraphURL".equals(request.getResourceID()) && request.getParameter("wfId") != null) {
        GraphEditorUtil.jnpl(request, response);
        return;
    }

    if ("refreshConfigURL".equals(request.getResourceID())) {
        List<String> graphs = new ArrayList<String>();
        Enumeration<String> enm = PortalCacheService.getInstance().getUser(request.getRemoteUser())
                .getAbstactWorkflows().keys();
        while (enm.hasMoreElements())
            graphs.add(enm.nextElement());

        request.setAttribute("graphs", graphs);
        request.setAttribute("workflow", request.getPortletSession().getAttribute("cworkflow"));
        getPortletContext().getRequestDispatcher("/jsp/workflow/accepteditedgraph.jsp").include(request,
                response);
        return;
    }

    // ajax help
    if (request.getParameter("helptext") != null) {
        super.serveResource(request, response);
        return;
    }
    //output download
    if (request.getParameter("downloadType") != null) {
        response.setContentType("application/zip");
        response.setProperty("Content-Disposition", "inline; filename=\"" + request.getParameter("workflowID")
                + "_" + request.getParameter("jobID") + "_" + request.getParameter("pidID") + "_outputs.zip\"");
        try {
            HttpDownload.fileDownload(request.getParameter("downloadType"), request, response);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PortletException("com error");
        }
        return;
    }
    // logs download
    if (request.getParameter("fileID") != null) {
        response.setContentType("application/text");
        response.setProperty("Content-Disposition",
                "inline; filename=\"" + request.getParameter("workflowID") + "_" + request.getParameter("jobID")
                        + "_" + request.getParameter("pidID") + "_" + request.getParameter("fileID")
                        + ".txt\"");
        try {
            HttpDownload.fileView(request, response);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PortletException("com error");
        }
        return;
    }

    // file upload status
    if (request.getParameter("uploadStatus") != null) {
        PortletSession ps = request.getPortletSession();
        // end of download
        if (ps.getAttribute("finaluploads") != null) {
            ps.removeAttribute("finaluploads");
            ps.removeAttribute("uploaded");
            ps.removeAttribute("upload");
            ps.removeAttribute("uploading");
            response.getWriter().write("Upload");

        } else {
            try {
                Vector<String> tmp = (Vector<String>) ps.getAttribute("uploaded");
                response.getWriter().write("&nbsp;<br/>");
                for (String t : tmp)
                    response.getWriter().write("uploaded:" + t + "<br/>");
                FileUploadProgressListener lisener = (FileUploadProgressListener) ((PortletFileUpload) ps
                        .getAttribute("upload")).getProgressListener();
                byte uplStatus = Byte.parseByte(lisener.getFileuploadstatus());
                response.getWriter()
                        .write("uploading:" + ps.getAttribute("uploading") + "->" + "<div style=\"width:"
                                + uplStatus + "px;background-color:blue; \" >" + uplStatus + "%<br/>");
            } catch (Exception ee) {
                System.out.println("file upload has not yet begun " + ps.getId());
                ee.printStackTrace();
            }
        }
        return;
    }
    // configuration
    Hashtable reqhash = new Hashtable();
    Enumeration enm0 = request.getParameterNames();
    while (enm0.hasMoreElements()) {
        key = "" + enm0.nextElement();
        reqhash.put(key, request.getParameter(key));
    }
    reqhash.put("sid", request.getPortletSession().getId());
    try {
        ActionHandler t = null;
        try {
            String sid = request.getPortletSession().getId();
            String workflowName = "" + request.getPortletSession().getAttribute("cworkflow");
            String username = request.getRemoteUser();
            String wftype = PortalCacheService.getInstance().getUser(username).getWorkflow(workflowName)
                    .getWorkflowType();
            reqhash.put("ws-pgrade.wftype", wftype);
            t = (ActionHandler) Class.forName(
                    "hu.sztaki.lpds.pgportal.servlet.ajaxactions." + wftype + "." + request.getParameter("m"))
                    .newInstance();
            //                System.out.println("***SERVE-RESOURCE:"+t.getClass().getName());

        } catch (Exception e) {
            try {
                t = (ActionHandler) Class
                        .forName("hu.sztaki.lpds.pgportal.servlet.ajaxactions." + request.getParameter("m"))
                        .newInstance();
                //                    System.out.println("***SERVE-RESOURCE:"+t.getClass().getName());
            } catch (ClassNotFoundException e0) {
                System.out.println("classnotfound");
                e0.printStackTrace();
            } catch (InstantiationException e0) {
                e0.printStackTrace();
                System.out.println("---Init error:hu.sztaki.lpds.pgportal.servlet.ajaxactions."
                        + request.getParameter("m"));
                e0.printStackTrace();
            } catch (IllegalAccessException e0) {
                e0.printStackTrace();
                System.out.println("---Illegal Access:hu.sztaki.lpds.pgportal.servlet.ajaxactions."
                        + request.getParameter("m"));
                e0.printStackTrace();
            }
        }
        try {
            // Session transfer
            t.setSessionVariables(request.getPortletSession());
            // Parameter setting
            reqhash.put("user", request.getRemoteUser());
            if (request.getPortletSession().getAttribute("cworkflow") != null)
                reqhash.put("workflow", request.getPortletSession().getAttribute("cworkflow"));
            if (request.getPortletSession().getAttribute("detailsruntime") != null)
                reqhash.put("detailsruntime", request.getPortletSession().getAttribute("detailsruntime"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        // Content transfer
        if (t.getDispacher(reqhash) == null) {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            try {
                out.print(t.getOutput(reqhash));
            } catch (Exception e) {
                e.printStackTrace();
            }
            out.close();
        }
        // Transfer of controlling
        else {
            Hashtable res = t.getParameters(reqhash);
            Enumeration enm = res.keys();
            while (enm.hasMoreElements()) {
                key = "" + enm.nextElement();
                request.setAttribute(key, res.get(key));
            }
            PortletRequestDispatcher dispatcher = getPortletContext()
                    .getRequestDispatcher(t.getDispacher(reqhash));
            dispatcher.include(request, response);
        }
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("-----------------------Can not be initialized:" + request.getParameter("m"));
    }

}

From source file:org.ireland.jnetty.webapp.WebApp.java

/**
 * //from   ww  w .j a  v  a  2  s.  co  m
 * Filter
 * 
 * @param filterName
 * @param className
 * @param filterClass
 * @param filter
 * @return
 */
private FilterRegistration.Dynamic addFilter(String filterName, String className,
        Class<? extends Filter> filterClass, Filter filter) {

    try {
        FilterConfigImpl config = createNewFilterConfig();

        config.setFilterName(filterName);
        config.setFilterClass(className);

        if (filterClass != null)
            config.setFilterClass(filterClass);

        if (filter != null)
            config.setFilter(filter);

        addFilter(config);

        return config;
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        // spec declares no throws so far.
        throw new RuntimeException(e.getMessage(), e);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:RutherfordScattering.RutherfordScattering.java

/**
 * Initializes the applet RutherfordScattering
 */// w w w . j a v  a2s  .c  o  m
@Override
public void init() {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(RutherfordScattering.class.getName())
                .log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(RutherfordScattering.class.getName())
                .log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(RutherfordScattering.class.getName())
                .log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(RutherfordScattering.class.getName())
                .log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the applet */
    try {
        java.awt.EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                initComponents();
                chart = new JFreeChart(new XYPlot());
            }
        });
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:edu.ku.brc.specify.tools.datamodelgenerator.DatamodelGenerator.java

@SuppressWarnings("unchecked")
public Class<?> getSetsClassType(final Class<?> cls, final String methodName) {
    try {//  w  w w.  j a va2 s  .co m
        File f = new File(srcCodeDir.getAbsoluteFile() + File.separator + cls.getSimpleName() + ".java");
        if (!f.exists()) {
            log.error("Can't locate source file[" + f.getAbsolutePath() + "]");
            return null;
        }

        List<String> lines = FileUtils.readLines(f);
        for (String line : lines) {
            int sInx = line.indexOf("Set<");
            if (sInx > -1 && line.indexOf(methodName) > -1) {
                int eInx = line.indexOf(">", sInx);
                String className = line.substring(sInx + 4, eInx);
                return Class.forName(packageName + "." + className);
            }
        }

    } catch (ClassNotFoundException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DatamodelGenerator.class, ex);

    } catch (IOException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DatamodelGenerator.class, ex);
        ex.printStackTrace();
    }
    return null;
}

From source file:com.flexive.core.storage.H2.H2StorageFactory.java

/**
 * {@inheritDoc}// w  w  w .  j av a  2  s  .c o m
 */
@Override
public Connection getConnection(String database, String schema, String jdbcURL, String jdbcURLParameters,
        String user, String password, boolean createDB, boolean createSchema, boolean dropDBIfExist)
        throws Exception {
    Connection con;
    try {
        if (StringUtils.isBlank(database))
            throw new IllegalArgumentException("No database name (path) specified!");
        if (StringUtils.isBlank(schema))
            throw new IllegalArgumentException("No database schema specified!");
        String url = jdbcURL + database;
        if (!StringUtils.isBlank(jdbcURLParameters))
            url = url + jdbcURLParameters.trim();
        schema = schema.trim();
        System.out.println("Using schema [" + schema + "], database [" + database + "] for " + VENDOR);

        if (StringUtils.isBlank(url))
            throw new IllegalArgumentException("No JDBC URL provided!");
        url = url.trim();

        try {
            Class.forName("org.h2.Driver").newInstance();
        } catch (ClassNotFoundException e) {
            System.err.println("H2 JDBC Driver not found in classpath!");
            return null;
        }
        if (dropDBIfExist) {
            Method m = Class.forName("org.h2.tools.DeleteDbFiles").getMethod("execute", String.class,
                    String.class, boolean.class);
            String path;
            String db;
            if (database.lastIndexOf('/') != -1) {
                path = database.substring(0, database.lastIndexOf('/'));
                db = database.substring(database.lastIndexOf('/') + 1);
            } else if (database.lastIndexOf('\\') != -1) {
                path = database.substring(0, database.lastIndexOf('\\'));
                db = database.substring(database.lastIndexOf('\\') + 1);
            } else {
                System.err.println("Could not extract path and database name from [" + database + "]");
                return null;
            }
            System.out.println("Dropping Database ... Path: [" + path + "], DB: [" + db + "]");
            m.invoke(null, path, db, false);
        }
        System.out.println("Connecting using JDBC URL " + url);
        con = DriverManager.getConnection(url, user, password);
    } catch (SQLException e) {
        e.printStackTrace();
        return null;
    }
    return con;
}

From source file:io.swagger.inflector.SwaggerOperationController.java

public Method detectMethod(Operation operation) {
    String controller = getControllerName(operation);
    String methodName = getMethodName(path, httpMethod, operation);

    if (controller != null && methodName != null) {
        try {//from w w w  .  j a  v a  2s. co m
            Class<?> cls;
            try {
                cls = Class.forName(controller);
            } catch (ClassNotFoundException e) {
                controller = controller + "Controller";
                cls = Class.forName(controller);
            }

            JavaType[] args = getOperationParameterClasses(operation, this.definitions);
            Method[] methods = cls.getMethods();
            for (Method method : methods) {
                if (methodName.equals(method.getName())) {
                    Class<?>[] methodArgs = method.getParameterTypes();
                    if (methodArgs.length == args.length) {
                        int i = 0;
                        boolean matched = true;
                        if (!args[i].getRawClass().equals(methodArgs[i])) {
                            LOGGER.debug("failed to match " + args[i] + ", " + methodArgs[i]);
                            matched = false;
                        }
                        if (matched) {
                            this.parameterClasses = args;
                            this.controller = cls.newInstance();
                            LOGGER.debug("matched " + method);
                            return method;
                        }
                    }
                }
            }

            LOGGER.debug("no match in " + controller);
        } catch (ClassNotFoundException e) {
            LOGGER.debug("didn't find class " + controller);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
    }
    return null;
}

From source file:es.ubu.XRayDetector.interfaz.PanelAplicacion.java

/**
 * Initialize the contents of the frame.
 *///from  ww w. j ava  2 s.co m
private void initialize() {

    try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (ClassNotFoundException e) {
        MyLogHandler.writeException(e);
        e.printStackTrace();
    } catch (InstantiationException e) {
        MyLogHandler.writeException(e);
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        MyLogHandler.writeException(e);
        e.printStackTrace();
    } catch (UnsupportedLookAndFeelException e) {
        MyLogHandler.writeException(e);
        e.printStackTrace();
    }

    getJFramePrincipal();

    JPanel panelControl = getPanelControl();

    getBtnAbrirImagen(panelControl);

    getBtnEntrenar(panelControl);

    getBtnAnalizar(panelControl);

    JPanel panelProgreso = getPanelProgreso();

    getProgressBar(panelProgreso);

    getBtnStop(panelProgreso);

    JPanel panelImagen = getPanelImagen();

    getImgPanel(panelImagen);

    JPanel panelLog = getPanelLog();

    txtLog = getTxtLog(panelLog);

    getBotonExportarLog();
    getBotonLimpiarLog();

    JPanel panelSlider = getPanelSlider();

    getSlider(panelSlider);

    getPanelTabla();

    getTablaResultados(panelTabla_1);
    imgPanel.setFocusable(true);

    JPanel panelAnalizarResultados = getPanelAnalizarResultados();

    getButtonGuardarImagenAnalizada(panelAnalizarResultados);

    getButtonGuardarImagenBinarizada(panelAnalizarResultados);

    getButtonPrecisionRecall(panelAnalizarResultados);

    selectionCopy = new Rectangle();

    try {
        File fichero = new File("./res/ayuda/ayuda.hs");
        URL hsURL = fichero.toURI().toURL();
        HelpSet hs = new HelpSet(null, hsURL);
        HelpBroker hb = hs.createHelpBroker();
        hb.enableHelpKey(frmXraydetector.getContentPane(), "ventanaentrenamientodeteccion", hs);
    } catch (MalformedURLException e) {
        MyLogHandler.writeException(e);
        e.printStackTrace();
    } catch (HelpSetException e) {
        MyLogHandler.writeException(e);
        e.printStackTrace();
    }

}

From source file:com.osbitools.ws.shared.prj.web.AbstractWsPrjInit.java

@Override
public void contextInitialized(ServletContextEvent evt) {
    super.contextInitialized(evt);
    ServletContext ctx = evt.getServletContext();

    // First - Load Custom Error List 
    try {/*w ww . j a  v a 2 s  .co  m*/
        Class.forName("com.osbitools.ws.shared.prj.CustErrorList");
    } catch (ClassNotFoundException e) {
        // Ignore Error 
    }

    // Initialize Entity Utils
    IEntityUtils eut = getEntityUtils();
    ctx.setAttribute("entity_utils", eut);

    // Initiate LangSetFileUtils
    ctx.setAttribute("ll_set_utils", new LangSetUtils());

    // Check if git repository exists and create one
    // Using ds subdirectory as git root repository 
    File drepo = new File(
            getConfigDir(ctx) + File.separator + eut.getPrjRootDirName() + File.separator + ".git");
    Git git;
    try {

        if (!drepo.exists()) {
            if (!drepo.mkdirs())
                throw new RuntimeErrorException(
                        new Error("Unable create directory '" + drepo.getAbsolutePath() + "'"));

            try {
                git = createGitRepo(drepo);
            } catch (Exception e) {
                throw new RuntimeErrorException(new Error(
                        "Unable create new repo on path: " + drepo.getAbsolutePath() + ". " + e.getMessage()));
            }

            getLogger(ctx).info("Created new git repository '" + drepo.getAbsolutePath() + "'");
        } else if (!drepo.isDirectory()) {
            throw new RuntimeErrorException(
                    new Error(drepo.getAbsolutePath() + " is regular file and not a directory"));
        } else {
            git = Git.open(drepo);
            getLogger(ctx).debug("Open existing repository " + drepo.getAbsolutePath());
        }
    } catch (IOException e) {
        // Something unexpected and needs to be analyzed
        e.printStackTrace();

        throw new RuntimeErrorException(new Error(e));
    }

    // Save git handler
    ctx.setAttribute("git", git);

    // Check if remote destination set/changed
    StoredConfig config = git.getRepository().getConfig();
    String rname = (String) ctx.getAttribute(PrjMgrConstants.PREMOTE_GIT_NAME);
    String rurl = (String) ctx.getAttribute("git_remote_url");

    if (!Utils.isEmpty(rname) && !Utils.isEmpty(rurl)) {
        String url = config.getString("remote", rname, "url");
        if (!rurl.equals(url)) {
            config.setString("remote", rname, "url", rurl);
            try {
                config.save();
            } catch (IOException e) {
                getLogger(ctx).error("Error saving git remote url. " + e.getMessage());
            }
        }
    }

    // Temp directory for files upload
    String tname = System.getProperty("java.io.tmpdir");
    getLogger(ctx).info("Using temporarily directory '" + tname + "' for file uploads");
    File tdir = new File(tname);

    if (!tdir.exists())
        throw new RuntimeErrorException(
                new Error("Temporarily directory for file upload '" + tname + "' is not found"));
    if (!tdir.isDirectory())
        throw new RuntimeErrorException(
                new Error("Temporarily directory for file upload '" + tname + "' is not a directory"));

    DiskFileItemFactory dfi = new DiskFileItemFactory();
    dfi.setSizeThreshold(
            ((Integer) ctx.getAttribute(PrjMgrConstants.SMAX_FILE_UPLOAD_SIZE_NAME)) * 1024 * 1024);
    dfi.setRepository(tdir);
    evt.getServletContext().setAttribute("dfi", dfi);

    // Save entity utils in context
    evt.getServletContext().setAttribute("entity_utils", getEntityUtils());
}

From source file:corelyzer.ui.CorelyzerGLCanvas.java

private void handleClastMouseReleased(final MouseEvent e) {
    if (selectedTrackSection != -1) {
        Point releasePos = e.getPoint();
        float[] releaseScenePos = { 0.0f, 0.0f };
        float[] releaseAbsPos = { 0.0f, 0.0f };

        convertMousePointToSceneSpace(releasePos, releaseScenePos);

        if (!SceneGraph.getDepthOrientation()) {
            float t = scenePos[0];
            scenePos[0] = scenePos[1];//w  w w .  j  a  v a2 s  .  c  o m
            scenePos[1] = -t;
        }

        SceneGraph.addClastPoint2(scenePos[0], scenePos[1]);

        convertScenePointToAbsolute(scenePos, releaseAbsPos);
        CorelyzerApp.getApp().getToolFrame().setClastLowerRight(releaseAbsPos);
        float[] clastUpperLeft = CorelyzerApp.getApp().getToolFrame().getClastUpperLeft();

        String trackname = CorelyzerApp.getApp().getTrackListModel().getElementAt(selectedTrackIndex)
                .toString();
        String secname = CorelyzerApp.getApp().getSectionListModel().getElementAt(selectedTrackSectionIndex)
                .toString();
        String sessionname = CoreGraph.getInstance().getCurrentSession().getName();

        // Different kinds of annotations
        AnnotationTypeDirectory dir = AnnotationTypeDirectory.getLocalAnnotationTypeDirectory();
        if (dir == null) {
            System.out.println("Null AnnotationTypeDirectory abort.");
            return;
        }

        Enumeration<String> keys = dir.keys();
        Vector<String> annotationOptions = new Vector<String>();
        annotationOptions.add("Cancel");

        while (keys.hasMoreElements()) {
            annotationOptions.add(keys.nextElement());
        }

        Object[] options = annotationOptions.toArray();

        int sel = JOptionPane.showOptionDialog(getPopupParent(), "Which kind of Annotation?",
                "Annotation Form Selector", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                options, options[0]);

        if (sel < 0) {
            return;
        }

        try {
            this.handleAnnotationEvent(options[sel].toString(), sessionname, trackname, secname, clastUpperLeft,
                    releaseAbsPos);
        } catch (ClassNotFoundException e1) {
            e1.printStackTrace();
        } catch (IllegalAccessException e1) {
            e1.printStackTrace();
        } catch (InstantiationException e1) {
            e1.printStackTrace();
        }
    }
}