title: Spring Boot (XML Configuration) & Jasypt Integration
body: <p>My application is merely to startup an ActiveMQ broker.</p>
  
  <p>I want to use XML-based configuration in Spring Boot, to make use of the XML configuration for ActiveMQ broker (referenced <a href="http://activemq.apache.org/xml-configuration.html" rel="nofollow noreferrer">here</a>).</p>
  
  <p>I'm using jasypt-spring-boot-starter for my encryption needs, but it seems that the encrypted values for my passwords are not being decrypted when the XML configuration is being initialised.</p>
  
  <p>No errors during startup. Just that when I try to access the broker using admin/user it will fail with error "User name [user] or password is invalid."</p>
  
  <p><strong>Main Spring Boot App Class</strong></p>
  
  <pre><code>@Configuration
  @ComponentScan
  @EnableAutoConfiguration
  @SpringBootApplication
  @RestController
  @ImportResource({"classpath:activemq.xml"})
  public class Application {
      public static void main(String[] args) throws Exception {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p><strong>Excerpt from Broker Config (activemq.xml)</strong></p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:amq="http://activemq.apache.org/schema/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://activemq.apache.org/schema/core 
      http://activemq.apache.org/schema/core/activemq-core.xsd"&gt;
  
      &lt;broker xmlns="http://activemq.apache.org/schema/core" brokerName="${activemq.broker.name}" dataDirectory="${activemq.broker.data}"&gt;
  
      &lt;plugins&gt;
          &lt;runtimeConfigurationPlugin checkPeriod="1000" /&gt;
  
          &lt;simpleAuthenticationPlugin&gt;
                  &lt;users&gt;
                  &lt;authenticationUser username="admin" password="${activemq.broker.admin.password}" groups="users,admins" /&gt;
                  &lt;authenticationUser username="user" password="${activemq.broker.user.password}" groups="users" /&gt;
                  &lt;authenticationUser username="guest" password="${activemq.broker.guest.password}" groups="guests" /&gt;
              &lt;/users&gt;
          &lt;/simpleAuthenticationPlugin&gt;
      &lt;/plugins&gt;
  
  ...more
  </code></pre>
  
  <p><strong>application.properties</strong></p>
  
  <pre><code>jasypt.encryptor.password=thisisnotapassword
  jasypt.encryptor.algorithm=PBEWITHMD5ANDTRIPLEDES
  activemq.broker.admin.password=ENC(OZRghRNXYpRiiw18KD7P6Uf2Y7fOieI7)
  activemq.broker.user.password=ENC(yOiHeJlh6Z+VRVmSZe//Yw==)
  activemq.broker.guest.password=guest
  </code></pre>
  
  <p>One thing I noticed from the startup logs is that activemq.xml gets loaded before jasypt related logs appear</p>
  
  <pre><code>Loading XML bean definitions from class path resource [activemq.xml]
  ...some logs
  String Encryptor custom Bean not found with name 'jasyptStringEncryptor'. Initializing Default String Encryptor
  </code></pre>