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:net.itransformers.topologyviewer.gui.VertexFilterFactory.java

static VertexPredicateFilter<String, String> createVertexFilter(final FilterType filter,
        final Map<String, DataMatcher> matcherMap, final Map<String, GraphMLMetadata<String>> vertexMetadata,
        final Graph<String, String> graph1) {
    return new VertexPredicateFilter<String, String>(new Predicate<String>() {
        public boolean evaluate(String v) {
            if (graph1.getIncidentEdges(v).isEmpty()) {
                return false;
            } else {
                if (filter == null)
                    return true;
                List<IncludeType> includes = filter.getInclude();
                String filterType = filter.getType();

                if (filterType == null) {
                    filterType = "or";
                }// w w  w  .j  a v a  2  s . c  o m
                boolean hasNodeInlcude = false;

                for (IncludeType include : includes) {
                    if (ForType.NODE.equals(include.getFor())) {

                        String matcher = include.getMatcher();
                        if (matcher == null) {
                            matcher = "default";
                        }
                        if (include.getClassType() == null) {

                            final String dataKey = include.getDataKey();
                            //include all nodes
                            if (dataKey == null) {
                                hasNodeInlcude = true;
                                continue;
                            }
                            //the evaluated node dosn't have that dataKey
                            if (vertexMetadata.get(dataKey) == null) {
                                logger.debug("No data is defined in vertex metadata for dataKey=" + dataKey);
                                continue;
                            }
                            //the evaluated node has that dataKey
                            String value = vertexMetadata.get(dataKey).transformer.transform(v);
                            //Evaluate only if the value is not null
                            if (value != null) {
                                //Evaluate multiplicity e.g multiple values for single data key split by commas
                                String[] dataValues = value.split(",");

                                //get the value from the include filter
                                String includeDataValue = include.getDataValue();

                                //Circle around the actual values and perform the datamatch
                                DataMatcher matcherInstance = matcherMap.get(matcher);
                                //If we have an "and" filter
                                if ("and".equals(filterType)) {
                                    for (String dataValue : dataValues) {
                                        // boolean matchResult = ;
                                        hasNodeInlcude = false;
                                        if (matcherInstance.compareData(dataValue, includeDataValue)) {
                                            logger.debug("Node selected: " + v + " by filter "
                                                    + filter.getName() + " with include " + include.getDataKey()
                                                    + " with value " + dataValue);
                                            hasNodeInlcude = true;
                                        }
                                    }

                                    if (!hasNodeInlcude) {
                                        return false;
                                    }
                                    //If we have an "or" filter

                                } else {
                                    for (String dataValue : dataValues) {
                                        if (matcherInstance.compareData(dataValue, includeDataValue)) {
                                            logger.debug("Node " + v + " has been selected from filter "
                                                    + filter.getName() + " by property " + include.getDataKey()
                                                    + " with value " + dataValue);
                                            hasNodeInlcude = true;
                                        } else {
                                            logger.debug("Node" + v + "  has not been selected from filter "
                                                    + filter.getName() + " by property " + include.getDataKey()
                                                    + " with value " + dataValue);

                                        }

                                    }
                                }
                            }
                        } else {
                            //We have totally custom filter from class
                            String type = include.getClassType();
                            Class<?> includeClazz;
                            try {
                                includeClazz = Class.forName(type);
                                VertexIncluder includeInst = (VertexIncluder) includeClazz.newInstance();
                                boolean hasToInlcude = includeInst.hasToInclude(v, vertexMetadata, graph1);

                                if ("and".equals(filterType)) {
                                    if (!hasToInlcude) {
                                        return false;
                                    }
                                } else {

                                    if (hasToInlcude) {
                                        hasNodeInlcude = true;
                                    }
                                }

                            } catch (ClassNotFoundException e) {
                                e.printStackTrace();
                                return false;
                            } catch (InstantiationException e) {
                                e.printStackTrace();
                                return false;
                            } catch (IllegalAccessException e) {
                                e.printStackTrace();
                                return false;
                            }

                        }
                    }
                }
                //Finally if the has to include flag is set include
                if (!hasNodeInlcude) {
                    logger.info("Node " + v + " has not been selected");
                    return false;

                } else {
                    logger.info("Node " + v + " has been selected");

                    return true;
                }
            }
        }
    });
}

From source file:com.ery.ertc.estorm.util.ToolUtil.java

public static Object deserializeObject(String serStr, boolean isGzip, boolean urlEnCode) throws IOException {
    byte[] bts = null;
    if (urlEnCode) {
        bts = org.apache.commons.codec.binary.Base64.decodeBase64(serStr.getBytes("ISO-8859-1"));
    } else {//from  w  w w  .  j av  a  2 s  . c o  m
        bts = serStr.getBytes("ISO-8859-1");
    }
    if (isGzip)
        bts = GZIPUtils.unzip(bts);
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bts);
    ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
    try {
        return objectInputStream.readObject();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        throw new IOException(e);
    } finally {
        objectInputStream.close();
        byteArrayInputStream.close();
    }
}

From source file:com.ricemap.spateDB.core.SpatialSite.java

public static Shape getShape(Configuration conf, String param) {
    String str = conf.get(param);
    String[] parts = str.split(",", 2);
    String shapeClassName = parts[0];
    Shape shape = null;//from   w w  w .ja v  a  2 s . c o  m
    try {
        Class<? extends Shape> shapeClass = Class.forName(shapeClassName).asSubclass(Shape.class);
        shape = shapeClass.newInstance();
        shape.fromText(new Text(parts[1]));
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return shape;
}

From source file:com.app.server.util.ClassLoaderUtil.java

public static boolean cleanupJarFileFactory(CopyOnWriteArrayList setJarFileNames2Close) {
    boolean res = false;
    Class classJarURLConnection = null;
    try {//from w w w .  ja v a  2 s. c  o  m
        classJarURLConnection = Class.forName("sun.net.www.protocol.jar.JarURLConnection");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    if (classJarURLConnection == null) {
        return res;
    }
    Field f = null;
    try {
        f = classJarURLConnection.getDeclaredField("factory");
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
    if (f == null) {
        return res;
    }
    f.setAccessible(true);
    Object obj = null;
    try {
        obj = f.get(null);
    } catch (IllegalAccessException e) {
        // ignore
    }
    if (obj == null) {
        return res;
    }
    Class classJarFileFactory = obj.getClass();
    //
    HashMap fileCache = null;
    try {
        f = classJarFileFactory.getDeclaredField("fileCache");
        f.setAccessible(true);
        obj = f.get(null);
        if (obj instanceof HashMap) {
            fileCache = (HashMap) obj;
        }
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    HashMap urlCache = null;
    try {
        f = classJarFileFactory.getDeclaredField("urlCache");
        f.setAccessible(true);
        obj = f.get(null);
        if (obj instanceof HashMap) {
            urlCache = (HashMap) obj;
        }
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    if (urlCache != null) {
        HashMap urlCacheTmp = (HashMap) urlCache.clone();
        Iterator it = urlCacheTmp.keySet().iterator();
        while (it.hasNext()) {
            obj = it.next();
            if (!(obj instanceof JarFile)) {
                continue;
            }
            JarFile jarFile = (JarFile) obj;
            if (setJarFileNames2Close.contains(jarFile.getName().trim().toUpperCase())) {
                try {
                    jarFile.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (fileCache != null) {
                    fileCache.remove(jarFile);
                }
                urlCache.remove(jarFile);
            }
        }
        res = true;
    } else if (fileCache != null) {
        // urlCache := null
        HashMap fileCacheTmp = (HashMap) fileCache.clone();
        Iterator it = fileCacheTmp.keySet().iterator();
        while (it.hasNext()) {
            Object key = it.next();
            obj = fileCache.get(key);
            if (!(obj instanceof JarFile)) {
                continue;
            }
            JarFile jarFile = (JarFile) obj;

            try {
                jarFile.close();
            } catch (IOException e) {
                // ignore
            }
            fileCache.remove(key);

        }
        res = true;
    }
    setJarFileNames2Close.clear();
    return res;
}

From source file:appStructure.MainApp.java

/**
 * //from w  w w.  ja  v  a 2  s.  c om
 */
private static void setLookAndFeel() {
    try {
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (ClassNotFoundException e) {
        System.err.println(
                "Couldn't find class for specified look and feel:" + "javax.swing.plaf.metal.MetalLookAndFeel");
        System.err.println("Did you include the L&F library in the class path?");
        System.err.println("Using the default look and feel.");
        e.printStackTrace();
    } catch (InstantiationException e) {

        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnsupportedLookAndFeelException e) {
        System.err.println("Can't use the specified look and feel (" + "javax.swing.plaf.metal.MetalLookAndFeel"
                + ") on this platform.");
        System.err.println("Using the default look and feel.");
        e.printStackTrace();
    } catch (Exception e) {
        System.err.println("Couldn't get specified look and feel (" + "javax.swing.plaf.metal.MetalLookAndFeel"
                + "), for some reason.");
        System.err.println("Using the default look and feel.");
        e.printStackTrace();
    }
}

From source file:com.diversityarrays.kdxplore.KDXplore.java

public static void initLAF() {
    // GuiUtil.initLookAndFeel();
    try {/*www .  j  a  v  a 2 s . c om*/

        for (UIManager.LookAndFeelInfo lafi : UIManager.getInstalledLookAndFeels()) {
            System.out.println(lafi.getName() + "\t" + lafi.getClassName()); //$NON-NLS-1$
        }
        System.out.println("-----"); //$NON-NLS-1$

        // String slaf = "javax.swing.plaf.nimbus.NimbusLookAndFeel"; //
        // UIManager.getSystemLookAndFeelClassName();
        // String slaf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
        // // UIManager.getSystemLookAndFeelClassName();
        // String slaf = "javax.swing.plaf.metal.MetalLookAndFeel"; //
        // UIManager.getSystemLookAndFeelClassName();
        String slaf = UIManager.getSystemLookAndFeelClassName();
        UIManager.setLookAndFeel(slaf);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (UnsupportedLookAndFeelException e) {
        e.printStackTrace();
    } finally {

    }
}

From source file:org.apache.airavata.registry.tool.DBMigrator.java

public static void updateDB(String jdbcUrl, String jdbcUser, String jdbcPwd) {
    relativePath = "db-scripts/" + getIncrementedVersion(currentAiravataVersion) + "/";
    InputStream sqlStream = null;
    Scanner in = new Scanner(System.in);
    if (jdbcUrl == null || jdbcUrl.equals("")) {
        System.out.println("Enter JDBC URL : ");
        jdbcUrl = in.next();/*from  ww  w .j a v  a2s  .  c o  m*/
    }
    if (jdbcUser == null || jdbcUser.equals("")) {
        System.out.println("Enter JDBC Username : ");
        jdbcUser = in.next();
    }
    if (jdbcPwd == null || jdbcPwd.equals("")) {
        System.out.println("Enter JDBC password : ");
        jdbcPwd = in.next();
    }

    String dbType = getDBType(jdbcUrl);
    String jdbcDriver = null;

    Connection connection;
    try {
        File file = null;
        if (dbType.contains("derby")) {
            jdbcDriver = "org.apache.derby.jdbc.ClientDriver";
            sqlStream = DBMigrator.class.getClassLoader().getResourceAsStream(relativePath + MIGRATE_SQL_DERBY);
        } else if (dbType.contains("mysql")) {
            jdbcDriver = "com.mysql.jdbc.Driver";
            sqlStream = DBMigrator.class.getClassLoader().getResourceAsStream(relativePath + MIGRATE_SQL_MYSQL);
        }
        Class.forName(jdbcDriver).newInstance();
        connection = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPwd);
        if (canUpdated(connection)) {
            executeSQLScript(connection, sqlStream);
            //update configuration table with airavata version
            updateConfigTable(connection);
        }
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        logger.error("Unable to find SQL scripts...", e);
    } catch (InstantiationException e) {
        e.printStackTrace();
        logger.error("Error while updating the database...", e);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
        logger.error("Error while updating the database...", e);
    } catch (SQLException e) {
        e.printStackTrace();
        logger.error("Error while updating the database...", e);
    } catch (Exception e) {
        e.printStackTrace();
        logger.error("Error while updating the database...", e);
    }
}

From source file:AWTUtilities.java

/**
 * Sets the state of the specified frame, as specified by
 * <code>Frame.setExtendedState</code> if running in JDK 1.4 or later,
 * otherwise does nothing. The call to <code>Frame.setExtendedState()</code>
 * is done via reflection to avoid runtime errors. 
 *///  w  ww . java  2s  . co m

public static void setExtendedFrameState(Frame frame, int state) {
    if (PlatformUtils.isJavaBetterThan("1.4")) {
        try {
            Class frameClass = Class.forName("java.awt.Frame");
            Method setExtendedStateMethod = frameClass.getMethod("setExtendedState", new Class[] { int.class });
            setExtendedStateMethod.invoke(frame, new Object[] { new Integer(state) });
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}

From source file:AWTUtilities.java

/**
 * Returns the state of the specified frame, as specified by
 * <code>Frame.getExtendedState()</code> if running under JDK 1.4 or later,
 * otherwise returns 0. The call to <code>Frame.getExtendedState()</code> is
 * done via reflection to avoid runtime errors.
 *//*from   ww w .ja  va 2  s. c  o  m*/

public static int getExtendedFrameState(Frame frame) {
    if (PlatformUtils.isJavaBetterThan("1.4")) {
        try {
            Class frameClass = Class.forName("java.awt.Frame");
            Method getExtendedStateMethod = frameClass.getMethod("getExtendedState", new Class[0]);
            Integer state = (Integer) getExtendedStateMethod.invoke(frame, new Object[0]);
            return state.intValue();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    return 0;
}

From source file:org.zywx.wbpalmstar.plugin.uexiconlist.utils.IconListUtils.java

public static boolean isMethodExist(String className, String methodName) {
    boolean isExist = false;
    try {/*from   ww w . jav a  2s  .  com*/
        Class<?> mClass = Class.forName(className);
        Method[] methodList = mClass.getMethods();
        for (Method method : methodList) {
            if (methodName.equals(method.getName())) {
                isExist = true;
                break;
            }
        }
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return isExist;
}