List of usage examples for java.lang IllegalAccessException getCause
public synchronized Throwable getCause()
From source file:com.woodblockwithoutco.quickcontroldock.model.impl.actions.DataLollipopAction.java
@Override protected void performActionOn() { new AsyncTask<Void, Void, Void>() { @Override/* w w w . j av a 2 s. c o m*/ protected Void doInBackground(Void... args) { try { mToggleDataMethod.invoke(mTelephonyManager, true); } catch (IllegalAccessException e) { Log.e(TAG, "Inaccessible data toggle method"); } catch (IllegalArgumentException e) { Log.e(TAG, "Invalid data toggle method signature"); } catch (InvocationTargetException e) { e.printStackTrace(); Log.e(TAG, "Invalid data toggle method invocation target: " + e.getCause().getMessage()); } return null; } @Override protected void onPostExecute(Void result) { LocalBroadcastManager.getInstance(mContext).sendBroadcast(mBroadcastIntent); } }.execute(); }
From source file:org.ajax4jsf.component.UISelector.java
public void encodeAjaxChild(FacesContext context, String path, Set<String> ids, Set<String> renderedAreas) throws IOException { if (getChildCount() != 1) { throw new FacesException("Selector component must have one, and only one, child"); }/*from w w w.j a va 2s . co m*/ UIComponent child = (UIComponent) getChildren().get(0); Set<Object> ajaxKeys = getAjaxKeys(); if (null != ajaxKeys) { String iterationProperty = getIterationProperty(); try { Object savedKey = PropertyUtils.getProperty(child, iterationProperty); for (Iterator<Object> iter = ajaxKeys.iterator(); iter.hasNext();) { Object key = (Object) iter.next(); PropertyUtils.setProperty(child, iterationProperty, key); if (true) { childrenRenderer.encodeAjaxChildren(context, this, path, ids, renderedAreas); } } PropertyUtils.setProperty(child, iterationProperty, savedKey); } catch (IllegalAccessException e) { throw new FacesException("Illegal access to iteration selection property " + iterationProperty + " on component " + child.getClientId(context), e); } catch (InvocationTargetException e) { throw new FacesException("Error in iteration selection property " + iterationProperty + " on component " + child.getClientId(context), e.getCause()); } catch (NoSuchMethodException e) { throw new FacesException("No iteration selection property " + iterationProperty + " on component " + child.getClientId(context), e); } } }
From source file:org.grouplens.lenskit.eval.script.ConfigMethodInvoker.java
/** * Find a method that should be invoked multiple times, if the argument is iterable. The * argument may be iterated multiple times. * * @param self The configurable object.//from ww w . ja va 2 s. c o m * @param name The method name. * @param args The arguments. * @return A thunk that will invoke the method. */ private Supplier<Object> findMultiMethod(final Object self, String name, final Object[] args) { if (args.length != 1) return null; // the argument is a list final Object arg = args[0]; if (!(arg instanceof Iterable)) { return null; } final Iterable<?> objects = (Iterable<?>) arg; Supplier<Object> result = null; for (final Method method : getOneArgMethods(self, name)) { Class ptype = method.getParameterTypes()[0]; boolean good = Iterables.all(objects, Predicates.or(Predicates.isNull(), Predicates.instanceOf(ptype))); if (good) { if (result != null) { throw new RuntimeException("multiple compatible methods named " + name); } else { result = new Supplier<Object>() { @Override public Object get() { for (Object obj : objects) { try { method.invoke(self, obj); } catch (IllegalAccessException e) { throw Throwables.propagate(e); } catch (InvocationTargetException e) { if (e.getCause() != null) { throw Throwables.propagate(e); } } } return null; } }; } } } return result; }
From source file:r.jvmi.binding.JvmMethod.java
/** * Invokes the underlying static method// www .ja v a 2s . c o m * * @param arguments * @param <X> * @return */ public <X> X invoke(Object... arguments) { try { return (X) method.invoke(null, arguments); } catch (IllegalAccessException e) { throw new EvalException("Access exception while invoking method:\n" + method.toString(), e); } catch (InvocationTargetException e) { if (e.getCause() instanceof ControlFlowException) { throw (ControlFlowException) e.getCause(); } else if (e.getCause() instanceof EvalException) { // Rethrow eval Exceptions throw (EvalException) e.getCause(); } else { // wrap checked exceptions throw new EvalException(e.getCause()); } } catch (IllegalArgumentException e) { throw new EvalException("IllegalArgumentException while invoking " + method.toString()); } }
From source file:org.apache.hadoop.hive.serde2.protobuf.ProtobufSerDe.java
@Override public Object deserialize(Writable blob) throws SerDeException { BytesWritable bw = (BytesWritable) blob; if (bw.getSize() <= 0) { return null; }/*w ww . j a va 2 s .c o m*/ CodedInputStream cis = CodedInputStream.newInstance(bw.getBytes(), 0, bw.getSize()); Object message = null; try { message = parseFromMethod.invoke(null, cis); } catch (java.lang.IllegalAccessException e) { throw new SerDeException(e.getMessage()); } catch (java.lang.reflect.InvocationTargetException e) { String errmsg = e.getMessage(); Throwable cause = e.getCause(); if (cause instanceof InvalidProtocolBufferException) { errmsg = "__InvalidProtocolBufferException:" + errmsg; } throw new SerDeException(errmsg); } return message; }
From source file:org.ajax4jsf.renderkit.compiler.MethodCallElement.java
void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) { MethodCallElement._log.error(/*from ww w .jav a 2 s .com*/ Messages.getMessage(Messages.METHOD_CALL_ERROR_3a, methodName, context.getComponent().getId()), e); throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_4a, new Object[] { methodName, context.getComponent().getId(), e.getCause().getMessage() }), e); }
From source file:org.openmrs.logic.token.impl.TokenServiceImpl.java
/** * Calls provider.afterStartup() in a Daemon thread (or, if we are pre-OpenMRS 1.8 another way) * // w w w . j a v a 2 s . com * @param provider */ private void startupProviderAsDaemon(final RuleProvider provider) { try { Method m = Class.forName("org.openmrs.api.context.Daemon").getMethod("runInNewDaemonThread"); m.invoke(null, new Runnable() { public void run() { log.debug("Starting " + provider.getClass()); provider.afterStartup(); log.debug("Finished starting " + provider.getClass()); }; }); } catch (IllegalAccessException ex) { startupProviderWithoutDaemon(provider); } catch (IllegalArgumentException ex) { startupProviderWithoutDaemon(provider); } catch (ClassNotFoundException ex) { startupProviderWithoutDaemon(provider); } catch (NoSuchMethodException ex) { startupProviderWithoutDaemon(provider); } catch (InvocationTargetException ex) { log.error("Error starting " + provider.getClass(), ex.getCause()); } }
From source file:org.apache.tomee.embedded.TomEEEmbeddedApplicationRunner.java
public synchronized void start(final Class<?> marker, final Properties config, final String... args) throws Exception { if (started) { return;/*from w w w. j a v a 2 s . c om*/ } ensureAppInit(marker); started = true; final Class<?> appClass = app.getClass(); final AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(ancestors(appClass))); // setup the container config reading class annotation, using a randome http port and deploying the classpath final Configuration configuration = new Configuration(); final ContainerProperties props = appClass.getAnnotation(ContainerProperties.class); if (props != null) { final Properties runnerProperties = new Properties(); for (final ContainerProperties.Property p : props.value()) { final String name = p.name(); if (name.startsWith("tomee.embedded.application.runner.")) { // allow to tune the Configuration // no need to filter there since it is done in loadFromProperties() runnerProperties.setProperty(name.substring("tomee.embedded.application.runner.".length()), p.value()); } else { configuration.property(name, StrSubstitutor.replaceSystemProperties(p.value())); } } if (!runnerProperties.isEmpty()) { configuration.loadFromProperties(runnerProperties); } } configuration.loadFromProperties(System.getProperties()); // overrides, note that some config are additive by design final List<Method> annotatedMethods = finder .findAnnotatedMethods(org.apache.openejb.testing.Configuration.class); if (annotatedMethods.size() > 1) { throw new IllegalArgumentException("Only one @Configuration is supported: " + annotatedMethods); } for (final Method m : annotatedMethods) { final Object o = m.invoke(app); if (Properties.class.isInstance(o)) { final Properties properties = Properties.class.cast(o); if (configuration.getProperties() == null) { configuration.setProperties(new Properties()); } configuration.getProperties().putAll(properties); } else { throw new IllegalArgumentException("Unsupported " + o + " for @Configuration"); } } final Collection<org.apache.tomee.embedded.LifecycleTask> lifecycleTasks = new ArrayList<>(); final Collection<Closeable> postTasks = new ArrayList<>(); final LifecycleTasks tasks = appClass.getAnnotation(LifecycleTasks.class); if (tasks != null) { for (final Class<? extends org.apache.tomee.embedded.LifecycleTask> type : tasks.value()) { final org.apache.tomee.embedded.LifecycleTask lifecycleTask = type.newInstance(); lifecycleTasks.add(lifecycleTask); postTasks.add(lifecycleTask.beforeContainerStartup()); } } final Map<String, Field> ports = new HashMap<>(); { Class<?> type = appClass; while (type != null && type != Object.class) { for (final Field f : type.getDeclaredFields()) { final RandomPort annotation = f.getAnnotation(RandomPort.class); final String value = annotation == null ? null : annotation.value(); if (value != null && value.startsWith("http")) { f.setAccessible(true); ports.put(value, f); } } type = type.getSuperclass(); } } if (ports.containsKey("http")) { configuration.randomHttpPort(); } // at least after LifecycleTasks to inherit from potential states (system properties to get a port etc...) final Configurers configurers = appClass.getAnnotation(Configurers.class); if (configurers != null) { for (final Class<? extends Configurer> type : configurers.value()) { type.newInstance().configure(configuration); } } final Classes classes = appClass.getAnnotation(Classes.class); String context = classes != null ? classes.context() : ""; context = !context.isEmpty() && context.startsWith("/") ? context.substring(1) : context; Archive archive = null; if (classes != null && classes.value().length > 0) { archive = new ClassesArchive(classes.value()); } final Jars jars = appClass.getAnnotation(Jars.class); final List<URL> urls; if (jars != null) { final Collection<File> files = ApplicationComposers.findFiles(jars); urls = new ArrayList<>(files.size()); for (final File f : files) { urls.add(f.toURI().toURL()); } } else { urls = null; } final WebResource resources = appClass.getAnnotation(WebResource.class); if (resources != null && resources.value().length > 1) { throw new IllegalArgumentException("Only one docBase is supported for now using @WebResource"); } String webResource = null; if (resources != null && resources.value().length > 0) { webResource = resources.value()[0]; } else { final File webapp = new File("src/main/webapp"); if (webapp.isDirectory()) { webResource = "src/main/webapp"; } } if (config != null) { // override other config from annotations configuration.loadFromProperties(config); } final Container container = new Container(configuration); SystemInstance.get().setComponent(TomEEEmbeddedArgs.class, new TomEEEmbeddedArgs(args, null)); SystemInstance.get().setComponent(LifecycleTaskAccessor.class, new LifecycleTaskAccessor(lifecycleTasks)); container.deploy(new Container.DeploymentRequest(context, // call ClasspathSearcher that lazily since container needs to be started to not preload logging urls == null ? new DeploymentsResolver.ClasspathSearcher() .loadUrls(Thread.currentThread().getContextClassLoader()).getUrls() : urls, webResource != null ? new File(webResource) : null, true, null, archive)); for (final Map.Entry<String, Field> f : ports.entrySet()) { switch (f.getKey()) { case "http": setPortField(f.getKey(), f.getValue(), configuration, context, app); break; case "https": break; default: throw new IllegalArgumentException("port " + f.getKey() + " not yet supported"); } } SystemInstance.get().addObserver(app); composerInject(app); final AnnotationFinder appFinder = new AnnotationFinder(new ClassesArchive(appClass)); for (final Method mtd : appFinder.findAnnotatedMethods(PostConstruct.class)) { if (mtd.getParameterTypes().length == 0) { if (!mtd.isAccessible()) { mtd.setAccessible(true); } mtd.invoke(app); } } hook = new Thread() { @Override public void run() { // ensure to log errors but not fail there for (final Method mtd : appFinder.findAnnotatedMethods(PreDestroy.class)) { if (mtd.getParameterTypes().length == 0) { if (!mtd.isAccessible()) { mtd.setAccessible(true); } try { mtd.invoke(app); } catch (final IllegalAccessException e) { throw new IllegalStateException(e); } catch (final InvocationTargetException e) { throw new IllegalStateException(e.getCause()); } } } try { container.close(); } catch (final Exception e) { e.printStackTrace(); } for (final Closeable c : postTasks) { try { c.close(); } catch (final IOException e) { e.printStackTrace(); } } postTasks.clear(); app = null; try { SHUTDOWN_TASKS.remove(this); } catch (final Exception e) { // no-op: that's ok at that moment if not called manually } } }; SHUTDOWN_TASKS.put(hook, hook); }
From source file:de.fiz.ddb.aas.utils.LDAPEngineUtilityOrganisation.java
protected boolean organizationExists(String orgId) throws ExecutionException { NamingEnumeration<SearchResult> searchResults = null; try {// w w w . ja va 2 s. c om searchResults = this.query(LDAPConnector.getSingletonInstance().getInstitutionBaseDN(), new StringBuilder("(& (objectclass=").append(Constants.ldap_ddbOrg_ObjectClass).append(") (") .append(Constants.ldap_ddbOrg_Id).append("=").append(orgId).append("))").toString(), new String[] { Constants.ldap_ddbOrg_Id, "+" }, SearchControls.SUBTREE_SCOPE); if (searchResults.hasMore()) { return true; } else { return false; } } catch (IllegalAccessException ex) { LOG.log(Level.SEVERE, "Connection-Error", ex); throw new ExecutionException(ex.getMessage(), ex.getCause()); } catch (NamingException ne) { LOG.log(Level.SEVERE, "something went wrong while checking if userId exists", ne); throw new ExecutionException(ne.getMessage(), ne.getCause()); } finally { if (searchResults != null) { try { searchResults.close(); } catch (NamingException e) { } } } }
From source file:de.fiz.ddb.aas.utils.LDAPEngineUtilityOrganisation.java
protected boolean licensedOganizationExists(String orgId) throws ExecutionException { NamingEnumeration<SearchResult> searchResults = null; try {//ww w .ja v a 2 s.c o m searchResults = this.query(LDAPConnector.getSingletonInstance().getLicensedInstitutionsBaseDN(), new StringBuilder("(& (objectclass=").append(Constants.ldap_ddbOrg_ObjectClass).append(") (") .append(Constants.ldap_ddbOrg_Id).append("=").append(orgId).append("))").toString(), new String[] { Constants.ldap_ddbOrg_Id, "+" }, SearchControls.SUBTREE_SCOPE); if (searchResults.hasMore()) { return true; } else { return false; } } catch (IllegalAccessException ex) { LOG.log(Level.SEVERE, "Connection-Error", ex); throw new ExecutionException(ex.getMessage(), ex.getCause()); } catch (NamingException ne) { LOG.log(Level.SEVERE, "something went wrong while checking if userId exists", ne); throw new ExecutionException(ne.getMessage(), ne.getCause()); } finally { if (searchResults != null) { try { searchResults.close(); } catch (NamingException e) { } } } }