title: Receiving NullPointerException while using Jasypt and Spring Security 3.1
body: <p>I am trying to configure Jasypt with Spring Security.  My configuration file looks like this:</p>
  
  <pre><code>    jdbc.driver=com.mysql.jdbc.Driver
      jdbc.url=jdbc:mysql://localhost:8090/sample
      jdbc.username=ENC(*****) where the *****=the salted username
      jdbc.password=ENC(*****) where the *****=the salted password
  </code></pre>
  
  <p>My servlet xml contains the proper bean setup in this format:</p>
  
  <pre><code> &lt;bean id="propertyPlaceholderConfigurer"
        class="org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer"&gt;
    &lt;constructor-arg ref="configurationEncryptor" /&gt;
    &lt;property name="location" value="/WEB-INF/jdbc.properties" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor"&gt;
    &lt;property name="config" ref="environmentVariablesConfiguration" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="environmentVariablesConfiguration"
        class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig"&gt;
    &lt;property name="algorithm" value="PBEWithMD5AndDES" /&gt;
      &lt;property name="passwordEnvName" value="APP_ENCRYPTION_PASSWORD" /&gt;
    &lt;!--&lt;property name="password" value="**********" /&gt;--&gt;
  &lt;/bean&gt;
         &lt;bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="${jdbc.driver}" /&gt;
      &lt;property name="url" value="${jdbc.url}" /&gt;
      &lt;property name="username" value="${jdbc.username}" /&gt;
      &lt;property name="password" value="${jdbc.password}" /&gt;
     &lt;/bean&gt;
  </code></pre>
  
  <p>My environment variable is set in windows properly for APP_ENCRYPTION_PASSWORD.  It is visible when I echo it from command line.  When I use this setup, I get the null pointer stack trace below.  When I use the hard coded salt password "-->", my application runs smoothly.  Can someone show me why Jasypt or Spring might not be picking up on my environment variable properly?  Any information would be welcomed.  Thanks.</p>
  
  <pre><code> org.springframework.web.context.ContextLoader initWebApplicationContext
  SEVERE: Context initialization failed
  java.lang.NullPointerException
      at org.jasypt.encryption.pbe.config.SimplePBEConfig.getPasswordCharArray(SimplePBEConfig.java:434)
      at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.resolveConfigurationPassword(StandardPBEByteEncryptor.java:740)
      at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:590)
      at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.initialize(StandardPBEStringEncryptor.java:553)
      at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:705)
      at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
      at org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer.convertPropertyValue(EncryptablePropertyPlaceholderConfigurer.java:109)
      at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperty(PropertyResourceConfigurer.java:121)
      at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperties(PropertyResourceConfigurer.java:104)
      at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:81)
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:662)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:388)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701)
      at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
      at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  Aug 7, 2013 8:46:15 AM org.apache.catalina.core.StandardContext listenerStart
  SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
  java.lang.NullPointerException
      at org.jasypt.encryption.pbe.config.SimplePBEConfig.getPasswordCharArray(SimplePBEConfig.java:434)
      at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.resolveConfigurationPassword(StandardPBEByteEncryptor.java:740)
      at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:590)
      at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.initialize(StandardPBEStringEncryptor.java:553)
      at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:705)
      at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
      at org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer.convertPropertyValue(EncryptablePropertyPlaceholderConfigurer.java:109)
      at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperty(PropertyResourceConfigurer.java:121)
      at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperties(PropertyResourceConfigurer.java:104)
      at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:81)
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
      at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:662)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:388)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701)
      at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
      at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  </code></pre>