title: Mule spring basic security fails with user-service properties file
body: <p>I am configuring a Mule application (running on API Gateway 2.1), and running into some issues when configuring spring security.</p>
  
  <p>Here is the security config:</p>
  
  <pre><code>&lt;spring:beans&gt;
      &lt;ss:authentication-manager alias="authenticationManager"&gt;
          &lt;ss:authentication-provider &gt;
              &lt;ss:user-service id="userService" properties="classpath:users.properties"&gt;
              &lt;!-- **** This works, but the properties file above ^ doesn't ****
                  &lt;ss:user name="user" password="password" authorities="ROLE_ADMIN"/&gt; 
                  &lt;ss:user name="anon" password="anon" authorities="ROLE_ANON" /&gt; 
              --&gt;
              &lt;/ss:user-service&gt;
          &lt;/ss:authentication-provider&gt;
      &lt;/ss:authentication-manager&gt;
  &lt;/spring:beans&gt;
  
  &lt;mule-ss:security-manager name="security-manager"
      doc:name="Spring Security Provider"&gt;
      &lt;mule-ss:delegate-security-provider
          name="memory-provider" delegate-ref="authenticationManager" /&gt;
  &lt;/mule-ss:security-manager&gt;
  </code></pre>
  
  <p><code>users.properties</code> is on my classpath and contains the following:</p>
  
  <pre><code>user=userpassword,ROLE_USER,enabled
  admin=admin,ROLE_USER,ROLE_ADMIN,enabled
  chris=chrispassword,ROLE_USER,enabled  
  </code></pre>
  
  <p>What I find confusing is that when I use the embedded users (see commented section in Mule flow above), and remove the <code>properties=classpath:users.properties</code>, everything runs fine. But when I try to use users.properties, I get the exception below. I know that users.properties is being found on the classpath. Have I misconfigured users.properties? If this is a more general configuration problem why doesn't it always fail?</p>
  
  <p>I'm getting the following exception (top part of the stack trace):</p>
  
  <blockquote>
    <p>org.mule.module.launcher.DeploymentInitException: NullPointerException: 
        at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:197) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.artifact.ArtifactWrapper$2.execute(ArtifactWrapper.java:62) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:129) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.artifact.ArtifactWrapper.init(ArtifactWrapper.java:57) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:25) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.DefaultArchiveDeployer.guardedDeploy(DefaultArchiveDeployer.java:310) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:330) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:155) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:256) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:78) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.DeploymentDirectoryWatcher.deployPackedApps(DeploymentDirectoryWatcher.java:275) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:150) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.MuleDeploymentService.start(MuleDeploymentService.java:100) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.MuleContainer.start(MuleContainer.java:170) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:21) ~[tooling-support-1.0.0.jar:?]
    Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name '_muleSecurityManager': Cannot create inner bean '(inner bean)#157a5cdc' of type [org.mule.module.spring.security.S
    pringProviderAdapter] while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#157
    a5cdc': Cannot resolve reference to bean 'authenticationManager' while setting bean property 'delegate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bea
    n with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting construct
    or argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationP
    rovider#0': Cannot resolve reference to bean 'userService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating
     bean with name 'userService': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.
    provisioning.InMemoryUserDetailsManager]: Constructor threw exception; nested exception is java.lang.NullPointerException (org.mule.api.lifecycle.InitialisationException) (org.mule.api.config.Configur
    ationException)
        at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:49) ~[mule-core-3.7.2.jar:3.7.2]
        at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:69) ~[mule-core-3.7.2.jar:3.7.2]
        at org.mule.context.DefaultMuleContextFactory$1.configure(DefaultMuleContextFactory.java:89) ~[mule-core-3.7.2.jar:3.7.2]
        at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:222) ~[mule-core-3.7.2.jar:3.7.2]
        at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:81) ~[mule-core-3.7.2.jar:3.7.2]
        at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:188) ~[mule-module-launcher-3.7.2.jar:3.7.2]
        ... 14 more
    Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name '_muleSecurityManager': Cannot create inner bean '(inner bean)#157a5cdc' of type [org.mule.module.spring.security.S
    pringProviderAdapter] while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#157
    a5cdc': Cannot resolve reference to bean 'authenticationManager' while setting bean property 'delegate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bea
    n with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting construct
    or argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationP
    rovider#0': Cannot resolve reference to bean 'userService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating
     bean with name 'userService': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.
    provisioning.InMemoryUserDetailsManager]: Constructor threw exception; nested exception is java.lang.NullPointerException (org.mule.api.lifecycle.InitialisationException)</p>
  </blockquote>