title: Suddenly getting "NoSuchBeanDefinitionException no bean named" with correct configs
body: <p>I have a desktop app in Java that connects to a MySql database through Hibernate.</p>
  
  <p>I have the following files for configuration:</p>
  
  <ul>
  <li>pom.xml, where I put some stuff and database profiles</li>
  <li>[app_name]_context.xml, where I put the main configuration, including the beans and the datasource</li>
  <li>[app_name]_hibernate.cfg.xml, where I put the mappings to the tables</li>
  </ul>
  
  <p>The app is almost finished, everything was working 100%, but then I decided to change the configuration to create DB profiles (before that the pom.xml didn't include any profile).
  So I created the profiles in pom.xml and referenced them from context.xml. Everything was working. Then I wanted the SQL to be printed to the terminal for debugging, and for some reason, it wasn't being printed. So I changed the database configurations until I got it right. Everything was working. Then I changed it to the way it was before the sql-print changes, the exact configuration it was working before, but now I'm getting this error for a bean that was always there, and was never changed.</p>
  
  <p>Here's some code to understand it better:</p>
  
  <p>The datasource in context.xml: (the ${} strings are filtered and replaced with the real values stored in pom.xml)</p>
  
  <pre><code>&lt;bean id="desenvolvimentoDS" class="org.apache.commons.dbcp.BasicDataSource"&gt;
      &lt;property name="driverClassName"&gt;
          &lt;value&gt;org.hibernate.dialect.MySQLDialect&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="url"&gt;
          &lt;value&gt;${db.mysql.url}&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="username"&gt;
          &lt;value&gt;${db.mysql.username}&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="password"&gt;
          &lt;value&gt;${db.mysql.password}&lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>The current profile being used, in pom.xml:</p>
  
  <pre><code>&lt;profile&gt;
          &lt;id&gt;HOMOLOGACAO&lt;/id&gt;
          &lt;activation&gt;
              &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;
          &lt;/activation&gt;
          &lt;properties&gt;
              &lt;profile.group&gt;HOMOLOGACAO&lt;/profile.group&gt;
              &lt;maven.test.skip&gt;true&lt;/maven.test.skip&gt;
              &lt;db.show_sql&gt;true&lt;/db.show_sql&gt;
              &lt;db.format_sql&gt;false&lt;/db.format_sql&gt;
              &lt;db.mysql.url&gt;[filtered]&lt;/db.mysql.url&gt;
              &lt;db.mysql.username&gt;[filtered]&lt;/db.mysql.username&gt;
              &lt;db.mysql.password&gt;[filtered]&lt;/db.mysql.password&gt;
          &lt;/properties&gt;
      &lt;/profile&gt;
  </code></pre>
  
  <p>The resource part of pom.xml, that tells Spring to filter those context.xml strings to the profiles values:</p>
  
  <pre><code>    &lt;resources&gt;
          &lt;resource&gt;
              &lt;directory&gt;src/main/resources/configuracao&lt;/directory&gt;
              &lt;filtering&gt;true&lt;/filtering&gt;
          &lt;/resource&gt;
      &lt;/resources&gt;
  </code></pre>
  
  <p>And finally, the bean that is giving me the error:</p>
  
  <pre><code>&lt;bean name="servidorUDP"
      class="br.uff.pgci.sgca.gateway.server.ServidorUDP"
      scope="singleton"/&gt;
  </code></pre>
  
  <p>Resuming, I created the database profiles to organize the configurations, changed some database configurations back and forth, and suddenly I'm getting "NoSuchBeanDefinitionException no bean named ServidorUDP" error.</p>
  
  <p>Could this be caused by misplaced linebreaks, or spaces, or wrong open/close xml tags? I'm pretty sure this isn't the case, but we never know...</p>