title: Spring configuration default mail poller more than one
body: <p>So guys, I have very strange error with my <code>SpringAppContext.xml</code>.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
      xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
      xmlns:util="http://www.springframework.org/schema/util" xmlns:jee="http://www.springframework.org/schema/jee"
      xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
          http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.2.xsd
          http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.2.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"&gt;
  
      &lt;jee:jndi-lookup id="configUrl" jndi-name="url/config"
          lookup-on-startup="true" /&gt;
  
      &lt;bean class="org.springframework.beans.factory.config.PropertiesFactoryBean"
          name="mailProperties"&gt;
          &lt;property name="location"&gt;
              &lt;!-- Generate a UrlResource from the java.net.Url --&gt;
              &lt;bean class="org.springframework.core.io.UrlResource"&gt;
                  &lt;constructor-arg  value="#{configUrl.toExternalForm() + '/mail.properties'}"/&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean class="...app.util.PropertyHolderBean" name="propertyHolder"&gt;
          &lt;constructor-arg ref="mailProperties"/&gt; 
      &lt;/bean&gt;
  
      &lt;int:channel id="inputMailChannel" datatype="javax.mail.internet.MimeMessage"&gt;
          &lt;int:queue capacity="25" /&gt;
      &lt;/int:channel&gt;
  
      &lt;util:properties id="javaMailProperties"&gt;
          &lt;prop key="mail.imap.socketFactory.class"&gt;#{propertyHolder.get('mail.imap.socketFactory.class')}&lt;/prop&gt;
          &lt;prop key="mail.imap.socketFactory.fallback"&gt;#{propertyHolder.get('mail.imap.socketFactory.fallback')}&lt;/prop&gt;
          &lt;prop key="mail.store.protocol"&gt;#{propertyHolder.get('mail.store.protocol')}&lt;/prop&gt;
          &lt;prop key="mail.imaps.partialfetch"&gt;#{propertyHolder.get('mail.imaps.partialfetch')}&lt;/prop&gt;
          &lt;prop key="mail.debug"&gt;#{propertyHolder.get('mail.debug')}&lt;/prop&gt;
      &lt;/util:properties&gt;
  
      &lt;int-mail:inbound-channel-adapter id="imapAdapterAuto"
          store-uri="#{propertyHolder.get('imap.uri')}" java-mail-properties="javaMailProperties"
          channel="inputMailChannel" should-delete-messages="false"
          should-mark-messages-as-read="true" auto-startup="#{propertyHolder.get('mail.emailApprovalEnabled')}"
          search-term-strategy="searchTermStrategy"&gt;
          &lt;int:poller max-messages-per-poll="#{propertyHolder.get('mail.messages.perpoll')}" fixed-rate="#{propertyHolder.get('mail.poll.rate')}" /&gt;
      &lt;/int-mail:inbound-channel-adapter&gt;
  
      &lt;int-mail:inbound-channel-adapter should-delete-messages="true" id="cleanMailboxAdapter" 
          store-uri="#{propertyHolder.get('imap.uri')}" 
          java-mail-properties="javaMailProperties" channel="inputMailChannel" 
          auto-startup="#{propertyHolder.get('mail.cleanup.enabled')}" 
          mail-filter-expression="subject matches '(?i)^((?!#{propertyHolder.get('mail.uniqueAppInstanceId')}).)*$'"&gt;
          &lt;int:poller max-messages-per-poll="25" fixed-rate="#{propertyHolder.get('mail.cleanup.rate')}" /&gt;
      &lt;/int-mail:inbound-channel-adapter&gt;
  
      &lt;bean id="searchTermStrategy"
          class="...mail.search.MailSubjectSearchStrategy"&gt;
          &lt;constructor-arg name="subjPattern" value="#{propertyHolder.get('mail.uniqueAppInstanceId')}"/&gt; 
      &lt;/bean&gt;
  
      &lt;int:service-activator input-channel="inputMailChannel"
          ref="inputMailProcessor" method="processIncomingMail" output-channel="outboundMailChanel" /&gt;
  
      &lt;int:poller default="true" max-messages-per-poll="100"
          fixed-delay="10000"&gt;
      &lt;/int:poller&gt;
  
      &lt;jee:jndi-lookup id="mailSession" jndi-name="java:comp/env/mail/Session" /&gt;
  
      &lt;bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"&gt;
          &lt;property name="session" ref="mailSession" /&gt;
      &lt;/bean&gt;
  
      &lt;int:channel id="outboundMailChanel" /&gt;
  
      &lt;int-mail:outbound-channel-adapter
          channel="outboundMailChanel" mail-sender="mailSender" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>There is a <code>poller</code>, ONE default <code>POLLER</code>, but compiler is throwing an error that my context contains more than one <code>poller</code>. How it's possible? I think so it's some kind of bug. 
   Help me please, if someone met it.</p>
  
  <pre><code>java.lang.IllegalStateException: Failed to load ApplicationContext
      at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99)
      at org.springframework.test.context.DefaultTestContext.getApplicationContext(DefaultTestContext.java:101)
      at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
      at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
      at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:331)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:213)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:290)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:292)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:233)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:176)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
  Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/spring/applicationContextMail.xml]
  Offending resource: class path resource [test-context.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Configuration problem: Only one default &lt;poller/&gt; element is allowed per context.
  Offending resource: class path resource [META-INF/spring/applicationContextMail.xml]
  Offending resource: class path resource [META-INF/spring/applicationContextMail.xml]
      at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
      at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
      at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:248)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:199)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:141)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
      at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromImportedResources(ConfigurationClassBeanDefinitionReader.java:313)
      at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:138)
      at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116)
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:330)
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243)
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
      at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:125)
      at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
      at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:100)
      at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:250)
      at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:64)
      at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91)
      ... 23 more
  Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Configuration problem: Only one default &lt;poller/&gt; element is allowed per context.
  Offending resource: class path resource [META-INF/spring/applicationContextMail.xml]
  Offending resource: class path resource [META-INF/spring/applicationContextMail.xml]
      at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
      at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
      at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:72)
      at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:83)
      at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
      at org.springframework.integration.config.xml.AbstractIntegrationNamespaceHandler.parse(AbstractIntegrationNamespaceHandler.java:63)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1424)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1414)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:141)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:242)
      ... 49 more
  </code></pre>