List of usage examples for java.lang IllegalAccessException getMessage
public String getMessage()
From source file:org.springframework.data.document.mongodb.convert.MappingMongoConverter.java
protected DBRef createDBRef(Object target, org.springframework.data.document.mongodb.mapping.DBRef dbref) { MongoPersistentEntity<?> targetEntity = mappingContext.getPersistentEntity(target.getClass()); if (null == targetEntity || null == targetEntity.getIdProperty()) { return null; }// w w w.j ava2 s . c om MongoPersistentProperty idProperty = targetEntity.getIdProperty(); ObjectId id = null; try { id = getProperty(target, idProperty, ObjectId.class, useFieldAccessOnly); if (null == id) { throw new MappingException("Cannot create a reference to an object with a NULL id."); } } catch (IllegalAccessException e) { throw new MappingException(e.getMessage(), e); } catch (InvocationTargetException e) { throw new MappingException(e.getMessage(), e); } String collection = dbref.collection(); if ("".equals(collection)) { collection = targetEntity.getType().getSimpleName().toLowerCase(); } String dbname = dbref.db(); if ("".equals(dbname)) { dbname = defaultDatabase; } DB db = mongo.getDB(dbname); return new DBRef(db, collection, id); }
From source file:com.maverick.ssl.SSLHandshakeProtocol.java
private void onServerHelloMsg(byte[] msg) throws SSLException { try {//from ww w.jav a 2 s .c o m ByteArrayInputStream in = new ByteArrayInputStream(msg); majorVersion = in.read(); minorVersion = in.read(); serverRandom = new byte[32]; in.read(serverRandom); sessionID = new byte[(in.read() & 0xFF)]; in.read(sessionID); cipherSuiteID = new SSLCipherSuiteID(in.read(), in.read()); pendingCipherSuite = (SSLCipherSuite) context.getCipherSuiteClass(cipherSuiteID).newInstance(); compressionID = in.read(); currentHandshakeStep = SERVER_HELLO_MSG; } catch (IllegalAccessException ex) { throw new SSLException(SSLException.INTERNAL_ERROR, ex.getMessage() == null ? ex.getClass().getName() : ex.getMessage()); } catch (InstantiationException ex) { throw new SSLException(SSLException.INTERNAL_ERROR, ex.getMessage() == null ? ex.getClass().getName() : ex.getMessage()); } catch (IOException ex) { throw new SSLException(SSLException.INTERNAL_ERROR, ex.getMessage() == null ? ex.getClass().getName() : ex.getMessage()); } }
From source file:org.ut.biolab.medsavant.MedSavantServlet.java
public String json_invoke(String adapter, String method, String jsonStr) throws IllegalArgumentException { adapter = adapter + "Adapter"; Field selectedAdapter = null; for (Field f : MedSavantServlet.class.getDeclaredFields()) { if (f.getType().getSimpleName().equalsIgnoreCase(adapter)) { selectedAdapter = f;//from ww w. j av a2s . co m } } if (selectedAdapter == null) { throw new IllegalArgumentException("The adapter " + adapter + " does not exist"); } JsonParser parser = new JsonParser(); JsonArray gArray = parser.parse(jsonStr).getAsJsonArray(); JsonElement jse = parser.parse(jsonStr); JsonArray jsonArray; if (jse.isJsonArray()) { jsonArray = jse.getAsJsonArray(); } else { throw new IllegalArgumentException("The json method arguments are not an array"); } Method selectedMethod = null; for (Method m : selectedAdapter.getType().getMethods()) { if (m.getName().equalsIgnoreCase(method) && m.getGenericParameterTypes().length == (jsonArray.size() + 1)) { selectedMethod = m; } } if (selectedMethod == null) { throw new IllegalArgumentException("The method " + method + " in adapter " + adapter + " with " + jsonArray.size() + " arguments does not exist"); } int i = 0; Object[] methodArgs = new Object[selectedMethod.getParameterTypes().length]; try { for (Type t : selectedMethod.getGenericParameterTypes()) { LOG.debug("Field " + i + " is " + t.toString() + " for method " + selectedMethod.toString()); methodArgs[i] = (i > 0) ? gson.fromJson(gArray.get(i - 1), t) : session.getSessionId(); ++i; } } catch (JsonParseException je) { LOG.error(je); } Object selectedAdapterInstance = null; try { selectedAdapterInstance = selectedAdapter.get(this); if (selectedAdapterInstance == null) { throw new NullPointerException( "Requested adapter " + selectedAdapter.getName() + " was not initialized."); } MethodInvocation methodInvocation = new MethodInvocation(session, gson, selectedAdapterInstance, selectedMethod, methodArgs); return methodInvocation.invoke(); } catch (IllegalAccessException iae) { throw new IllegalArgumentException("Couldn't execute method with given arguments: " + iae.getMessage()); } catch (LockException lex) { //this shouldn't happen, as locking exceptions can only be thrown by queued method invocations, which //are intercepted in the BlockingQueueManager. String msg = "Unexpected locking exception thrown in unqueued method invocation."; LOG.error(msg); throw new IllegalArgumentException(msg + ": " + lex.getMessage()); } }
From source file:org.suren.autotest.web.framework.settings.SettingUtil.java
/** * ??Page// w w w . j a va 2s .c om * * @param pageClsStr * @param dataSrcClsStr * @param ele */ private void parse(final String pageClsStr, String dataSrcClsStr, Element ele) throws Exception { final Object pageInstance = getBean(pageClsStr); final Class<?> pageCls = pageInstance.getClass(); String url = ele.attributeValue("url"); if (url != null) { BeanUtil.set(pageInstance, "url", url); } String paramPrefix = ele.attributeValue("paramPrefix", "param"); BeanUtil.set(pageInstance, "paramPrefix", paramPrefix); BeanUtil.set(pageInstance, "dataSource", dataSrcClsStr); ele.accept(new VisitorSupport() { @Override public void visit(Element node) { if (!"field".equals(node.getName())) { return; } String fieldName = node.attributeValue("name"); String byId = node.attributeValue("byId"); String byCss = node.attributeValue("byCss"); String byName = node.attributeValue("byName"); String byXpath = node.attributeValue("byXpath"); String byLinkText = node.attributeValue("byLinkText"); String byPartialLinkText = node.attributeValue("byPartialLinkText"); String byTagName = node.attributeValue("byTagName"); String data = node.attributeValue("data"); String type = node.attributeValue("type"); String strategy = node.attributeValue("strategy"); String paramPrefix = node.attributeValue("paramPrefix", "param"); String timeOut = node.attributeValue("timeout", "0"); if (fieldName == null || "".equals(fieldName)) { return; } AbstractElement ele = null; try { Method getterMethod = BeanUtils.findMethod(pageCls, "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1)); if (getterMethod != null) { ele = (AbstractElement) getterMethod.invoke(pageInstance); if (ele == null) { logger.error( String.format("element [%s] is null, maybe you not set autowired.", fieldName)); return; } if ("input".equals(type)) { Text text = (Text) ele; text.setValue(data); ele = text; } ele.setId(byId); ele.setName(byName); ele.setTagName(byTagName); ele.setXPath(byXpath); ele.setCSS(byCss); ele.setLinkText(byLinkText); ele.setPartialLinkText(byPartialLinkText); ele.setStrategy(strategy); ele.setParamPrefix(paramPrefix); ele.setTimeOut(Long.parseLong(timeOut)); } else { logger.error(String.format("page cls [%s], field [%s]", pageClsStr, fieldName)); } } catch (IllegalAccessException e) { logger.error(e.getMessage(), e); } catch (IllegalArgumentException e) { logger.error(e.getMessage(), e); } catch (InvocationTargetException e) { logger.error(e.getMessage(), e); } catch (ClassCastException e) { logger.error(String.format("fieldName [%s]", fieldName), e); } node.accept(new FieldLocatorsVisitor(ele)); } }); pageMap.put(pageClsStr, (Page) pageInstance); }
From source file:com.heyzap.cordova.ads.CDVHeyzapAbstractPlugin.java
@Override public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { try {/*from w w w .j a v a 2s.com*/ final Method actionMethod = this.getClass().getMethod(action, JSONArray.class, CallbackContext.class); if (actionMethod != null) { cordova.getThreadPool().execute(new Runnable() { @Override public void run() { try { actionMethod.invoke(CDVHeyzapAbstractPlugin.this, args, callbackContext); } catch (IllegalAccessException e) { String msg = "Unable to Invoke action: " + action + ". Illegal Access Exception."; Log.e(TAG, msg); e.printStackTrace(); callbackContext.error(msg); } catch (InvocationTargetException e) { String msg = "Unable to Invoke action: " + action; Log.e(TAG, msg); e.printStackTrace(); callbackContext.error(msg); } catch (Exception e) { String msg = "Could not run Heyzap Ads Method - SDK Error: " + e.getMessage(); Log.e(TAG, msg); e.printStackTrace(); callbackContext.error(msg); } } }); return true; } } catch (NoSuchMethodException e) { Log.e(TAG, "Action: " + action + " was not found."); } return false; }
From source file:org.projectforge.framework.persistence.database.XmlDump.java
/** * @param o1/* w w w . j a v a 2s.co m*/ * @param o2 * @param logDifference If true than the difference is logged. * @return True if the given objects are equal. */ private boolean equals(final Object o1, final Object o2, final boolean logDifference) { if (o1 == null) { final boolean equals = (o2 == null); if (equals == false && logDifference == true) { log.error("Value 1 is null and value 2 is " + o2); } return equals; } else if (o2 == null) { if (logDifference == true) { log.error("Value 2 is null and value 1 is " + o1); } return false; } final Class<?> cls1 = o1.getClass(); final Field[] fields = cls1.getDeclaredFields(); AccessibleObject.setAccessible(fields, true); for (final Field field : fields) { if (accept(field) == false) { continue; } try { final Object fieldValue1 = getValue(o1, o2, field); final Object fieldValue2 = getValue(o2, o1, field); if (field.getType().isPrimitive() == true) { if (ObjectUtils.equals(fieldValue2, fieldValue1) == false) { if (logDifference == true) { log.error("Field is different: " + field.getName() + "; value 1 '" + fieldValue1 + "' 2 '" + fieldValue2 + "'."); } return false; } continue; } else if (fieldValue1 == null) { if (fieldValue2 != null) { if (fieldValue2 instanceof Collection<?>) { if (CollectionUtils.isEmpty((Collection<?>) fieldValue2) == true) { // null is equals to empty collection in this case. return true; } } if (logDifference == true) { log.error("Field '" + field.getName() + "': value 1 '" + fieldValue1 + "' is different from value 2 '" + fieldValue2 + "'."); } return false; } } else if (fieldValue2 == null) { if (fieldValue1 != null) { if (logDifference == true) { log.error("Field '" + field.getName() + "': value 1 '" + fieldValue1 + "' is different from value 2 '" + fieldValue2 + "'."); } return false; } } else if (fieldValue1 instanceof Collection<?>) { final Collection<?> col1 = (Collection<?>) fieldValue1; final Collection<?> col2 = (Collection<?>) fieldValue2; if (col1.size() != col2.size()) { if (logDifference == true) { log.error("Field '" + field.getName() + "': colection's size '" + col1.size() + "' is different from collection's size '" + col2.size() + "'."); } return false; } if (equals(field, col1, col2, logDifference) == false || equals(field, col2, col1, logDifference) == false) { return false; } } else if (HibernateUtils.isEntity(fieldValue1.getClass()) == true) { if (fieldValue2 == null || ObjectUtils.equals(HibernateUtils.getIdentifier(fieldValue1), HibernateUtils.getIdentifier(fieldValue2)) == false) { if (logDifference == true) { log.error("Field '" + field.getName() + "': Hibernate object id '" + HibernateUtils.getIdentifier(fieldValue1) + "' is different from id '" + HibernateUtils.getIdentifier(fieldValue2) + "'."); } return false; } } else if (fieldValue1 instanceof BigDecimal) { if (fieldValue2 == null || ((BigDecimal) fieldValue1).compareTo((BigDecimal) fieldValue2) != 0) { if (logDifference == true) { log.error("Field '" + field.getName() + "': value 1 '" + fieldValue1 + "' is different from value 2 '" + fieldValue2 + "'."); } return false; } } else if (fieldValue1.getClass().isArray() == true) { if (ArrayUtils.isEquals(fieldValue1, fieldValue2) == false) { if (logDifference == true) { log.error("Field '" + field.getName() + "': value 1 '" + fieldValue1 + "' is different from value 2 '" + fieldValue2 + "'."); } return false; } } else if (ObjectUtils.equals(fieldValue2, fieldValue1) == false) { if (logDifference == true) { log.error("Field '" + field.getName() + "': value 1 '" + fieldValue1 + "' is different from value 2 '" + fieldValue2 + "'."); } return false; } } catch (final IllegalAccessException ex) { throw new InternalError("Unexpected IllegalAccessException: " + ex.getMessage()); } } return true; }
From source file:org.springframework.data.document.mongodb.convert.MappingMongoConverter.java
protected void writeInternal(final Object obj, final DBObject dbo, MongoPersistentEntity<?> entity) { if (obj == null) { return;/*from ww w. j a va 2s . co m*/ } if (null == entity) { throw new MappingException("No mapping metadata found for entity of type " + obj.getClass().getName()); } // Write the ID final MongoPersistentProperty idProperty = entity.getIdProperty(); if (!dbo.containsField("_id") && null != idProperty) { Object idObj; try { idObj = getProperty(obj, idProperty, Object.class, useFieldAccessOnly); } catch (IllegalAccessException e) { throw new MappingException(e.getMessage(), e); } catch (InvocationTargetException e) { throw new MappingException(e.getMessage(), e); } if (null != idObj) { dbo.put("_id", idObj); } else { if (!VALID_ID_TYPES.contains(idProperty.getType())) { throw new MappingException("Invalid data type " + idProperty.getType().getName() + " for Id property. Should be one of " + VALID_ID_TYPES); } } } // Write the properties entity.doWithProperties(new PropertyHandler<MongoPersistentProperty>() { public void doWithPersistentProperty(MongoPersistentProperty prop) { String name = prop.getName(); Class<?> type = prop.getType(); Object propertyObj; try { propertyObj = getProperty(obj, prop, type, useFieldAccessOnly); } catch (IllegalAccessException e) { throw new MappingException(e.getMessage(), e); } catch (InvocationTargetException e) { throw new MappingException(e.getMessage(), e); } if (null != propertyObj) { if (!isSimpleType(propertyObj.getClass())) { writePropertyInternal(prop, propertyObj, dbo); } else { dbo.put(name, propertyObj); } } } }); entity.doWithAssociations(new AssociationHandler<MongoPersistentProperty>() { public void doWithAssociation(Association<MongoPersistentProperty> association) { MongoPersistentProperty inverseProp = association.getInverse(); Class<?> type = inverseProp.getType(); Object propertyObj; try { propertyObj = getProperty(obj, inverseProp, type, useFieldAccessOnly); } catch (IllegalAccessException e) { throw new MappingException(e.getMessage(), e); } catch (InvocationTargetException e) { throw new MappingException(e.getMessage(), e); } if (null != propertyObj) { writePropertyInternal(inverseProp, propertyObj, dbo); } } }); }
From source file:org.springframework.data.document.mongodb.convert.MappingMongoConverter.java
private <S extends Object> S read(final MongoPersistentEntity<S> entity, final DBObject dbo) { final StandardEvaluationContext spelCtx = new StandardEvaluationContext(); if (null != applicationContext) { spelCtx.setBeanResolver(new BeanFactoryResolver(applicationContext)); }//from www . ja v a 2 s .c om if (!(dbo instanceof BasicDBList)) { String[] keySet = dbo.keySet().toArray(new String[] {}); for (String key : keySet) { spelCtx.setVariable(key, dbo.get(key)); } } final List<String> ctorParamNames = new ArrayList<String>(); final MongoPersistentProperty idProperty = entity.getIdProperty(); final S instance = constructInstance(entity, new PreferredConstructor.ParameterValueProvider() { @SuppressWarnings("unchecked") public <T> T getParameterValue(PreferredConstructor.Parameter<T> parameter) { String name = parameter.getName(); TypeInformation<T> type = parameter.getType(); Class<T> rawType = parameter.getRawType(); String key = idProperty == null ? name : idProperty.getName().equals(name) ? idProperty.getKey() : name; Object obj = dbo.get(key); ctorParamNames.add(name); if (obj instanceof DBRef) { return read(type, ((DBRef) obj).fetch()); } else if (obj instanceof BasicDBList) { BasicDBList objAsDbList = (BasicDBList) obj; List<?> l = unwrapList(objAsDbList, type); return conversionService.convert(l, rawType); } else if (obj instanceof DBObject) { return read(type, ((DBObject) obj)); } else if (null != obj && obj.getClass().isAssignableFrom(rawType)) { return (T) obj; } else if (null != obj) { return conversionService.convert(obj, rawType); } return null; } }, spelCtx); // Set properties not already set in the constructor entity.doWithProperties(new PropertyHandler<MongoPersistentProperty>() { public void doWithPersistentProperty(MongoPersistentProperty prop) { boolean isConstructorProperty = ctorParamNames.contains(prop.getName()); boolean hasValueForProperty = dbo.containsField(prop.getKey()); if (!hasValueForProperty || isConstructorProperty) { return; } Object obj = getValueInternal(prop, dbo, spelCtx, prop.getSpelExpression()); try { setProperty(instance, prop, obj, useFieldAccessOnly); } catch (IllegalAccessException e) { throw new MappingException(e.getMessage(), e); } catch (InvocationTargetException e) { throw new MappingException(e.getMessage(), e); } } }); // Handle associations entity.doWithAssociations(new AssociationHandler<MongoPersistentProperty>() { public void doWithAssociation(Association<MongoPersistentProperty> association) { MongoPersistentProperty inverseProp = association.getInverse(); Object obj = getValueInternal(inverseProp, dbo, spelCtx, inverseProp.getSpelExpression()); try { setProperty(instance, inverseProp, obj); } catch (IllegalAccessException e) { throw new MappingException(e.getMessage(), e); } catch (InvocationTargetException e) { throw new MappingException(e.getMessage(), e); } } }); return instance; }
From source file:com.zenesis.qx.remote.ProxySessionTracker.java
/** * Called to create a new instance of the bootstrap class * @return//from w w w . java 2 s .c om */ protected Proxied createBootstrap() { try { return bootstrapClass.newInstance(); } catch (IllegalAccessException e) { throw new IllegalStateException( "Cannot create bootstrap instance from " + bootstrapClass + ": " + e.getMessage()); } catch (InstantiationException e) { Throwable t = (Throwable) e; throw new IllegalStateException( "Cannot create bootstrap instance from " + bootstrapClass + ": " + t.getMessage(), t); } }
From source file:com.google.gsa.valve.rootAuth.RootAuthorizationProcess.java
/** * Gets the authorization process instance needed to process the request * /*www. j a v a 2 s. c o m*/ * @param repository the repository configuration information * * @return the authorization class */ private AuthorizationProcessImpl getAuthorizationProcess(ValveRepositoryConfiguration repository) { AuthorizationProcessImpl authProcess = null; //protection if (repository != null) { try { String authZComponent = repository.getAuthZ(); logger.debug("Authorization module is: " + authZComponent); if (authZComponent != null) { authProcess = (AuthorizationProcessImpl) Class.forName(authZComponent).newInstance(); authProcess.setValveConfiguration(valveConf); } else { logger.debug("This repository[" + repository.getId() + "] does not cointain any Authorization class"); } } catch (LinkageError le) { logger.error(repository.getId() + " - Can't instantiate class [AuthorizationProcess-LinkageError]: " + le.getMessage(), le); authProcess = null; } catch (InstantiationException ie) { logger.error(repository.getId() + " - Can't instantiate class [AuthorizationProcess-InstantiationException]: " + ie.getMessage(), ie); authProcess = null; } catch (IllegalAccessException iae) { logger.error(repository.getId() + " - Can't instantiate class [AuthorizationProcess-IllegalAccessException]: " + iae.getMessage(), iae); authProcess = null; } catch (ClassNotFoundException cnfe) { logger.error(repository.getId() + " - Can't instantiate class [AuthorizationProcess-ClassNotFoundException]: " + cnfe.getMessage(), cnfe); authProcess = null; } catch (Exception e) { logger.error(repository.getId() + " - Can't instantiate class [AuthorizationProcess-Exception]: " + e.getMessage(), e); authProcess = null; } } return authProcess; }