{"action":"created","issue":{"url":"https://api.github.com/repos/cloudfoundry/java-buildpack/issues/209","labels_url":"https://api.github.com/repos/cloudfoundry/java-buildpack/issues/209/labels{/name}","comments_url":"https://api.github.com/repos/cloudfoundry/java-buildpack/issues/209/comments","events_url":"https://api.github.com/repos/cloudfoundry/java-buildpack/issues/209/events","html_url":"https://github.com/cloudfoundry/java-buildpack/issues/209","id":97535687,"number":209,"title":"Support for Cloud Foundry Environment Variable substitution in the JAVA_OPTS framework","user":{"login":"kelapure","id":206519,"avatar_url":"https://avatars.githubusercontent.com/u/206519?v=3","gravatar_id":"","url":"https://api.github.com/users/kelapure","html_url":"https://github.com/kelapure","followers_url":"https://api.github.com/users/kelapure/followers","following_url":"https://api.github.com/users/kelapure/following{/other_user}","gists_url":"https://api.github.com/users/kelapure/gists{/gist_id}","starred_url":"https://api.github.com/users/kelapure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelapure/subscriptions","organizations_url":"https://api.github.com/users/kelapure/orgs","repos_url":"https://api.github.com/users/kelapure/repos","events_url":"https://api.github.com/users/kelapure/events{/privacy}","received_events_url":"https://api.github.com/users/kelapure/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-07-27T19:19:28Z","updated_at":"2015-07-29T13:56:41Z","closed_at":null,"body":"See comments made here https://github.com/cloudfoundry/java-buildpack/issues/205\r\nUse case is very simple. I  need the ability to configure a javaagent with the [$PORT](http://docs.run.pivotal.io/devguide/deploy-apps/environment-variable.html#PORT) CF env. variable.\r\n\r\n I needeto do something like this\r\n`JAVA_OPTS:-javaagent:agent.jar=port=$PORT,host=localhost`\r\n\r\nThe port that is provided to configure the Jolokia agent is the port the server listens on. This is passed into the droplet as an env. variable by CF. I had trouble getting the droplet to start with the above command. The value of $PORT is not substituted in the JAVA_OPTS env variable. Is there any way to force this to happen. See example below ...\r\n\r\n```yaml\r\n2015-07-27T15:10:17.44-0400 [STG/0]      ERR [Buildpack]                      DEBUG Release Payload:\r\n2015-07-27T15:10:17.44-0400 [STG/0]      ERR ---\r\n2015-07-27T15:10:17.44-0400 [STG/0]      ERR addons: []\r\n2015-07-27T15:10:17.44-0400 [STG/0]      ERR config_vars: {}\r\n2015-07-27T15:10:17.44-0400 [STG/0]      ERR default_process_types:\r\n2015-07-27T15:10:17.44-0400 [STG/0]      ERR   web: CALCULATED_MEMORY=$($PWD/.java-buildpack/open_jdk_jre/bin/java-buildpack-memory-calculator-1.1.1_RELEASE\r\n2015-07-27T15:10:17.44-0400 [STG/0]      ERR     -memorySizes=metaspace:64m.. -memoryWeights=heap:75,metaspace:10,stack:5,native:10\r\n2015-07-27T15:10:17.44-0400 [STG/0]      ERR     -totMemory=$MEMORY_LIMIT) && JAVA_HOME=$PWD/.java-buildpack/open_jdk_jre JAVA_OPTS=\"-Djava.io.tmpdir=$TMPDIR\r\n2015-07-27T15:10:17.44-0400 [STG/0]      ERR     -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/killjava.sh $CALCULATED_MEMORY\r\n2015-07-27T15:10:17.44-0400 [STG/0]      ERR     -javaagent:/home/vcap/app/WEB-INF/lib/jolokia-jvm-1.3.1-agent.jar=port=,host=localhost\r\n2015-07-27T15:10:17.44-0400 [STG/0]      ERR     -Daccess.logging.enabled=false -Dhttp.port=$PORT\" $PWD/.java-buildpack/tomcat/bin/catalina.sh\r\n2015-07-27T15:10:17.44-0400 [STG/0]      ERR     run\r\n2015-07-27T15:10:24.93-0400 [STG/17]     OUT -----> Uploading droplet (74M)\r\n2015-07-27T15:10:35.82-0400 [DEA/17]     OUT Starting app instance (index 0) with guid 4284bf4f-95c7-40d0-9290-162837c1bcf8\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR Exception in thread \"main\" java.lang.reflect.InvocationTargetException\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR    at java.lang.reflect.Method.invoke(Method.java:497)\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:388)\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR    at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR Caused by: java.lang.IllegalArgumentException: jolokia: Invalid option 'port='. Ignoring\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR    at org.jolokia.jvmagent.JvmAgentConfig.split(JvmAgentConfig.java:112)\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR    at org.jolokia.jvmagent.JvmAgentConfig.<init>(JvmAgentConfig.java:46)\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR    at org.jolokia.jvmagent.JvmAgent.premain(JvmAgent.java:67)\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR    ... 6 more\r\n2015-07-27T15:10:38.76-0400 [App/0]      OUT FATAL ERROR in native method: processing of -javaagent failed\r\n2015-07-27T15:10:38.76-0400 [App/0]      ERR bash: line 1:    33 Aborted                 JAVA_HOME=$PWD/.java-buildpack/open_jdk_jre JAVA_OPTS=\"-Djava.io.tmpdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/killjava.sh $CALCULATED_MEMORY -javaagent:/home/vcap/app/WEB-INF/lib/jolokia-jvm-1.3.1-agent.jar=port=,host=localhost -Daccess.logging.enabled=false -Dhttp.port=$PORT\" $PWD/.java-buildpack/tomcat/bin/catalina.sh run\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/cloudfoundry/java-buildpack/issues/comments/125960278","html_url":"https://github.com/cloudfoundry/java-buildpack/issues/209#issuecomment-125960278","issue_url":"https://api.github.com/repos/cloudfoundry/java-buildpack/issues/209","id":125960278,"user":{"login":"kelapure","id":206519,"avatar_url":"https://avatars.githubusercontent.com/u/206519?v=3","gravatar_id":"","url":"https://api.github.com/users/kelapure","html_url":"https://github.com/kelapure","followers_url":"https://api.github.com/users/kelapure/followers","following_url":"https://api.github.com/users/kelapure/following{/other_user}","gists_url":"https://api.github.com/users/kelapure/gists{/gist_id}","starred_url":"https://api.github.com/users/kelapure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelapure/subscriptions","organizations_url":"https://api.github.com/users/kelapure/orgs","repos_url":"https://api.github.com/users/kelapure/repos","events_url":"https://api.github.com/users/kelapure/events{/privacy}","received_events_url":"https://api.github.com/users/kelapure/received_events","type":"User","site_admin":false},"created_at":"2015-07-29T13:56:41Z","updated_at":"2015-07-29T13:56:41Z","body":"@cgfrost  The substitution of $PORT with the actual value like 8080."}}