cloudfoundry/vcap-java — pull request #34 by scottfrederick (2013-10-14 22:36:36+00:00)
Title: Fixed NPE when binding apps to a user-provided service instance.

When a Spring app is bound to a user-provided service instance, the auto-configuration jar will throw a NullPointerException.

~~~
ERROR: org.cloudfoundry.reconfiguration.spring.CloudApplicationContextInitializer - Unexpected exception on initialization: null
java.lang.NullPointerException
at org.cloudfoundry.org.cloudfoundry.runtime.env.CloudEnvironment.servicePropertiesHelper(CloudEnvironment.java:274)
at org.cloudfoundry.org.cloudfoundry.runtime.env.CloudEnvironment.serviceProperties(CloudEnvironment.java:256)
at org.cloudfoundry.org.cloudfoundry.runtime.env.CloudEnvironment.getCloudProperties(CloudEnvironment.java:233)
at org.cloudfoundry.reconfiguration.spring.CloudApplicationContextInitializer.buildPropertySource(CloudApplicationContextInitializer.java:80)
at org.cloudfoundry.reconfiguration.spring.CloudApplicationContextInitializer.initialize(CloudApplicationContextInitializer.java:66)
at org.springframework.web.context.ContextLoader.customizeContext(ContextLoader.java:501)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:388)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1113)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1671)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
~~~

This is due to the fact that user-provided service instances do not have a `plan` attribute in the VCAP_SERVICES json, but code in cloudfoundry-runtime-lib assumes all services have a `plan` attribute.