List of usage examples for java.lang NoSuchFieldException getMessage
public String getMessage()
From source file:org.kuali.rice.core.framework.persistence.jpa.metadata.MetadataManager.java
/** * Retrieves the primary key as an object for the given Object (which is assumed to be a JPA entity), filling it with values from the extension. * If the entity has a single field primary key, the value of that field from the extension is returned. If a composite key is needed, it will be * constructed (based on the id class for the extension object) and populated with the correct values from the extension. If a problem occurs, * a null will be returned.//from w ww .j av a2 s .c om * * @param owner the object to get values from * @param extension the object to build a key for * @return a primary key value */ public static Object getPersistableBusinessObjectPrimaryKeyObjectWithValuesForExtension(Object owner, Object extension) { final EntityDescriptor descriptor = getEntityDescriptor(extension.getClass()); final Class idClass = descriptor.getIdClass(); if (idClass != null) { try { Object pkObject = idClass.newInstance(); for (FieldDescriptor fieldDescriptor : descriptor.getPrimaryKeys()) { Field field = getField(owner.getClass(), fieldDescriptor.getName()); field.setAccessible(true); final Object value = field.get(owner); if (value != null) { final Field fieldToSet = getField(pkObject.getClass(), fieldDescriptor.getName()); fieldToSet.setAccessible(true); fieldToSet.set(pkObject, value); } } return pkObject; } catch (SecurityException se) { LOG.error(se.getMessage(), se); } catch (InstantiationException ie) { LOG.error(ie.getMessage(), ie); } catch (IllegalAccessException iae) { LOG.error(iae.getMessage(), iae); } catch (NoSuchFieldException nsfe) { LOG.error(nsfe.getMessage(), nsfe); } } else { for (FieldDescriptor fieldDescriptor : descriptor.getPrimaryKeys()) { try { Field field = getField(owner.getClass(), fieldDescriptor.getName()); field.setAccessible(true); final Object value = field.get(owner); return value; // there's only one value, let's kick out } catch (Exception e) { LOG.error(e.getMessage(), e); } } } return null; }
From source file:Browser.java
/** * Called by a static initializer to load any classes, fields, and methods * required at runtime to locate the user's web browser. * @return <code>true</code> if all intialization succeeded * <code>false</code> if any portion of the initialization failed *//*from w w w . ja va2s . co m*/ private static boolean loadClasses() { switch (jvm) { case MRJ_2_0: try { Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent"); Class aeClass = Class.forName("com.apple.MacOS.ae"); aeDescClass = Class.forName("com.apple.MacOS.AEDesc"); aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class[] { int.class }); appleEventConstructor = appleEventClass.getDeclaredConstructor( new Class[] { int.class, int.class, aeTargetClass, int.class, int.class }); aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[] { String.class }); makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class[] { String.class }); putParameter = appleEventClass.getDeclaredMethod("putParameter", new Class[] { int.class, aeDescClass }); sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[] {}); Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject"); keyDirectObject = (Integer) keyDirectObjectField.get(null); Field autoGenerateReturnIDField = appleEventClass.getDeclaredField("kAutoGenerateReturnID"); kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null); Field anyTransactionIDField = appleEventClass.getDeclaredField("kAnyTransactionID"); kAnyTransactionID = (Integer) anyTransactionIDField.get(null); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (NoSuchFieldException nsfe) { errorMessage = nsfe.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_2_1: try { mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType"); Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType"); kSystemFolderType = systemFolderField.get(null); findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[] { mrjOSTypeClass }); getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", new Class[] { File.class }); getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[] { File.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchFieldException nsfe) { errorMessage = nsfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (SecurityException se) { errorMessage = se.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_3_0: try { Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); Constructor constructor = linker.getConstructor(new Class[] { Class.class }); linkage = constructor.newInstance(new Object[] { Browser.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (InvocationTargetException ite) { errorMessage = ite.getMessage(); return false; } catch (InstantiationException ie) { errorMessage = ie.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_3_1: try { mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", new Class[] { String.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } break; default: break; } return true; }
From source file:fxts.stations.util.BrowserLauncher.java
/** * Called by a static initializer to load any classes, fields, and methods required at runtime * to locate the user's web browser.//from w ww. ja v a 2 s .c om * * @return <code>true</code> if all intialization succeeded * <code>false</code> if any portion of the initialization failed */ private static boolean loadClasses() { switch (jvm) { case MRJ_2_0: try { Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent"); Class aeClass = Class.forName("com.apple.MacOS.ae"); aeDescClass = Class.forName("com.apple.MacOS.AEDesc"); aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class[] { int.class }); appleEventConstructor = appleEventClass.getDeclaredConstructor( new Class[] { int.class, int.class, aeTargetClass, int.class, int.class }); aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[] { String.class }); makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class[] { String.class }); putParameter = appleEventClass.getDeclaredMethod("putParameter", new Class[] { int.class, aeDescClass }); sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[] {}); Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject"); keyDirectObject = (Integer) keyDirectObjectField.get(null); Field autoGenerateReturnIDField = appleEventClass.getDeclaredField("kAutoGenerateReturnID"); kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null); Field anyTransactionIDField = appleEventClass.getDeclaredField("kAnyTransactionID"); kAnyTransactionID = (Integer) anyTransactionIDField.get(null); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (NoSuchFieldException nsfe) { errorMessage = nsfe.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_2_1: try { mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType"); Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType"); kSystemFolderType = systemFolderField.get(null); findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[] { mrjOSTypeClass }); getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", new Class[] { File.class }); getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[] { File.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchFieldException nsfe) { errorMessage = nsfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (SecurityException se) { errorMessage = se.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_3_0: try { Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); Constructor constructor = linker.getConstructor(new Class[] { Class.class }); linkage = constructor.newInstance(new Object[] { BrowserLauncher.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (InvocationTargetException ite) { errorMessage = ite.getMessage(); return false; } catch (InstantiationException ie) { errorMessage = ie.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_3_1: try { mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", new Class[] { String.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } break; default: break; } return true; }
From source file:android.hawkencompanionapp.fragments.MechGuideFragment.java
@Override public void onDetach() { super.onDetach(); try {/* w w w. j a v a 2 s . c om*/ final Field childFragmentManager = Fragment.class.getDeclaredField("mChildFragmentManager"); childFragmentManager.setAccessible(true); childFragmentManager.set(this, null); } catch (NoSuchFieldException e) { Logger.error(this, e.getMessage()); } catch (IllegalAccessException e) { Logger.error(this, e.getMessage()); } }
From source file:org.musicrecital.webapp.taglib.ConstantsTag.java
/** * Main method that does processing and exposes Constants in specified scope * @return int//from ww w . j av a 2s . c o m * @throws JspException if processing fails */ @Override public int doStartTag() throws JspException { // Using reflection, get the available field names in the class Class c = null; int toScope = PageContext.PAGE_SCOPE; if (scope != null) { toScope = getScope(scope); } try { c = Class.forName(clazz); } catch (ClassNotFoundException cnf) { log.error("ClassNotFound - maybe a typo?"); throw new JspException(cnf.getMessage()); } try { // if var is null, expose all variables if (var == null) { Field[] fields = c.getDeclaredFields(); AccessibleObject.setAccessible(fields, true); for (Field field : fields) { pageContext.setAttribute(field.getName(), field.get(this), toScope); } } else { try { Object value = c.getField(var).get(this); pageContext.setAttribute(c.getField(var).getName(), value, toScope); } catch (NoSuchFieldException nsf) { log.error(nsf.getMessage()); throw new JspException(nsf); } } } catch (IllegalAccessException iae) { log.error("Illegal Access Exception - maybe a classloader issue?"); throw new JspException(iae); } // Continue processing this page return (SKIP_BODY); }
From source file:org.openhie.openempi.webapp.taglib.ConstantsTag.java
/** * Main method that does processing and exposes Constants in specified scope * @return int// w w w .j av a 2s . c o m * @throws JspException if processing fails */ @SuppressWarnings("unchecked") @Override public int doStartTag() throws JspException { // Using reflection, get the available field names in the class Class c = null; int toScope = PageContext.PAGE_SCOPE; if (scope != null) { toScope = getScope(scope); } try { c = Class.forName(clazz); } catch (ClassNotFoundException cnf) { log.error("ClassNotFound - maybe a typo?"); throw new JspException(cnf.getMessage()); } try { // if var is null, expose all variables if (var == null) { Field[] fields = c.getDeclaredFields(); AccessibleObject.setAccessible(fields, true); for (Field field : fields) { pageContext.setAttribute(field.getName(), field.get(this), toScope); } } else { try { Object value = c.getField(var).get(this); pageContext.setAttribute(c.getField(var).getName(), value, toScope); } catch (NoSuchFieldException nsf) { log.error(nsf.getMessage()); throw new JspException(nsf); } } } catch (IllegalAccessException iae) { log.error("Illegal Access Exception - maybe a classloader issue?"); throw new JspException(iae); } // Continue processing this page return (SKIP_BODY); }
From source file:ubic.gemma.web.taglib.ConstantsTag.java
@Override public int doStartTag() throws JspException { // Using reflection, get the available field names in the class Class<?> c;//from ww w . j a va 2 s . com int toScope = PageContext.PAGE_SCOPE; if (scope != null) { toScope = getScope(scope); } try { c = Class.forName(clazz); } catch (ClassNotFoundException cnf) { log.error("ClassNotFound - maybe a typo?"); throw new JspException(cnf.getMessage()); } try { // if var is null, expose all variables if (var == null) { Field[] fields = c.getDeclaredFields(); AccessibleObject.setAccessible(fields, true); for (Field field : fields) { /* * if (log.isDebugEnabled()) { log.debug("putting '" + fields[i].getName() + "=" + * fields[i].get(this) + "' into " + scope + " scope"); } */ pageContext.setAttribute(field.getName(), field.get(this), toScope); } } else { try { String value = (String) c.getField(var).get(this); pageContext.setAttribute(c.getField(var).getName(), value, toScope); } catch (NoSuchFieldException nsf) { log.error(nsf.getMessage()); throw new JspException(nsf); } } } catch (IllegalAccessException iae) { log.error("Illegal Access Exception - maybe a classloader issue?"); throw new JspException(iae); } // Continue processing this page return (SKIP_BODY); }
From source file:com.gisgraphy.webapp.taglib.ConstantsTag.java
/** * Main method that does processing and exposes Constants in specified scope * //from ww w . j av a2 s . c o m * @return int * @throws JspException * if processing fails */ @Override public int doStartTag() throws JspException { // Using reflection, get the available field names in the class Class<?> c = null; int toScope = PageContext.PAGE_SCOPE; if (scope != null) { toScope = getScope(scope); } try { c = Class.forName(clazz); } catch (ClassNotFoundException cnf) { log.error("ClassNotFound - maybe a typo?"); throw new JspException(cnf.getMessage()); } try { // if var is null, expose all variables if (var == null) { Field[] fields = c.getDeclaredFields(); AccessibleObject.setAccessible(fields, true); for (Field field : fields) { pageContext.setAttribute(field.getName(), field.get(this), toScope); } } else { try { Object value = c.getField(var).get(this); pageContext.setAttribute(c.getField(var).getName(), value, toScope); } catch (NoSuchFieldException nsf) { log.error(nsf.getMessage()); throw new JspException(nsf); } } } catch (IllegalAccessException iae) { log.error("Illegal Access Exception - maybe a classloader issue?"); throw new JspException(iae); } // Continue processing this page return (SKIP_BODY); }
From source file:alpha.portal.webapp.taglib.ConstantsTag.java
/** * Main method that does processing and exposes Constants in specified * scope.//from w ww. ja va2 s .com * * @return int * @throws JspException * if processing fails */ @Override public int doStartTag() throws JspException { // Using reflection, get the available field names in the class Class c = null; int toScope = PageContext.PAGE_SCOPE; if (this.scope != null) { toScope = this.getScope(this.scope); } try { c = Class.forName(this.clazz); } catch (final ClassNotFoundException cnf) { this.log.error("ClassNotFound - maybe a typo?"); throw new JspException(cnf.getMessage()); } try { // if var is null, expose all variables if (this.var == null) { final Field[] fields = c.getDeclaredFields(); AccessibleObject.setAccessible(fields, true); for (final Field field : fields) { this.pageContext.setAttribute(field.getName(), field.get(this), toScope); } } else { try { final Object value = c.getField(this.var).get(this); this.pageContext.setAttribute(c.getField(this.var).getName(), value, toScope); } catch (final NoSuchFieldException nsf) { this.log.error(nsf.getMessage()); throw new JspException(nsf); } } } catch (final IllegalAccessException iae) { this.log.error("Illegal Access Exception - maybe a classloader issue?"); throw new JspException(iae); } // Continue processing this page return (Tag.SKIP_BODY); }
From source file:org.orekit.frames.TidalCorrectionTest.java
/** * Disables the internal TimeStampedCache for validation purposes. * For this purpose the newSlotInterval is set to a very low value (1 min), so that * every time new tidal correction data has to be created, a new slot is used. * @param tc the {@link TidalCorrection} object for which the cache shall be disabled *//*from w w w .j a va 2s. c o m*/ private void disableTimeStampedCache(final TidalCorrection tc) { try { Class<?> clazz = tc.getClass(); Field field = clazz.getDeclaredField("cache"); field.setAccessible(true); @SuppressWarnings("rawtypes") TimeStampedCache<?> cache = (TimeStampedCache) field.get(tc); clazz = cache.getClass(); field = clazz.getDeclaredField("newSlotQuantumGap"); field.setAccessible(true); field.set(cache, FastMath.round(60 / 1e-6)); } catch (IllegalAccessException iae) { Assert.fail(iae.getMessage()); } catch (NoSuchFieldException nfe) { Assert.fail(nfe.getMessage()); } }