List of usage examples for java.lang ClassNotFoundException getMessage
public String getMessage()
From source file:com.gemstone.gemfire.management.internal.cli.functions.DataCommandFunction.java
@SuppressWarnings({ "rawtypes" }) public DataCommandResult remove(String key, String keyClass, String regionName, String removeAllKeys) { Cache cache = CacheFactory.getAnyInstance(); if (regionName == null || regionName.isEmpty()) { return DataCommandResult.createRemoveResult(key, null, null, CliStrings.REMOVE__MSG__REGIONNAME_EMPTY, false);/*from w w w. j a v a 2 s . com*/ } boolean allKeysFlag = (removeAllKeys == null || removeAllKeys.isEmpty()); if (allKeysFlag && (key == null || key.isEmpty())) { return DataCommandResult.createRemoveResult(key, null, null, CliStrings.REMOVE__MSG__KEY_EMPTY, false); } Region region = cache.getRegion(regionName); if (region == null) { return DataCommandResult.createRemoveInfoResult(key, null, null, CliStrings.format(CliStrings.REMOVE__MSG__REGION_NOT_FOUND, regionName), false); } else { if (removeAllKeys == null) { Object keyObject = null; try { keyObject = getClassObject(key, keyClass); } catch (ClassNotFoundException e) { return DataCommandResult.createRemoveResult(key, null, null, "ClassNotFoundException " + keyClass, false); } catch (IllegalArgumentException e) { return DataCommandResult.createRemoveResult(key, null, null, "Error in converting JSON " + e.getMessage(), false); } if (region.containsKey(keyObject)) { Object value = region.remove(keyObject); if (logger.isDebugEnabled()) logger.debug("Removed key {} successfully", key); //return DataCommandResult.createRemoveResult(key, value, null, null); Object array[] = getJSONForNonPrimitiveObject(value); DataCommandResult result = DataCommandResult.createRemoveResult(key, array[1], null, null, true); if (array[0] != null) result.setValueClass((String) array[0]); return result; } else { return DataCommandResult.createRemoveInfoResult(key, null, null, CliStrings.REMOVE__MSG__KEY_NOT_FOUND_REGION, false); } } else { DataPolicy policy = region.getAttributes().getDataPolicy(); if (!policy.withPartitioning()) { region.clear(); if (logger.isDebugEnabled()) logger.debug("Cleared all keys in the region - {}", regionName); return DataCommandResult.createRemoveInfoResult(key, null, null, CliStrings.format(CliStrings.REMOVE__MSG__CLEARED_ALL_CLEARS, regionName), true); } else { return DataCommandResult.createRemoveInfoResult(key, null, null, CliStrings.REMOVE__MSG__CLEAREALL_NOT_SUPPORTED_FOR_PARTITIONREGION, false); } } } }
From source file:org.apache.geode.management.internal.cli.functions.DataCommandFunction.java
@SuppressWarnings({ "rawtypes" }) public DataCommandResult remove(String key, String keyClass, String regionName, String removeAllKeys) { Cache cache = CacheFactory.getAnyInstance(); if (regionName == null || regionName.isEmpty()) { return DataCommandResult.createRemoveResult(key, null, null, CliStrings.REMOVE__MSG__REGIONNAME_EMPTY, false);// w w w. j a v a 2 s . c o m } boolean allKeysFlag = (removeAllKeys == null || removeAllKeys.isEmpty()); if (allKeysFlag && (key == null || key.isEmpty())) { return DataCommandResult.createRemoveResult(key, null, null, CliStrings.REMOVE__MSG__KEY_EMPTY, false); } Region region = cache.getRegion(regionName); if (region == null) { return DataCommandResult.createRemoveInfoResult(key, null, null, CliStrings.format(CliStrings.REMOVE__MSG__REGION_NOT_FOUND, regionName), false); } else { if (removeAllKeys == null) { Object keyObject = null; try { keyObject = getClassObject(key, keyClass); } catch (ClassNotFoundException e) { return DataCommandResult.createRemoveResult(key, null, null, "ClassNotFoundException " + keyClass, false); } catch (IllegalArgumentException e) { return DataCommandResult.createRemoveResult(key, null, null, "Error in converting JSON " + e.getMessage(), false); } if (region.containsKey(keyObject)) { Object value = region.remove(keyObject); if (logger.isDebugEnabled()) logger.debug("Removed key {} successfully", key); // return DataCommandResult.createRemoveResult(key, value, null, null); Object array[] = getJSONForNonPrimitiveObject(value); DataCommandResult result = DataCommandResult.createRemoveResult(key, array[1], null, null, true); if (array[0] != null) result.setValueClass((String) array[0]); return result; } else { return DataCommandResult.createRemoveInfoResult(key, null, null, CliStrings.REMOVE__MSG__KEY_NOT_FOUND_REGION, false); } } else { DataPolicy policy = region.getAttributes().getDataPolicy(); if (!policy.withPartitioning()) { region.clear(); if (logger.isDebugEnabled()) logger.debug("Cleared all keys in the region - {}", regionName); return DataCommandResult.createRemoveInfoResult(key, null, null, CliStrings.format(CliStrings.REMOVE__MSG__CLEARED_ALL_CLEARS, regionName), true); } else { return DataCommandResult.createRemoveInfoResult(key, null, null, CliStrings.REMOVE__MSG__CLEAREALL_NOT_SUPPORTED_FOR_PARTITIONREGION, false); } } } }
From source file:org.apache.hadoop.zebra.pig.TableStorer.java
@Override public void setStoreLocation(String location, Job job) throws IOException { Configuration conf = job.getConfiguration(); String[] outputs = location.split(","); if (outputs.length == 1) { BasicTableOutputFormat.setOutputPath(job, new Path(location)); } else if (outputs.length > 1) { if (partitionClass == null) { try { partitionClass = (Class<? extends ZebraOutputPartition>) conf .getClassByName(partitionClassString); } catch (ClassNotFoundException e) { throw new IOException(e); }/*from w w w . java 2 s. c o m*/ } Path[] paths = new Path[outputs.length]; for (int i = 0; i < paths.length; i++) { paths[i] = new Path(outputs[i]); } BasicTableOutputFormat.setMultipleOutputs(job, partitionClass, partitionClassArgumentsString, paths); } else { throw new IOException("Invalid location : " + location); } // Get schema string and sorting info from UDFContext and re-store them to // job config. Properties properties = UDFContext.getUDFContext().getUDFProperties(this.getClass(), new String[] { udfContextSignature }); ZebraSchema zSchema = ZebraSchema.createZebraSchema(properties.getProperty(UDFCONTEXT_OUTPUT_SCHEMA)); ZebraSortInfo zSortInfo = ZebraSortInfo.createZebraSortInfo(properties.getProperty(UDFCONTEXT_SORT_INFO), null); ZebraStorageHint zStorageHint = ZebraStorageHint.createZebraStorageHint(storageHintString); try { BasicTableOutputFormat.setStorageInfo(job, zSchema, zStorageHint, zSortInfo); } catch (ParseException e) { throw new IOException("Invalid storage info: " + e.getMessage()); } // Get checktype information from UDFContext and re-store it to job config; if (properties.getProperty(UDFCONTEXT_OUTPUT_CHECKTYPE) != null && properties.getProperty(UDFCONTEXT_OUTPUT_CHECKTYPE).equals("no")) { ZebraConf.setCheckType(conf, false); } }
From source file:corner.service.EntityService.java
/** * ???./*from w ww . ja va 2 s . c o m*/ * * @param clazzname * ??. * @param key * . * @return ,?,null. */ @SuppressWarnings("unchecked") public Object getEntity(String clazzname, Serializable key) { Class clazz; try { clazz = Class.forName(clazzname); return this.getEntity(clazz, key); } catch (ClassNotFoundException e) { // do nothing logger.warn(e.getMessage()); return null; } }
From source file:org.bytesoft.bytetcc.supports.spring.CompensableAnnotationValidator.java
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { Map<String, Class<?>> otherServiceMap = new HashMap<String, Class<?>>(); Map<String, Compensable> compensables = new HashMap<String, Compensable>(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); String[] beanNameArray = beanFactory.getBeanDefinitionNames(); for (int i = 0; beanNameArray != null && i < beanNameArray.length; i++) { String beanName = beanNameArray[i]; BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName); String className = beanDef.getBeanClassName(); Class<?> clazz = null; try {//from ww w . j a v a2 s .c o m clazz = cl.loadClass(className); } catch (ClassNotFoundException ex) { continue; } try { Compensable compensable = clazz.getAnnotation(Compensable.class); if (compensable == null) { otherServiceMap.put(beanName, clazz); continue; } else { compensables.put(beanName, compensable); } Class<?> interfaceClass = compensable.interfaceClass(); if (interfaceClass.isInterface() == false) { throw new IllegalStateException("Compensable's interfaceClass must be a interface."); } Method[] methodArray = interfaceClass.getDeclaredMethods(); for (int j = 0; j < methodArray.length; j++) { Method interfaceMethod = methodArray[j]; Method method = clazz.getMethod(interfaceMethod.getName(), interfaceMethod.getParameterTypes()); this.validateDeclaredRemotingException(method, clazz); this.validateTransactionalPropagation(method, clazz); } } catch (IllegalStateException ex) { throw new FatalBeanException(ex.getMessage(), ex); } catch (NoSuchMethodException ex) { throw new FatalBeanException(ex.getMessage(), ex); } catch (SecurityException ex) { throw new FatalBeanException(ex.getMessage(), ex); } } Iterator<Map.Entry<String, Compensable>> itr = compensables.entrySet().iterator(); while (itr.hasNext()) { Map.Entry<String, Compensable> entry = itr.next(); Compensable compensable = entry.getValue(); Class<?> interfaceClass = compensable.interfaceClass(); String confirmableKey = compensable.confirmableKey(); String cancellableKey = compensable.cancellableKey(); if (StringUtils.isNotBlank(confirmableKey)) { if (compensables.containsKey(confirmableKey)) { throw new FatalBeanException(String .format("The confirm bean(id= %s) cannot be a compensable service!", confirmableKey)); } Class<?> clazz = otherServiceMap.get(confirmableKey); if (clazz == null) { throw new IllegalStateException( String.format("The confirm bean(id= %s) is not exists!", confirmableKey)); } try { Method[] methodArray = interfaceClass.getDeclaredMethods(); for (int j = 0; j < methodArray.length; j++) { Method interfaceMethod = methodArray[j]; Method method = clazz.getMethod(interfaceMethod.getName(), interfaceMethod.getParameterTypes()); this.validateDeclaredRemotingException(method, clazz); this.validateTransactionalPropagation(method, clazz); this.validateTransactionalRollbackFor(method, clazz, confirmableKey); } } catch (IllegalStateException ex) { throw new FatalBeanException(ex.getMessage(), ex); } catch (NoSuchMethodException ex) { throw new FatalBeanException(ex.getMessage(), ex); } catch (SecurityException ex) { throw new FatalBeanException(ex.getMessage(), ex); } } if (StringUtils.isNotBlank(cancellableKey)) { if (compensables.containsKey(cancellableKey)) { throw new FatalBeanException(String .format("The cancel bean(id= %s) cannot be a compensable service!", confirmableKey)); } Class<?> clazz = otherServiceMap.get(cancellableKey); if (clazz == null) { throw new IllegalStateException( String.format("The cancel bean(id= %s) is not exists!", cancellableKey)); } try { Method[] methodArray = interfaceClass.getDeclaredMethods(); for (int j = 0; j < methodArray.length; j++) { Method interfaceMethod = methodArray[j]; Method method = clazz.getMethod(interfaceMethod.getName(), interfaceMethod.getParameterTypes()); this.validateDeclaredRemotingException(method, clazz); this.validateTransactionalPropagation(method, clazz); this.validateTransactionalRollbackFor(method, clazz, cancellableKey); } } catch (IllegalStateException ex) { throw new FatalBeanException(ex.getMessage(), ex); } catch (NoSuchMethodException ex) { throw new FatalBeanException(ex.getMessage(), ex); } catch (SecurityException ex) { throw new FatalBeanException(ex.getMessage(), ex); } } } }
From source file:com.flexive.testRunner.FxTestRunnerThread.java
/** * {@inheritDoc}/*from w w w .ja v a 2 s . c o m*/ */ @Override public void run() { synchronized (lock) { if (testInProgress) return; testInProgress = true; } try { ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL jar = cl.getResource("lib/flexive-tests.jar"); //build a list of all test classes List<Class> testClasses = new ArrayList<Class>(100); try { JarInputStream jin = new JarInputStream(jar.openStream()); while (jin.available() != 0) { JarEntry je = jin.getNextJarEntry(); if (je == null) continue; final String name = je.getName(); //only classes, no inner classes, abstract or mock classes if (name.endsWith(".class") && !(name.indexOf('$') > 0) && !(name.indexOf("Abstract") > 0) && !(name.indexOf("Mock") > 0)) { boolean ignore = false; //check ignore package for (String pkg : FxTestRunner.ignorePackages) if (name.indexOf(pkg) > 0) { ignore = true; break; } if (ignore) continue; final String className = name.substring(name.lastIndexOf('/') + 1); //check ignore classes for (String cls : FxTestRunner.ignoreTests) if (className.indexOf(cls) > 0) { ignore = true; break; } if (ignore) continue; final String fqn = name.replaceAll("\\/", ".").substring(0, name.lastIndexOf('.')); try { testClasses.add(Class.forName(fqn)); } catch (ClassNotFoundException e) { LOG.error("Could not find test class: " + fqn); } } } } catch (IOException e) { LOG.error(e); } TestNG testng = new TestNG(); testng.setTestClasses(testClasses.toArray(new Class[testClasses.size()])); // skip.ear groups have to be excluded, else tests that include these will be skipped as well (like ContainerBootstrap which is needed) testng.setExcludedGroups("skip.ear"); System.setProperty("flexive.tests.ear", "1"); TestListenerAdapter tla = new TestListenerAdapter(); testng.addListener(tla); if (callback != null) { FxTestRunnerListener trl = new FxTestRunnerListener(callback); testng.addListener(trl); } testng.setThreadCount(4); testng.setVerbose(0); testng.setDefaultSuiteName("EARTestSuite"); testng.setOutputDirectory(outputPath); if (callback != null) callback.resetTestInfo(); try { testng.run(); } catch (Exception e) { LOG.error(e); new FxFacesMsgErr("TestRunner.err.testNG", e.getMessage()).addToContext(); } if (callback != null) { callback.setRunning(false); callback.setResultsAvailable(true); } } finally { synchronized (lock) { testInProgress = false; } } }
From source file:com.zenesis.qx.remote.RequestHandler.java
/** * Handles creating a server object to match one created on the client; expects className, * clientId, properties//ww w . j ava2s.c o m * @param jp * @throws ServletException * @throws IOException */ protected void cmdNewObject(JsonParser jp) throws ServletException, IOException { // Get the basics String className = getFieldValue(jp, "className", String.class); int clientId = getFieldValue(jp, "clientId", Integer.class); // Get the class Class<? extends Proxied> clazz; try { clazz = (Class<? extends Proxied>) Class.forName(className); } catch (ClassNotFoundException e) { throw new ServletException("Unknown class " + className); } ProxyType type = ProxyTypeManager.INSTANCE.getProxyType(clazz); // Create the instance Proxied proxied; try { proxied = type.newInstance(clazz); } catch (InstantiationException e) { throw new ServletException("Cannot create class " + className + ": " + e.getMessage(), e); } catch (InvocationTargetException e) { throw new ServletException("Cannot create class " + className + ": " + e.getMessage(), e); } catch (IllegalAccessException e) { throw new ServletException("Cannot create class " + className + ": " + e.getMessage(), e); } // Get the server ID int serverId = tracker.addClientObject(proxied); // Remember the client ID, in case there are subsequent commands which refer to it if (clientObjects == null) clientObjects = new HashMap<Integer, Proxied>(); clientObjects.put(clientId, proxied); // Tell the client about the new ID - do this before changing properties tracker.invalidateCache(proxied); tracker.getQueue().queueCommand(CommandId.CommandType.MAP_CLIENT_ID, proxied, null, new MapClientId(serverId, clientId)); // Set property values if (jp.nextToken() == JsonToken.FIELD_NAME) { if (jp.nextToken() != JsonToken.START_OBJECT) throw new ServletException("Unexpected properties definiton for 'new' command"); while (jp.nextToken() != JsonToken.END_OBJECT) { String propertyName = jp.getCurrentName(); jp.nextToken(); // Read a Proxied object? ProxyProperty prop = getProperty(type, propertyName); MetaClass propClass = prop.getPropertyClass(); Object value = null; if (propClass.isSubclassOf(Proxied.class)) { if (propClass.isArray() || propClass.isCollection()) { value = readArray(jp, propClass.getJavaType()); } else if (propClass.isMap()) { value = readMap(jp, propClass.getKeyClass(), propClass.getJavaType()); } else { Integer id = jp.readValueAs(Integer.class); if (id != null) value = getProxied(id); } } else { value = jp.readValueAs(Object.class); if (value != null && Enum.class.isAssignableFrom(propClass.getJavaType())) { String str = Helpers.camelCaseToEnum(value.toString()); value = Enum.valueOf(propClass.getJavaType(), str); } } setPropertyValue(type, proxied, propertyName, value); } } // Done jp.nextToken(); }
From source file:org.apache.camel.impl.DefaultPackageScanClassResolver.java
/** * Add the class designated by the fully qualified class name provided to * the set of resolved classes if and only if it is approved by the Test * supplied.//from w ww.j a va 2 s . co m * * @param test the test used to determine if the class matches * @param fqn the fully qualified name of a class */ protected void addIfMatching(PackageScanFilter test, String fqn, Set<Class<?>> classes) { try { String externalName = fqn.substring(0, fqn.indexOf('.')).replace('/', '.'); Set<ClassLoader> set = getClassLoaders(); boolean found = false; for (ClassLoader classLoader : set) { if (log.isTraceEnabled()) { log.trace("Testing for class " + externalName + " matches criteria [" + test + "] using classloader:" + classLoader); } try { Class<?> type = classLoader.loadClass(externalName); if (log.isTraceEnabled()) { log.trace("Loaded the class: " + type + " in classloader: " + classLoader); } if (test.matches(type)) { if (log.isTraceEnabled()) { log.trace("Found class: " + type + " which matches the filter in classloader: " + classLoader); } classes.add(type); } found = true; break; } catch (ClassNotFoundException e) { if (log.isTraceEnabled()) { log.trace( "Cannot find class '" + fqn + "' in classloader: " + classLoader + ". Reason: " + e, e); } } catch (NoClassDefFoundError e) { if (log.isTraceEnabled()) { log.trace("Cannot find the class definition '" + fqn + "' in classloader: " + classLoader + ". Reason: " + e, e); } } } if (!found) { if (log.isDebugEnabled()) { // use debug to avoid being noisy in logs log.debug("Cannot find class '" + fqn + "' in any classloaders: " + set); } } } catch (Exception e) { if (log.isWarnEnabled()) { log.warn("Cannot examine class '" + fqn + "' due to a " + e.getClass().getName() + " with message: " + e.getMessage(), e); } } }
From source file:net.yacy.http.servlets.YaCyDefaultServlet.java
protected Method rewriteMethod(final File classFile) throws InvocationTargetException { Method m = null;//from w w w. j a v a 2s . c om // now make a class out of the stream try { final SoftReference<Method> ref = templateMethodCache.get(classFile); if (ref != null) { m = ref.get(); if (m == null) { templateMethodCache.remove(classFile); } else { return m; } } final Class<?> c = provider.loadClass(classFile); final Class<?>[] params = (Class<?>[]) Array.newInstance(Class.class, 3); params[0] = RequestHeader.class; params[1] = serverObjects.class; params[2] = serverSwitch.class; m = c.getMethod("respond", params); if (MemoryControl.shortStatus()) { templateMethodCache.clear(); } else { // store the method into the cache templateMethodCache.put(classFile, new SoftReference<Method>(m)); } } catch (final ClassNotFoundException e) { ConcurrentLog.severe("FILEHANDLER", "YaCyDefaultServlet: class " + classFile + " is missing:" + e.getMessage()); throw new InvocationTargetException(e, "class " + classFile + " is missing:" + e.getMessage()); } catch (final NoSuchMethodException e) { ConcurrentLog.severe("FILEHANDLER", "YaCyDefaultServlet: method 'respond' not found in class " + classFile + ": " + e.getMessage()); throw new InvocationTargetException(e, "method 'respond' not found in class " + classFile + ": " + e.getMessage()); } return m; }
From source file:ca.uhn.fhir.rest.server.servlet.ServletRequestDetails.java
@Override protected byte[] getByteStreamRequestContents() { /*//from w w w. ja v a2 s .co m * This is weird, but this class is used both in clients and in servers, and we want to avoid needing to depend on * servlet-api in clients since there is no point. So we dynamically load a class that does the servlet processing * in servers. Down the road it may make sense to just split the method binding classes into server and client * versions, but this isn't actually a huge deal I don't think. */ IRequestReader reader = ourRequestReader; if (reader == null) { try { Class.forName("javax.servlet.ServletInputStream"); String className = BaseMethodBinding.class.getName() + "$" + "ActiveRequestReader"; try { reader = (IRequestReader) Class.forName(className).newInstance(); } catch (Exception e1) { throw new ConfigurationException("Failed to instantiate class " + className, e1); } } catch (ClassNotFoundException e) { String className = BaseMethodBinding.class.getName() + "$" + "InactiveRequestReader"; try { reader = (IRequestReader) Class.forName(className).newInstance(); } catch (Exception e1) { throw new ConfigurationException("Failed to instantiate class " + className, e1); } } ourRequestReader = reader; } try { InputStream inputStream = reader.getInputStream(this); requestContents = IOUtils.toByteArray(inputStream); if (myServer.isUncompressIncomingContents()) { String contentEncoding = myServletRequest.getHeader(Constants.HEADER_CONTENT_ENCODING); if ("gzip".equals(contentEncoding)) { ourLog.debug("Uncompressing (GZip) incoming content"); if (requestContents.length > 0) { GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(requestContents)); requestContents = IOUtils.toByteArray(gis); } } } return requestContents; } catch (IOException e) { ourLog.error("Could not load request resource", e); throw new InvalidRequestException(String.format("Could not load request resource: %s", e.getMessage())); } }