List of usage examples for java.lang ClassNotFoundException printStackTrace
public void printStackTrace()
From source file:lu.fisch.moenagade.model.Project.java
public void jar() { try {/*from w w w. j a v a2s . c o m*/ // compile all if (!save()) return; generateSource(true); if (compile()) { // adjust the dirname String bdir = getDirectoryName(); if (!bdir.endsWith(System.getProperty("file.separator"))) { bdir += System.getProperty("file.separator"); } // adjust the filename String bname = getDirectoryName(); if (bname.endsWith(System.getProperty("file.separator"))) { bname = bname.substring(0, bname.length() - 1); } bname = bname.substring(bname.lastIndexOf(System.getProperty("file.separator")) + 1); // default class to launch String mc = "moenagade.Project"; // target JVM String target = "1.8"; /* String[] targets = new String[]{"1.1","1.2","1.3","1.5","1.6"}; if(System.getProperty("java.version").startsWith("1.7")) targets = new String[]{"1.1","1.2","1.3","1.5","1.6","1.7"}; if(System.getProperty("java.version").startsWith("1.8")) targets = new String[]{"1.1","1.2","1.3","1.5","1.6","1.7","1.8"}; target= (String) JOptionPane.showInputDialog( frame, "Please enter version of the JVM you want to target.", "Target JVM", JOptionPane.QUESTION_MESSAGE, Moenagade.IMG_QUESTION, targets, "1.6");*/ File fDir = new File(directoryName + System.getProperty("file.separator") + "bin"); if (!fDir.exists()) fDir.mkdir(); // get all the files content Hashtable<String, String> codes = new Hashtable<>(); String srcdir = directoryName + System.getProperty("file.separator") + "src"; Collection files = FileUtils.listFiles(new File(srcdir), new String[] { "java" }, true); File[] javas = new File[files.size()]; int i = 0; for (Iterator iterator = files.iterator(); iterator.hasNext();) { File file = (File) iterator.next(); javas[i++] = file; } try { // make class files Runtime6.getInstance().compileToPath(javas, fDir.getAbsolutePath(), target, ""); StringList manifest = new StringList(); manifest.add("Manifest-Version: 1.0"); manifest.add("Created-By: " + Moenagade.E_VERSION + " " + Moenagade.E_VERSION); manifest.add("Name: " + bname); if (mc != null) { manifest.add("Main-Class: " + mc); } // compose the filename fDir = new File(bdir + "dist" + System.getProperty("file.separator")); fDir.mkdir(); bname = bdir + "dist" + System.getProperty("file.separator") + bname + ".jar"; String baseName = bdir; String libFolderName = bdir + "lib"; String distLibFolderName = bdir + "dist" + System.getProperty("file.separator") + "lib"; File outFile = new File(bname); FileOutputStream bo = new FileOutputStream(bname); JarOutputStream jo = new JarOutputStream(bo); String dirname = getDirectoryName(); if (!dirname.endsWith(System.getProperty("file.separator"))) { dirname += System.getProperty("file.separator"); } // add the files to the array addToJar(jo, "", new File(dirname + "bin" + System.getProperty("file.separator"))); // add the files to the array addToJar(jo, "", new File(dirname + "src" + System.getProperty("file.separator")), new String[] { "java" }); //manifest.add("Class-Path: "+cp+" "+cpsw); // adding the manifest file manifest.add(""); JarEntry je = new JarEntry("META-INF/MANIFEST.MF"); jo.putNextEntry(je); String mf = manifest.getText(); jo.write(mf.getBytes(), 0, mf.getBytes().length); jo.close(); bo.close(); // delete bin directory deleteDirectory(new File(getDirectoryName() + System.getProperty("file.separator") + "bin" + System.getProperty("file.separator"))); // generate java code with dispose_on_exit generateSource(); JOptionPane.showMessageDialog(frame, "The JAR-archive has been generated and can\nbe found in the \"dist\" directory.", "Success", JOptionPane.INFORMATION_MESSAGE, Moenagade.IMG_INFO); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } } } /*catch (ClassNotFoundException ex) { JOptionPane.showMessageDialog(frame, "There was an error while creating the JAR-archive ...", "Error :: ClassNotFoundException", JOptionPane.ERROR_MESSAGE,Unimozer.IMG_ERROR); }*/ catch (IOException ex) { JOptionPane.showMessageDialog(frame, "There was an error while creating the JAR-archive ...", "Error :: IOException", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); ex.printStackTrace(); } }
From source file:YoungDoubleSlit.YoungDoubleSlit.java
/** * Initializes the applet YoungDoubleSlit *///from w ww .j a va 2 s . co 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(YoungDoubleSlit.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(YoungDoubleSlit.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(YoungDoubleSlit.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(YoungDoubleSlit.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> wavelength = 300; slit_width = 0; slit_distance = 0; bin_size = 501; single_mode = true; /* Create and display the applet */ try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { initComponents(); isTimerOn = false; timer = null; } }); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:org.alfresco.rad.test.AlfrescoTestRunner.java
/** * Call a remote Alfresco server and have the test run there. * * @param method the test method to run * @param notifier/*from ww w.j a v a2s .co m*/ * @param desc */ protected void callProxiedChild(FrameworkMethod method, RunNotifier notifier, Description desc) { notifier.fireTestStarted(desc); String className = method.getMethod().getDeclaringClass().getCanonicalName(); String methodName = method.getName(); if (null != methodName) { className += "#" + methodName; } // Login credentials for Alfresco Repo // TODO: Maybe configure credentials in props... CredentialsProvider provider = new BasicCredentialsProvider(); UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("admin", "admin"); provider.setCredentials(AuthScope.ANY, credentials); // Create HTTP Client with credentials CloseableHttpClient httpclient = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build(); // Create the GET Request for the Web Script that will run the test String testWebScriptUrl = "/service/testing/test.xml?clazz=" + className.replace("#", "%23"); //System.out.println("AlfrescoTestRunner: Invoking Web Script for test execution: " + testWebScriptUrl); HttpGet get = new HttpGet(getContextRoot(method) + testWebScriptUrl); try { // Send proxied request and read response HttpResponse resp = httpclient.execute(get); InputStream is = resp.getEntity().getContent(); InputStreamReader ir = new InputStreamReader(is); BufferedReader br = new BufferedReader(ir); String body = ""; String line; while ((line = br.readLine()) != null) { body += line + "\n"; } // Process response if (body.length() > 0) { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = null; dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(new InputSource(new StringReader(body))); Element root = doc.getDocumentElement(); NodeList results = root.getElementsByTagName("result"); if (null != results && results.getLength() > 0) { String result = results.item(0).getFirstChild().getNodeValue(); if (SUCCESS.equals(result)) { notifier.fireTestFinished(desc); } else { boolean failureFired = false; NodeList throwableNodes = root.getElementsByTagName("throwable"); for (int tid = 0; tid < throwableNodes.getLength(); tid++) { String throwableBody = null; Object object = null; Throwable throwable = null; throwableBody = throwableNodes.item(tid).getFirstChild().getNodeValue(); if (null != throwableBody) { try { object = objectFromString(throwableBody); } catch (ClassNotFoundException e) { } if (null != object && object instanceof Throwable) { throwable = (Throwable) object; } } if (null == throwable) { throwable = new Throwable("Unable to process exception body: " + throwableBody); } notifier.fireTestFailure(new Failure(desc, throwable)); failureFired = true; } if (!failureFired) { notifier.fireTestFailure(new Failure(desc, new Throwable( "There was an error but we can't figure out what it was, sorry!"))); } } } else { notifier.fireTestFailure(new Failure(desc, new Throwable("Unable to process response for proxied test request: " + body))); } } else { notifier.fireTestFailure(new Failure(desc, new Throwable( "Attempt to proxy test into running Alfresco instance failed, no response received"))); } } catch (IOException e) { notifier.fireTestFailure(new Failure(desc, e)); } catch (ParserConfigurationException e) { notifier.fireTestFailure(new Failure(desc, e)); } catch (SAXException e) { notifier.fireTestFailure(new Failure(desc, e)); } finally { try { httpclient.close(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:de.tudresden.inf.rn.mobilis.mxa.XMPPRemoteService.java
/** * WORKAROUND for Android only! The necessary configuration files for Smack * library are not included in Android's apk-Package. * /*from w ww . j a v a 2 s. c om*/ * @param pm * A ProviderManager instance. */ private void configureProviderManager(ProviderManager pm) { // Private Data Storage pm.addIQProvider("query", "jabber:iq:private", new PrivateDataManager.PrivateDataIQProvider()); // Time try { pm.addIQProvider("query", "jabber:iq:time", Class.forName("org.jivesoftware.smackx.packet.Time")); } catch (ClassNotFoundException e) { e.printStackTrace(); } // Roster Exchange pm.addExtensionProvider("x", "jabber:x:roster", new RosterExchangeProvider()); // Message Events pm.addExtensionProvider("x", "jabber:x:event", new MessageEventProvider()); // Chat State pm.addExtensionProvider("active", "http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider()); pm.addExtensionProvider("composing", "http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider()); pm.addExtensionProvider("paused", "http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider()); pm.addExtensionProvider("inactive", "http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider()); pm.addExtensionProvider("gone", "http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider()); // XHTML pm.addExtensionProvider("html", "http://jabber.org/protocol/xhtml-im", new XHTMLExtensionProvider()); // Group Chat Invitations pm.addExtensionProvider("x", "jabber:x:conference", new GroupChatInvitation.Provider()); // Service Discovery # Items pm.addIQProvider("query", "http://jabber.org/protocol/disco#items", new DiscoverItemsProvider()); // Service Discovery # Info pm.addIQProvider("query", "http://jabber.org/protocol/disco#info", new DiscoverInfoProvider()); // Data Forms pm.addExtensionProvider("x", "jabber:x:data", new DataFormProvider()); // MUC User pm.addExtensionProvider("x", "http://jabber.org/protocol/muc#user", new MUCUserProvider()); // MUC Admin pm.addIQProvider("query", "http://jabber.org/protocol/muc#admin", new MUCAdminProvider()); // MUC Owner pm.addIQProvider("query", "http://jabber.org/protocol/muc#owner", new MUCOwnerProvider()); // Delayed Delivery pm.addExtensionProvider("x", "jabber:x:delay", new DelayInformationProvider()); // Version try { pm.addIQProvider("query", "jabber:iq:version", Class.forName("org.jivesoftware.smackx.packet.Version")); } catch (ClassNotFoundException e) { // Not sure what's happening here. } // VCard pm.addIQProvider("vCard", "vcard-temp", new VCardProvider()); // Offline Message Requests pm.addIQProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageRequest.Provider()); // Offline Message Indicator pm.addExtensionProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageInfo.Provider()); // Last Activity pm.addIQProvider("query", "jabber:iq:last", new LastActivity.Provider()); // User Search pm.addIQProvider("query", "jabber:iq:search", new UserSearch.Provider()); // SharedGroupsInfo pm.addIQProvider("sharedgroup", "http://www.jivesoftware.org/protocol/sharedgroup", new SharedGroupsInfo.Provider()); // JEP-33: Extended Stanza Addressing pm.addExtensionProvider("addresses", "http://jabber.org/protocol/address", new MultipleAddressesProvider()); // FileTransfer pm.addIQProvider("si", "http://jabber.org/protocol/si", new StreamInitiationProvider()); pm.addIQProvider("query", "http://jabber.org/protocol/bytestreams", new BytestreamsProvider()); pm.addIQProvider("open", "http://jabber.org/protocol/ibb", new OpenIQProvider()); pm.addIQProvider("close", "http://jabber.org/protocol/ibb", new CloseIQProvider()); pm.addExtensionProvider("data", "http://jabber.org/protocol/ibb", new DataPacketProvider()); // Privacy pm.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider()); }
From source file:lu.fisch.moenagade.model.Project.java
private boolean compile() { // get all the files content Hashtable<String, String> codes = new Hashtable<>(); String dir = directoryName + System.getProperty("file.separator") + "src"; Collection files = FileUtils.listFiles(new File(dir), new String[] { "java" }, true); for (Iterator iterator = files.iterator(); iterator.hasNext();) { File file = (File) iterator.next(); try {/* w ww .j a v a 2s . c o m*/ codes.put( file.getPath().substring(dir.length() + 1) .replace(System.getProperty("file.separator"), ".").replace(".java", ""), IOUtils.toString(file.toURI(), "utf-8")); } catch (IOException ex2) { JOptionPane.showMessageDialog(frame, "Error while saving world (base) source!\n" + ex2.getMessage() + "\n", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); ex2.printStackTrace(); return false; } } // compile try { //Runtime6.getInstance().executeCommand("System.setProperty(\"user.dir\",\"" + directoryName + "\")"); Runtime6.getInstance().setRootDirectory(directoryName + System.getProperty("file.separator") + "src"); Runtime6.getInstance().compile(codes, ""); //Runtime6.getInstance().compileToPath(sourceFiles, directoryName+System.getProperty("file.separator")+"bin", "7", ""); } catch (ClassNotFoundException ex) { JOptionPane.showMessageDialog(frame, "Error while compiling!\n" + ex.getMessage() + "\n", "Error", JOptionPane.ERROR_MESSAGE, Moenagade.IMG_ERROR); Console.disconnectAll(); ex.printStackTrace(); Console.connectAll(); return false; } return true; }
From source file:com.flexive.core.storage.PostgreSQL.PostgreSQLStorageFactory.java
/** * {@inheritDoc}// ww w . j a v 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 dropIfExist) throws Exception { Connection con = null; Statement stmt = null; try { if (StringUtils.isBlank(database)) throw new IllegalArgumentException("No database name (path) specified!"); System.out.println("using database [" + database + "], schema [" + schema + "] for " + VENDOR); String url = jdbcURL; if (StringUtils.isBlank(url)) throw new IllegalArgumentException("No JDBC URL provided!"); url = url.trim(); if (!StringUtils.isBlank(jdbcURLParameters)) url = url + jdbcURLParameters; try { Class.forName("org.postgresql.Driver").newInstance(); } catch (ClassNotFoundException e) { System.err.println("PostgreSQL JDBC Driver not found in classpath!"); return null; } System.out.println("Connecting using JDBC URL " + url); con = DriverManager.getConnection(url, user, password); stmt = con.createStatement(); int cnt = 0; if (dropIfExist) cnt += stmt.executeUpdate("DROP DATABASE IF EXISTS \"" + database + "\""); if (createDB) { //first check if it already exists ResultSet rs = stmt.executeQuery( "SELECT COUNT(*) FROM PG_CATALOG.PG_DATABASE WHERE DATNAME='" + database + "'"); boolean exists = rs != null && rs.next() && rs.getInt(1) > 0; if (rs != null) rs.close(); if (!exists) { cnt += stmt.executeUpdate("CREATE DATABASE \"" + database + "\""); System.out.println("Created database [" + database + "]."); } else System.out.println("Database [" + database + "] already exists. Skipping create."); } if (!jdbcURL.endsWith("/" + database)) { //(re)connect to that database as there seems to be no way to change the database from a sql statement stmt.close(); stmt = null; con.close(); url = url + (url.endsWith("/") ? database : "/" + database); con = DriverManager.getConnection(url, user, password); } if (cnt > 0) System.out.println("Executed " + cnt + " statements"); } catch (SQLException e) { e.printStackTrace(); return null; } finally { if (stmt != null) stmt.close(); } return con; }
From source file:io.swagger.inflector.controllers.SwaggerOperationController.java
public Method detectMethod(Operation operation) { controllerName = getControllerName(operation); methodName = getMethodName(path, httpMethod, operation); JavaType[] args = getOperationParameterClasses(operation, this.definitions); StringBuilder builder = new StringBuilder(); builder.append(getMethodName(path, httpMethod, operation)).append("("); for (int i = 0; i < args.length; i++) { if (i == 0) { builder.append(RequestContext.class.getCanonicalName()).append(" request"); } else {/* ww w . j av a 2 s . c om*/ builder.append(", "); if (args[i] == null) { LOGGER.error( "didn't expect a null class for " + operation.getParameters().get(i - 1).getName()); } else if (args[i].getRawClass() != null) { String className = args[i].getRawClass().getName(); if (className.startsWith("java.lang.")) { className = className.substring("java.lang.".length()); } builder.append(className); builder.append(" ").append(operation.getParameters().get(i - 1).getName()); } } } builder.append(")"); operationSignature = "public io.swagger.inflector.models.ResponseContext " + builder.toString(); LOGGER.info("looking for method: `" + operationSignature + "` in class `" + controllerName + "`"); this.parameterClasses = args; if (controllerName != null && methodName != null) { try { Class<?> cls; try { cls = Class.forName(controllerName); } catch (ClassNotFoundException e) { controllerName = controllerName + "Controller"; cls = Class.forName(controllerName); } 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 = getControllerFactory().instantiateController(cls, operation); LOGGER.debug("found class `" + controllerName + "`"); return method; } } } } } 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:edu.umn.cs.spatialHadoop.indexing.Indexer.java
/** * Create a partitioner for a particular job * @param ins/*ww w . j a va 2 s .com*/ * @param out * @param job * @param partitionerName * @return * @throws IOException */ public static Partitioner createPartitioner(Path[] ins, Path out, Configuration job, String partitionerName) throws IOException { try { Partitioner partitioner; Class<? extends Partitioner> partitionerClass = PartitionerClasses.get(partitionerName.toLowerCase()); if (partitionerClass == null) { // Try to parse the name as a class name try { partitionerClass = Class.forName(partitionerName).asSubclass(Partitioner.class); } catch (ClassNotFoundException e) { throw new RuntimeException("Unknown index type '" + partitionerName + "'"); } } if (PartitionerReplicate.containsKey(partitionerName.toLowerCase())) { boolean replicate = PartitionerReplicate.get(partitionerName.toLowerCase()); job.setBoolean("replicate", replicate); } partitioner = partitionerClass.newInstance(); long t1 = System.currentTimeMillis(); final Rectangle inMBR = (Rectangle) OperationsParams.getShape(job, "mbr"); // Determine number of partitions long inSize = 0; for (Path in : ins) { inSize += FileUtil.getPathSize(in.getFileSystem(job), in); } long estimatedOutSize = (long) (inSize * (1.0 + job.getFloat(SpatialSite.INDEXING_OVERHEAD, 0.1f))); FileSystem outFS = out.getFileSystem(job); long outBlockSize = outFS.getDefaultBlockSize(out); final List<Point> sample = new ArrayList<Point>(); float sample_ratio = job.getFloat(SpatialSite.SAMPLE_RATIO, 0.01f); long sample_size = job.getLong(SpatialSite.SAMPLE_SIZE, 100 * 1024 * 1024); LOG.info("Reading a sample of " + (int) Math.round(sample_ratio * 100) + "%"); ResultCollector<Point> resultCollector = new ResultCollector<Point>() { @Override public void collect(Point p) { sample.add(p.clone()); } }; OperationsParams params2 = new OperationsParams(); params2.setFloat("ratio", sample_ratio); params2.setLong("size", sample_size); if (job.get("shape") != null) params2.set("shape", job.get("shape")); if (job.get("local") != null) params2.set("local", job.get("local")); params2.setClass("outshape", Point.class, Shape.class); Sampler.sample(ins, resultCollector, params2); long t2 = System.currentTimeMillis(); System.out.println("Total time for sampling in millis: " + (t2 - t1)); LOG.info("Finished reading a sample of " + sample.size() + " records"); int partitionCapacity = (int) Math.max(1, Math.floor((double) sample.size() * outBlockSize / estimatedOutSize)); int numPartitions = Math.max(1, (int) Math.ceil((float) estimatedOutSize / outBlockSize)); LOG.info("Partitioning the space into " + numPartitions + " partitions with capacity of " + partitionCapacity); partitioner.createFromPoints(inMBR, sample.toArray(new Point[sample.size()]), partitionCapacity); return partitioner; } catch (InstantiationException e) { e.printStackTrace(); return null; } catch (IllegalAccessException e) { e.printStackTrace(); return null; } }
From source file:com.projity.field.Field.java
public void setType(String type) { try {/*from w w w. j av a2 s .c om*/ setExternalType(Class.forName(type)); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:hu.sztaki.lpds.pgportal.services.asm.ASMService.java
/** * Set job_desc/*from w w w .j a v a 2 s .c o m*/ * * * * @param prop * - property name to set ("nodenumber" etc.) * @param value * - property value * @param userID * - id of the user who owns the workflow * @param workflowID * - id of the workflow * @param jobID * - id of the job */ private void setJobDesc(String prop, String value, String userID, String workflowID, String jobID) { try { Vector<JobPropertyBean> jobs = getConfigData(userID, workflowID); for (JobPropertyBean j : jobs) { if (j.getName().equals(jobID)) { // j.getExe().put(prop, value); j.getDesc().put(prop, value); System.out.println("job : " + j.getName() + " set job property:" + prop + " value: " + value); break; } } // MoSGrid autosave if (autoSave) { saveConfigData(userID, workflowID, jobs); } } catch (ClassNotFoundException ex) { ex.printStackTrace(); Logger.getLogger(ASMService.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { ex.printStackTrace(); Logger.getLogger(ASMService.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { ex.printStackTrace(); Logger.getLogger(ASMService.class.getName()).log(Level.SEVERE, null, ex); } }