List of usage examples for java.lang ClassNotFoundException getMessage
public String getMessage()
From source file:jade.core.messaging.FileMessageStorage.java
public synchronized void loadAll(LoadListener ll) throws IOException { // Notify the listener that the load process started ll.loadStarted(""); // Scan all its valid subdirectories. File[] subdirs = baseDir.listFiles(new FileFilter() { public boolean accept(File f) { return f.isDirectory() && f.getName().startsWith(RECEIVER_PREFIX); }//w ww .jav a 2s .c o m }); for (int i = 0; i < subdirs.length; i++) { File subdir = subdirs[i]; // Scan all its valid files. File[] files = subdir.listFiles(new FileFilter() { public boolean accept(File f) { return !f.isDirectory() && f.getName().startsWith(MESSAGE_PREFIX); } }); for (int j = 0; j < files.length; j++) { File toRead = files[j]; // Read the file content BufferedReader in = new BufferedReader(new FileReader(toRead)); // Read the number of copies String strHowMany = in.readLine(); long howMany = 1; try { howMany = Long.parseLong(strHowMany); } catch (NumberFormatException nfe) { // Do nothing; the default value will be used } try { // NL (23/01/04) GenericMessage are now stored using Java serialization String encodedMsg = in.readLine(); // String.getBytes is, in general, an irreversible operation. However, in this case, because // the content was previously encoded Base64, we can expect that we will have only valid Base64 chars. ByteArrayInputStream istream = new ByteArrayInputStream( Base64.decodeBase64(encodedMsg.getBytes("US-ASCII"))); ObjectInputStream p = new ObjectInputStream(istream); GenericMessage message = (GenericMessage) p.readObject(); istream.close(); // Use an ACL codec to read in the receiver AID StringACLCodec codec = new StringACLCodec(in, null); // Read the receiver AID AID receiver = codec.decodeAID(); // Notify the listener that a new item was loaded for (int k = 0; k < howMany; k++) { ll.itemLoaded(toRead.getName(), message, receiver); } } catch (ACLCodec.CodecException ce) { System.err.println("Error reading file " + toRead.getName() + " [" + ce.getMessage() + "]"); } catch (ClassNotFoundException cnfe) { System.err.println("Error reading file " + toRead.getName() + " [" + cnfe.getMessage() + "]"); } finally { in.close(); } } } // Notify the listener that the load process ended ll.loadEnded(""); }
From source file:org.toobsframework.scheduler.AppScheduler.java
public void init() { try {/* w w w . j a v a 2 s .c o m*/ SchedulerFactory sf = new StdSchedulerFactory(); scheduler = sf.getScheduler(); Iterator<AppScheduleInfo> iter = appSchedules.iterator(); while (iter.hasNext()) { AppScheduleInfo appInfo = (AppScheduleInfo) iter.next(); try { JobDetail job = new JobDetail(appInfo.getJobName(), appInfo.getGroupName(), java.lang.Class.forName(appInfo.getJobClass())); String jobSchedule = appInfo.getJobSchedule(); String jobSchedOvr = configuration.getProperty(appInfo.getJobEnvCronProperty()); if (jobSchedOvr != null && jobSchedOvr.length() > 0) { jobSchedule = jobSchedOvr; } CronTrigger trigger = new CronTrigger("Trigger-" + appInfo.getJobName(), "Trigger-" + appInfo.getGroupName(), appInfo.getJobName(), appInfo.getGroupName(), jobSchedule); scheduler.addJob(job, true); Date ft = scheduler.scheduleJob(trigger); log.info("Job " + job.getName() + " will next run at " + ft.toString()); } catch (ClassNotFoundException e) { log.error("Job " + appInfo.getJobName() + " class " + appInfo.getJobClass() + " not found"); } } scheduler.start(); memMon = MemoryMonitor.getInstance(); } catch (ParseException e) { log.error("ParseException in AppScheduler " + e.getMessage(), e); } catch (SchedulerException e) { log.error("SchedulerException in AppScheduler " + e.getMessage(), e); } }
From source file:javarestart.WebClassLoader.java
@Override protected Class<?> findClass(final String name) throws ClassNotFoundException { String res = name.replace('.', '/') + ".class"; try {/*from w ww . j a v a 2 s .c o m*/ if (initialBundle.containsKey(res)) { byte[] classBytes = initialBundle.get(res); if (classBytes == null) { throw new ClassNotFoundException("resource " + name + " not found"); } initialBundle.remove(res); Class c = defineClass(null, classBytes, 0, classBytes.length); fireClassLoaded(name); return c; } URL resource = findResourceImpl(name.replace('.', '/') + ".class"); if (resource == null) { throw new ClassNotFoundException("resource " + name + " not found"); } Class c = tryToLoadClass(resource.openStream()); fireClassLoaded(name); return c; } catch (ClassNotFoundException e) { throw e; } catch (final Exception e) { throw new ClassNotFoundException(e.getMessage(), e); } }
From source file:hydrograph.ui.dataviewer.actions.ReloadAction.java
@Override public void run() { viewDataPreferencesVO = debugDataViewer.getViewDataPreferences(); DataViewerUtility.INSTANCE.resetSort(debugDataViewer); Job job = new Job(Messages.LOADING_DEBUG_FILE) { @Override/* w w w . ja va 2 s.c o m*/ protected IStatus run(IProgressMonitor monitor) { debugDataViewer.disbleDataViewerUIControls(); if (lastDownloadedFileSize != viewDataPreferencesVO.getFileSize() || ifFilterReset) { int returnCode = downloadDebugFile(); if (StatusConstants.ERROR == returnCode) { return Status.CANCEL_STATUS; } } try { closeExistingDebugFileConnection(); if (lastDownloadedFileSize != viewDataPreferencesVO.getFileSize() || ifFilterReset) { debugDataViewer.getDataViewerAdapter() .reinitializeAdapter(viewDataPreferencesVO.getPageSize(), true); } else { SelectColumnAction selectColumnAction = (SelectColumnAction) debugDataViewer .getActionFactory().getAction(SelectColumnAction.class.getName()); debugDataViewer.getDataViewerAdapter() .reinitializeAdapter(viewDataPreferencesVO.getPageSize(), false); if (selectColumnAction.getSelectedColumns().size() != 0) { debugDataViewer.getDataViewerAdapter() .setColumnList(selectColumnAction.getSelectedColumns()); } } } catch (ClassNotFoundException e) { Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); showDetailErrorMessage(Messages.UNABLE_TO_RELOAD_DEBUG_FILE + ": unable to load CSV Driver", status); return Status.CANCEL_STATUS; } catch (SQLException | IOException exception) { Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, exception.getMessage(), exception); showDetailErrorMessage(Messages.UNABLE_TO_RELOAD_DEBUG_FILE + ": unable to read view data file", status); if (debugDataViewer.getDataViewerAdapter() != null) { debugDataViewer.getDataViewerAdapter().closeConnection(); return Status.CANCEL_STATUS; } debugDataViewer.close(); } Display.getDefault().asyncExec(new Runnable() { @Override public void run() { debugDataViewer.getStatusManager().getStatusLineManager().getProgressMonitor().done(); debugDataViewer.getActionFactory().enableAllActions(true); debugDataViewer.getStatusManager().setStatus(new StatusMessage(StatusConstants.SUCCESS)); debugDataViewer.getStatusManager().enableInitialPaginationContols(); debugDataViewer.getStatusManager().clearJumpToPageText(); updateDataViewerViews(); if (lastDownloadedFileSize != viewDataPreferencesVO.getFileSize() || ifFilterReset) { debugDataViewer.submitRecordCountJob(); setIfFilterReset(false); } lastDownloadedFileSize = viewDataPreferencesVO.getFileSize(); DataViewerUtility.INSTANCE.resetSort(debugDataViewer); debugDataViewer.redrawTableCursor(); } }); return Status.OK_STATUS; } }; job.schedule(); }
From source file:org.commonjava.indy.core.expire.DatabaseLifecycleActions.java
@Override public void stop() throws IndyLifecycleException { if (!schedulerConfig.isEnabled()) { logger.info("Scheduler disabled. Skipping its initialization"); return;//from w ww . j a v a 2 s .c o m } final String dbDriver = schedulerConfig.getDbDriver(); if (dbDriver.startsWith(APACHEDB_DRIVER_SUPER_PACKAGE)) { final String url = APACHEDB_SHUTDOWN_URL; Connection connection = null; try { Thread.currentThread().getContextClassLoader().loadClass(dbDriver); logger.info("Connecting to DB: {}", url); connection = DriverManager.getConnection(url); } catch (final ClassNotFoundException e) { throw new IndyLifecycleException("Failed to load database driver: " + dbDriver, e); } catch (final SQLException e) { logger.debug(e.getMessage(), e); } finally { close(null, null, connection, url); // try // { // final Driver driver = DriverManager.getDriver( url ); // DriverManager.deregisterDriver( driver ); // } // catch ( final SQLException e ) // { // logger.debug( "Failed to deregister database driver for: " + url, e ); // } } } }
From source file:com.bah.bahdit.main.plugins.fulltextindex.FullTextIndex.java
/** * loads the necessary files from the properties file * called from FullTextIndex.configure//from www . ja v a 2s . c o m * * @param context - passed from the servlet */ @SuppressWarnings("unchecked") private void loadResources(ServletContext context) { // get the sample table from resources try { InputStream sample = context.getResourceAsStream(properties.getProperty(FT_SAMPLE)); InputStream samplebuffer = new BufferedInputStream(sample); ObjectInput objectsample = new ObjectInputStream(samplebuffer); sampleTable = (HashMap<String, Integer>) objectsample.readObject(); } catch (ClassNotFoundException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } // get the pagerank table from resources try { InputStream pagerank = context.getResourceAsStream(properties.getProperty(PR_FILE)); InputStream pagerankbuffer = new BufferedInputStream(pagerank); ObjectInput objectpagerank = new ObjectInputStream(pagerankbuffer); pagerankTable = (HashMap<String, Double>) objectpagerank.readObject(); } catch (ClassNotFoundException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } // get the spell checker spellChecker = LevenshteinDistance.createSpellChecker(context, sampleTable); // create stop words list from general list try { stopWords = new HashSet<String>(); InputStream gstop = context.getResourceAsStream(properties.getProperty(Search.GENERAL_STOP)); DataInputStream gin = new DataInputStream(gstop); BufferedReader gbr = new BufferedReader(new InputStreamReader(gin)); String strLine; while ((strLine = gbr.readLine()) != null) stopWords.add(strLine); } catch (IOException e) { log.error(e.getMessage()); } }
From source file:com.adito.boot.AbstractPropertyClass.java
public void restore() throws IOException { log.info("Restoring property class " + getName()); if (store == null) { throw new IllegalStateException("Nothing stored for " + getName()); }/*from w w w . jav a2s . c om*/ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(store.toByteArray())) { protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { try { return Class.forName(desc.getName(), false, AbstractPropertyClass.this.getClass().getClassLoader()); } catch (ClassNotFoundException ex) { return super.resolveClass(desc); } } }; try { definitions = (Map<String, PropertyDefinition>) ois.readObject(); categories = (List<PropertyDefinitionCategory>) ois.readObject(); categoryMap = (Map<String, PropertyDefinitionCategory>) ois.readObject(); store = null; // PropertyClass member variable is transient so we need to reinitialise for (PropertyDefinition def : definitions.values()) def.init(this); for (PropertyDefinitionCategory cat : categories) cat.setPropertyClass(this); } catch (ClassNotFoundException cnfe) { throw new IOException("Deserialisation failed. " + cnfe.getMessage()); } finally { ois.close(); } }
From source file:edu.cornell.med.icb.goby.modes.GenericToolsDriver.java
/** * Load the list of concrete modes./* w ww . j a v a 2s . c om*/ */ private void loadModeMap() { final Map<String, Class> modeMap = MODES_MAP; final Map<String, Class> shortModeMap = SHORT_MODES_MAP; final Map<Class, String> shortModeReverseMap = SHORT_MODES_REVERSE_MAP; final Set<String> allShortModes = new HashSet<String>(); for (final String modeClassName : modesClassNamesList()) { try { LOG.debug("About to process modeClassName: " + modeClassName); final Class modeClass = Class.forName(modeClassName); if (Modifier.isAbstract(modeClass.getModifiers())) { // Ignore abstract classes continue; } // Since we're not abstract, we can make an instance final Object modeInstance = modeClass.newInstance(); if (modeInstance instanceof AbstractCommandLineMode) { final String modeName = ((AbstractCommandLineMode) modeInstance).getModeName(); final String shortModeName = ((AbstractCommandLineMode) modeInstance).getShortModeName(); // Make sure the class has a static field "MODE_NAME" if (modeName != null) { modeMap.put(modeName, modeClass); if (shortModeName != null) { if (!allShortModes.contains(shortModeName)) { shortModeMap.put(shortModeName, modeClass); shortModeReverseMap.put(modeClass, shortModeName); allShortModes.add(shortModeName); } else { // Do not offer short versions for which there are duplicates. One needs // to hand write versions of getShortModeName() for these classes. shortModeReverseMap.remove(shortModeMap.get(shortModeName)); shortModeMap.remove(shortModeName); } } } } } catch (ClassNotFoundException e) { System.err.println( "Could find a class for " + modeClassName + " ClassNotFoundException: " + e.getMessage()); } catch (IllegalAccessException e) { System.err.println("Could not find MODE_NAME for class " + modeClassName + " IllegalAccessException: " + e.getMessage()); } catch (InstantiationException e) { System.err.println("Could not find MODE_NAME for class " + modeClassName + " InstantiationException: " + e.getMessage()); } } }
From source file:edu.lternet.pasta.token.TokenManager.java
/** * Returns a connection to the database. * * @return The database Connection object. *///from w w w .j a v a 2 s. c om private Connection getConnection() throws ClassNotFoundException { Connection conn = null; SQLWarning warn; // Load the jdbc driver. try { Class.forName(this.dbDriver); } catch (ClassNotFoundException e) { logger.error("Can't load driver " + e.getMessage()); throw (e); } // Make the database connection try { conn = DriverManager.getConnection(this.dbURL, this.dbUser, this.dbPassword); // If a SQLWarning object is available, print its warning(s). // There may be multiple warnings chained. warn = conn.getWarnings(); if (warn != null) { while (warn != null) { logger.warn("SQLState: " + warn.getSQLState()); logger.warn("Message: " + warn.getMessage()); logger.warn("Vendor: " + warn.getErrorCode()); warn = warn.getNextWarning(); } } } catch (SQLException e) { logger.error("Database access failed " + e); } return conn; }
From source file:info.magnolia.content2bean.impl.Content2BeanTransformerImpl.java
/** * Most of the conversion is done by the BeanUtils. TODO don't use bean utils conversion since it can't be used for * the adder methods// w ww . j a va2 s . c o m */ @Override public Object convertPropertyValue(Class<?> propertyType, Object value) throws Content2BeanException { if (Class.class.equals(propertyType)) { try { return Classes.getClassFactory().forName(value.toString()); } catch (ClassNotFoundException e) { log.error(e.getMessage()); throw new Content2BeanException(e); } } if (Locale.class.equals(propertyType)) { if (value instanceof String) { String localeStr = (String) value; if (StringUtils.isNotEmpty(localeStr)) { return LocaleUtils.toLocale(localeStr); } } } if (Collection.class.equals(propertyType) && value instanceof Map) { // TODO never used ? return ((Map) value).values(); } // this is mainly the case when we are flattening node hierarchies if (String.class.equals(propertyType) && value instanceof Map && ((Map) value).size() == 1) { return ((Map) value).values().iterator().next(); } return value; }