Search in sources :

Example 31 with BeanCreationException

use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.

the class GatewayMessageHandler method initialize.

private void initialize() {
    BeanFactory beanFactory = getBeanFactory();
    if (beanFactory instanceof ConfigurableListableBeanFactory) {
        ((ConfigurableListableBeanFactory) beanFactory).initializeBean(this.gatewayProxyFactoryBean, null);
    }
    try {
        this.exchanger = (RequestReplyExchanger) this.gatewayProxyFactoryBean.getObject();
    } catch (Exception e) {
        throw new BeanCreationException("Can't instantiate the GatewayProxyFactoryBean: " + this, e);
    }
    if (this.running) {
        // We must stop gatewayProxyFactoryBean because after the normal start its "gatewayMap" is still empty
        this.gatewayProxyFactoryBean.stop();
        this.gatewayProxyFactoryBean.start();
    }
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) BeanFactory(org.springframework.beans.factory.BeanFactory) ConfigurableListableBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory) ConfigurableListableBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory) BeanCreationException(org.springframework.beans.factory.BeanCreationException)

Example 32 with BeanCreationException

use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.

the class MessagingAnnotationsWithBeanAnnotationTests method testInvalidMessagingAnnotationsConfig.

@Test
public void testInvalidMessagingAnnotationsConfig() {
    try {
        new AnnotationConfigApplicationContext(InvalidContextConfiguration.class).close();
        fail("BeanCreationException expected");
    } catch (Exception e) {
        assertThat(e, instanceOf(BeanCreationException.class));
        assertThat(e.getCause(), instanceOf(BeanDefinitionValidationException.class));
        assertThat(e.getMessage(), containsString("The attribute causing the ambiguity is: [applySequence]."));
    }
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) BeanDefinitionValidationException(org.springframework.beans.factory.support.BeanDefinitionValidationException) BeanCreationException(org.springframework.beans.factory.BeanCreationException) MessageRejectedException(org.springframework.integration.MessageRejectedException) Test(org.junit.Test)

Example 33 with BeanCreationException

use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.

the class AggregatorParserTests method testMissingReleaseStrategyDefinition.

@Test
public void testMissingReleaseStrategyDefinition() {
    try {
        new ClassPathXmlApplicationContext("ReleaseStrategyMethodWithMissingReference.xml", this.getClass()).close();
        fail("Expected exception");
    } catch (BeanCreationException e) {
        assertThat(e.getMessage(), containsString("No bean named 'testReleaseStrategy' available"));
    }
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Test(org.junit.Test)

Example 34 with BeanCreationException

use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.

the class AggregatorParserTests method testAggregatorWithInvalidReleaseStrategyMethod.

@Test
public void testAggregatorWithInvalidReleaseStrategyMethod() {
    try {
        new ClassPathXmlApplicationContext("invalidReleaseStrategyMethod.xml", this.getClass()).close();
        fail("Expected exception");
    } catch (BeanCreationException e) {
        assertThat(e.getMessage(), containsString("TestReleaseStrategy] has no eligible methods"));
    }
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Test(org.junit.Test)

Example 35 with BeanCreationException

use of org.springframework.beans.factory.BeanCreationException in project spring-integration by spring-projects.

the class AggregatorParserTests method testMissingMethodOnAggregator.

@Test
public void testMissingMethodOnAggregator() {
    try {
        new ClassPathXmlApplicationContext("invalidMethodNameAggregator.xml", this.getClass()).close();
        fail("Expected exception");
    } catch (BeanCreationException e) {
        assertThat(e.getMessage(), containsString("Adder] has no eligible methods"));
    }
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Test(org.junit.Test)

Aggregations

BeanCreationException (org.springframework.beans.factory.BeanCreationException)133 Test (org.junit.Test)30 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)18 BeansException (org.springframework.beans.BeansException)16 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)13 IOException (java.io.IOException)12 Map (java.util.Map)12 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)12 Test (org.junit.jupiter.api.Test)11 HashMap (java.util.HashMap)9 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)9 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)8 ArrayList (java.util.ArrayList)7 PostConstruct (javax.annotation.PostConstruct)7 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)7 Bean (org.springframework.context.annotation.Bean)7 HasId (org.apache.camel.spi.HasId)6 BeanCurrentlyInCreationException (org.springframework.beans.factory.BeanCurrentlyInCreationException)6 BeanDefinitionStoreException (org.springframework.beans.factory.BeanDefinitionStoreException)6 BeanWrapperImpl (org.springframework.beans.BeanWrapperImpl)5