List of usage examples for org.springframework.beans BeansException getCause
public synchronized Throwable getCause()
From source file:be.hikage.springtemplate.TemplateTest.java
@Test public void testBad() { try {/*from w w w.j a v a 2s .c o m*/ ApplicationContext context = new ClassPathXmlApplicationContext("test-config-bad.xml", this.getClass()); fail("Exception must be thrown"); } catch (BeansException e) { assertTrue(e.getCause() instanceof BeanCreationException); } }
From source file:com.zigbee.framework.common.util.BeanCopyUtil.java
/** * Bean Copy Method/*from w ww. j a v a2s . co m*/ * @param srcBean source bean instance * @param destBean destination bean instance * @throws AppException Application Exception */ public static void beanCopy(Object srcBean, Object destBean) throws AppException { try { BeanUtils.copyProperties(srcBean, destBean); } catch (BeansException e) { e.printStackTrace(); String errMsg = "BEAN COPY Exception!" + e.getMessage() + e.getStackTrace(); throw new AppException(CommonErrorConstants.BEAN_COPY_EXCEPTION, errMsg, e.getCause()); } }
From source file:com.zigbee.framework.common.util.BeanCopyUtil.java
/** * ?/*from w w w. ja va 2 s. co m*/ * @author tun.tan * @Date 2011-9-29 ?11:18:42 */ public static void copyProps(Object source, Object target, String[] igonre) { Assert.notNull(source, "Source must not be null"); Assert.notNull(target, "Target must not be null"); Class<?> actualEditable = target.getClass(); PropertyDescriptor[] targetPds = getPropertyDescriptors(actualEditable); Object methodName = null; // Object targetValue=null; //? for (PropertyDescriptor targetPd : targetPds) { if (targetPd.getWriteMethod() != null) { try { PropertyDescriptor sourcePd = getPropertyDescriptor(source.getClass(), targetPd.getName()); if (igonre != null) { boolean jump = false; // for (int i = 0; i < igonre.length; i++) { if (igonre[i] == null) {// continue; } if (targetPd.getName().equals(igonre[i])) {//? logger.info(targetPd.getName()); jump = true; } } if (jump) {// continue; } } if (sourcePd != null && sourcePd.getReadMethod() != null) {// Method readMethod = sourcePd.getReadMethod(); if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) { readMethod.setAccessible(true); } Object value = readMethod.invoke(source); //Check whether the value is empty, only copy the properties which are not empty // targetValue=value; if (value != null) {// Method writeMethod = targetPd.getWriteMethod(); methodName = writeMethod.getName(); if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) { readMethod.setAccessible(true); } writeMethod.invoke(target, value); } } } catch (BeansException e) { e.printStackTrace(); String errMsg = "BEAN COPY Exception! methodName=" + methodName + " ;" + e.getMessage(); logger.error(errMsg); throw new ZigbeeSystemException("beanCopyException", errMsg, e.getCause()); } catch (SecurityException e) { e.printStackTrace(); String errMsg = "BEAN COPY Exception! methodName=" + methodName + " ;" + e.getMessage(); logger.error(errMsg); throw new ZigbeeSystemException("beanCopyException", errMsg, e.getCause()); } catch (IllegalArgumentException e) { e.printStackTrace(); String errMsg = "BEAN COPY Exception! methodName=" + methodName + " ;" + e.getMessage(); logger.error(errMsg); throw new ZigbeeSystemException("beanCopyException", errMsg, e.getCause()); } catch (IllegalAccessException e) { e.printStackTrace(); String errMsg = "BEAN COPY Exception! methodName=" + methodName + " ;" + e.getMessage(); logger.error(errMsg); throw new ZigbeeSystemException("beanCopyException", errMsg, e.getCause()); } catch (InvocationTargetException e) { e.printStackTrace(); String errMsg = "BEAN COPY Exception! methodName=" + methodName + " ;" + e.getMessage(); logger.error(errMsg); throw new ZigbeeSystemException("beanCopyException", errMsg, e.getCause()); } } } }
From source file:org.springframework.integration.config.ChainParserTests.java
@Test(expected = BeanCreationException.class) //INT-2275 public void invalidNestedChainWithLoggingChannelAdapter() { try {/*from w w w .ja v a 2s .c o m*/ new ClassPathXmlApplicationContext("invalidNestedChainWithOutboundChannelAdapter-context.xml", this.getClass()); fail("BeanCreationException is expected!"); } catch (BeansException e) { assertEquals(IllegalArgumentException.class, e.getCause().getClass()); assertTrue(e.getMessage().contains("output channel was provided")); assertTrue(e.getMessage().contains("does not implement the MessageProducer")); throw e; } }