title: Spring Boot Application tried parse application.properties like XML file
body: <p>When I try launch application, console displayed XmlBeanDefinitionStoreException for application.properties file.
  I couldn't understand why Application tried to read it like XML file. Help me find problem and solve. Thank in advance.</p>
  
  <p>So that console output</p>
  
  <pre><code>  .   ____          _            __ _ _
   /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
  ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
   \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
    '  |____| .__|_| |_|_| |_\__, | / / / /
   =========|_|==============|___/=/_/_/_/
   :: Spring Boot ::        (v1.3.0.RELEASE)
  
  [2016-12-08 10:18:23.297] boot - 6023  INFO [main] --- Main: Starting Main on aleksey-HP-Notebook with PID 6023 (/home/aleksey/MfWorkspace/magicflex/application/VCAUI/target/classes started by aleksey in /home/aleksey/MfWorkspace/magicflex/application/VCAUI)
  [2016-12-08 10:18:23.303] boot - 6023  INFO [main] --- Main: No profiles are active
  [2016-12-08 10:18:23.328] boot - 6023  INFO [main] --- XmlBeanDefinitionReader: Loading XML bean definitions from class path resource [com/dooks/vcaui/server/applicationContext.xml]
  SLF4J: Class path contains multiple SLF4J bindings.
  SLF4J: Found binding in [jar:file:/home/aleksey/MfWorkspace/magicflex/application/VCA/lib/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: Found binding in [jar:file:/home/aleksey/MfWorkspace/magicflex/application/VCAUI/war/WEB-INF/lib/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
  [pool-1-thread-1] INFO org.hibernate.validator.util.Version - Hibernate Validator 4.2.0.Final
  [2016-12-08 10:18:24.265] boot - 6023  INFO [main] --- AnnotationConfigEmbeddedWebApplicationContext: Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@57f23557: startup date [Thu Dec 08 10:18:24 IST 2016]; root of context hierarchy
  [2016-12-08 10:18:26.859] boot - 6023  INFO [main] --- ConfigurationClassBeanDefinitionReader: Skipping bean definition for [BeanMethod:name=transactionalEventListenerFactory,declaringClass=org.springframework.transaction.annotation.AbstractTransactionManagementConfiguration]: a definition for bean 'org.springframework.transaction.config.internalTransactionalEventListenerFactory' already exists. This top-level bean definition is considered as an override.
  [2016-12-08 10:18:26.871] boot - 6023 ERROR [main] --- SpringApplication: Application startup failed
  org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document from class path resource [com/mf/spring/configuration/application.properties] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
      at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromImportedResources(ConfigurationClassBeanDefinitionReader.java:346)
      at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:142)
      at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116)
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:333)
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243)
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98)
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:677)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:519)
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
      at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101)
      at com.dooks.vcaui.server.Main.main(Main.java:15)
  Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
      at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1472)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:994)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
      at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
      at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
      at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:429)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
      ... 21 more
  </code></pre>
  
  <p>I have Spring boot application class</p>
  
  <pre><code>@SpringBootApplication
  public class Main {
  
      public static void main(String[] args) {
          SpringApplication.run("classpath:/com/dooks/vcaui/server/applicationContext.xml", args);
      }
  
  
  }
  </code></pre>
  
  <p>applicationContext.xml</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
      xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
      xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:task="http://www.springframework.org/schema/task"
      xsi:schemaLocation="
              http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
              http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
              http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
              http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
              http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
              http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"&gt;
  
      &lt;tx:annotation-driven /&gt;
  
      &lt;context:component-scan base-package="com.dooks.vcaui.server, com.dooks, com.mf"/&gt;
  
      &lt;!-- first, define your individual @Configuration classes as beans --&gt;
      &lt;bean class="com.mf.spring.configuration.VcaConfig"/&gt;
      &lt;bean class="com.mf.spring.configuration.HibernateConfig"/&gt;
      &lt;bean class="com.mf.spring.configuration.LicenseConfig"/&gt;
      &lt;bean class="com.mf.spring.configuration.BeanConfig"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>That hibernate configuration</p>
  
  <pre><code>@Configuration
  @ComponentScan(basePackages = {"com.dooks", "com.mf"})
  @EnableTransactionManagement
  @PropertySources({
      @PropertySource(value = { "classpath:/com/mf/spring/configuration/application.properties" }),
      @PropertySource(value = { "/etc/dooks/application.properties" }, ignoreResourceNotFound=true)
  })
  public class HibernateConfig {
  
      @Autowired
      private Environment environment;
  
      @Bean
      public LocalSessionFactoryBean sessionFactory() throws IllegalStateException, PropertyVetoException {
          LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
          sessionFactory.setDataSource(dataSource());
          sessionFactory.setPackagesToScan(new String[] { "com.dooks", "com.mf" });
          sessionFactory.setHibernateProperties(hibernateProperties());
          return sessionFactory;
       }
  
      @Bean(destroyMethod="close")
      public DataSource dataSource() throws IllegalStateException, PropertyVetoException {
          ComboPooledDataSource dataSource = new ComboPooledDataSource();
          dataSource.setDriverClass(environment.getRequiredProperty("jdbc.driverClassName"));
          dataSource.setJdbcUrl(environment.getRequiredProperty("jdbc.url"));
  
          dataSource.setUser(environment.getRequiredProperty("jdbc.username"));
          dataSource.setPassword(environment.getRequiredProperty("jdbc.password"));
  
          dataSource.setAcquireIncrement(environment.getProperty("c3p0.acquire_increment", Integer.class));        
          dataSource.setMinPoolSize(environment.getProperty("c3p0.min_size", Integer.class));
          dataSource.setMaxPoolSize(environment.getProperty("c3p0.max_size", Integer.class));
          dataSource.setMaxIdleTimeExcessConnections(environment.getProperty("c3p0.maxIdleTimeExcessConnections", Integer.class));
          dataSource.setMaxStatements(environment.getProperty("c3p0.max_statements", Integer.class));
          dataSource.setAcquireIncrement(environment.getProperty("c3p0.idle_test_period", Integer.class));
          dataSource.setCheckoutTimeout(environment.getProperty("c3p0.timeout", Integer.class));
          dataSource.setTestConnectionOnCheckout(environment.getProperty("c3p0.testConnectionOnCheckout", Boolean.class));
  
          return dataSource;
      }
  
      private Properties hibernateProperties() {
          Properties properties = new Properties();
          properties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
          properties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
          properties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
          return properties;        
      }
  
      @Bean
      @Autowired
      public HibernateTransactionManager transactionManager(SessionFactory s) {
         HibernateTransactionManager txManager = new HibernateTransactionManager();
         txManager.setSessionFactory(s);
         return txManager;
      }
  }
  </code></pre>
  
  <p>and this application.properties</p>
  
  <pre><code>jdbc.driverClassName = org.mariadb.jdbc.Driver
  jdbc.url = jdbc:mysql://localhost/dooks?useUnicode=true&amp;characterEncoding=UTF-8
  jdbc.username = alex
  jdbc.password = P@ssw0rd
  hibernate.dialect = org.hibernate.dialect.MySQLDialect
  hibernate.show_sql = false
  hibernate.format_sql = false
  c3p0.acquire_increment = 1
  c3p0.idle_test_period = 100
  c3p0.max_size = 100
  c3p0.max_statements = 0
  c3p0.min_size = 5
  c3p0.timeout = 3600
  c3p0.testConnectionOnCheckout = true
  c3p0.maxIdleTimeExcessConnections = 60
  </code></pre>
  
  <p><strong>Edited</strong></p>
  
  <p>When I tried remove application.properties file, @ResourceSource(s) annotations and write values from file manualy into HibernateConfig, that exception still. Even if I not use Spring Boot and just try take applicationContext.xml by ClassPathXmlApplicationContext. I sure just HibernateConfig used that, but something tried to look at this file.</p>
  
  <pre><code>public class Main {
  
      public static void main(String[] args) {
          ApplicationContext ac = new ClassPathXmlApplicationContext("/applicationContext.xml");
  
      }
  </code></pre>
  
  <p>Exception</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [com/mf/spring/configuration/application.properties]; nested exception is java.io.FileNotFoundException: class path resource [com/mf/spring/configuration/application.properties] cannot be opened because it does not exist
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
      at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromImportedResources(ConfigurationClassBeanDefinitionReader.java:346)
      at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:142)
      at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116)
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:333)
      at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243)
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
      at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98)
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:677)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:519)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
      at com.dooks.vcaui.server.Main.main(Main.java:12)
  Caused by: java.io.FileNotFoundException: class path resource [com/mf/spring/configuration/application.properties] cannot be opened because it does not exist
      at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
      ... 16 more
  </code></pre>