List of usage examples for org.springframework.beans.factory BeanCreationException printStackTrace
public void printStackTrace()
From source file:com.github.bfour.fpliteraturecollector.application.Application.java
public static void main(String[] args) { try {/*w ww . j ava 2s . co m*/ // https://vvirlan.wordpress.com/2014/12/10/solved-caused-by-java-awt-headlessexception-when-trying-to-create-a-swingawt-frame-from-spring-boot/ SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class); builder.headless(false); ConfigurableApplicationContext context = builder.run(args); // Neo4jResource myBean = context.getBean(Neo4jResource.class); // myBean.functionThatUsesTheRepo(); // ServiceManager servMan = ServiceManager // .getInstance(ServiceManagerMode.TEST); ServiceManager servMan = context.getBean(ServiceManager.class); context.getAutowireCapableBeanFactory().autowireBeanProperties(servMan, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true); FPJGUIManager.getInstance().initialize(); MainWindow.getInstance(servMan).setVisible(true); } catch (BeanCreationException e) { e.printStackTrace(); if (ExceptionUtils.getRootCause(e) instanceof IOException) ApplicationErrorDialogue.showMessage("Sorry, could not access the database.\n" + "This might be because it is currently in use or because there are insufficient access rights.\n" + "Try closing all running instances of this application and restart."); else ApplicationErrorDialogue.showDefaultMessage(e, BUG_REPORT_URL); } catch (Exception e) { e.printStackTrace(); ApplicationErrorDialogue.showDefaultMessage(e, BUG_REPORT_URL); } }
From source file:com.aan.girsang.server.launcher.ServerLauncher.java
public static void main(String[] args) { try {//from w w w . j a va 2 s.c o m AbstractApplicationContext ctx = new ClassPathXmlApplicationContext( new String[] { "applicationContext.xml", "serverContext.xml" }); ctx.registerShutdownHook(); log.info("SERVER ONLINE"); } catch (BeanCreationException bce) { JOptionPane.showMessageDialog(null, "Server Sudah Aktif"); bce.printStackTrace(); } }
From source file:org.springframework.beans.factory.xml.XmlBeanFactoryTests.java
@Test public void testFailsOnInnerBean() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf); reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE); reader.loadBeanDefinitions(REFTYPES_CONTEXT); try {/* w w w .j av a2 s . c om*/ xbf.getBean("failsOnInnerBean"); } catch (BeanCreationException ex) { // Check whether message contains outer bean name. ex.printStackTrace(); assertTrue(ex.getMessage().contains("failsOnInnerBean")); assertTrue(ex.getMessage().contains("someMap")); } try { xbf.getBean("failsOnInnerBeanForConstructor"); } catch (BeanCreationException ex) { // Check whether message contains outer bean name. ex.printStackTrace(); assertTrue(ex.getMessage().contains("failsOnInnerBeanForConstructor")); assertTrue(ex.getMessage().contains("constructor argument")); } }
From source file:org.springframework.beans.factory.xml.XmlBeanFactoryTests.java
@Test public void testRelatedCausesFromConstructorResolution() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); try {//w w w. ja v a2 s .c om xbf.getBean("rod2Accessor"); } catch (BeanCreationException ex) { assertTrue(ex.toString().indexOf("touchy") != -1); ex.printStackTrace(); assertNull(ex.getRelatedCauses()); } }
From source file:org.springframework.beans.factory.xml.XmlBeanFactoryTests.java
@Test public void testNonLenientDependencyMatching() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf.getBeanDefinition("lenientDependencyTestBean"); bd.setLenientConstructorResolution(false); try {//from w w w . j a v a2 s. c o m xbf.getBean("lenientDependencyTestBean"); fail("Should have thrown BeanCreationException"); } catch (BeanCreationException ex) { // expected ex.printStackTrace(); assertTrue(ex.getMostSpecificCause().getMessage().contains("Ambiguous")); } }
From source file:org.springframework.beans.factory.xml.XmlBeanFactoryTests.java
@Test public void testNonLenientDependencyMatchingFactoryMethod() { DefaultListableBeanFactory xbf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT); AbstractBeanDefinition bd = (AbstractBeanDefinition) xbf .getBeanDefinition("lenientDependencyTestBeanFactoryMethod"); bd.setLenientConstructorResolution(false); try {// ww w . j ava2s. c o m xbf.getBean("lenientDependencyTestBeanFactoryMethod"); fail("Should have thrown BeanCreationException"); } catch (BeanCreationException ex) { // expected ex.printStackTrace(); assertTrue(ex.getMostSpecificCause().getMessage().contains("Ambiguous")); } }