preparation

Started by making sure that the latest version still works.

I already confirmed with Active State that you cannot upload a JAR directly, but have to unpack it so:

from the working dir (same level as pom.xml)
cd ./unpacked/; unzip ../target/unfamous-quotes-0.0.1-SNAPSHOT.jar; ls -al; cd ..
stackato push –path ./unpacked/

But the application starts up on port 8080 which is not the port stackato wants it to run at and then it is killed and restarted and ..
application.properties still has an entry about the server.port which I commented out and retried. But the server still started on
port 8080. So I made sure that the application.properties file was really updated which it was.

In between tries I always removed application including the route with

stackato delete unfamous-quotes

No luck. nothing helped.
I don’t understand though since I have an example that works and this app worked fine before I did some static file changes.

No matter what I check or do stackato is not able to assign the right port and the server runs on 8080 until it is killed of.
Of course I could set the port like for my simple server test but that defeats the purpose.

Besides, the exact same JAR works on Pivotal’s Cloud Foundation free tier run.pivotal.io with a simple push.

cf push unfamous-quotes -p ./target/unfamous-quotes-0.0.1-SNAPSHOT.jar

Next I tried another trick that I already learned in my experiments. I upload the jar with Eclipse (STS)
Or you can also push with CF, but then I would have to log out of run.pivotal.io – which I am using in parallel –
and into stackato, which also works. But unlike the stackato CLI the cf CLI does not allow multiple targets
and swithcing between them. So Eclispe it is.
The push with Eclipse (or cf) will fail, too, but all it requires is a start of the app and the same jar works in stackato.

Except that this does not resolve anything, the server still tstats on 127.0.0.0

Setting the JAVA_OPTS environment variable has the same escaping problems as before, too.

At this stage I am ready for one of my once in a month stress-release cigarettes.
The stackato web UI does not do anything to calm me down, either. e.g. the page refresh is annoying.

Even cf set-env did not work I assume there is an incompatibility with the build back

since the logs show this, which neither seems to work nor does it contain any of my environment variables:

stackato[dea_ng.0]: Launching web process: $PWD/.java-buildpack/open_jdk/bin/java -cp $PWD/.:$PWD/.java-buildpack/spring_auto_reconfiguration/spring_auto_reconfiguration-0.8.9.jar -Djava.io.tmpdir=$TMPDIR -XX:MaxPermSize=64M -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk/bin/killjava.sh -XX:PermSize=64M -Xms382293K -Xmx382293K -Xss995K org.springframework.boot.loader.JarLauncher --server.port=$PORT

And I give up for now.

Similar to my Cloud Foundry environment notes I was interested what Stackato puts on top of the Cloud Foundry framework. This was running in a local VM that I downloaded from their site.

Deploying the app

Still using the same test code

After spending quite some time on trying to set the JAVA_OPTS, I instead changed the source code to use the environment variable instead of server.port and server.address and then re-pushed

mkdir build
cd build
unzip ../target/simple-executable-jar-web-server-0.0.1.jar
cd ..
stackato push --path /xdata/local/dev/markus/git/simple-executable-jar-web-server/build

The app worked after my code changes and the test server was up and running, but I could not log into the web console, anymore, thought I had the password wrong, but then used

stackato passwd

and it accepted my old password. Besides Firefox remembered the same password.

A server restart helped. Since I usually only pause my VMs it might have gotten confused.,

Runtime Environment and Properties

Environment

'HOME' = '/home/stackato/app'
'JAVA_OPTS' = '-Dserver.port=$VCAP_APP_PORT -Dserver.address=$VCAP_APP_HOST'
'LANG' = 'en_US.UTF-8'
'LANGUAGE' = 'en_US.UTF-8'
'LC_ALL' = 'en_US.UTF-8'
'LOGNAME' = 'stackato'
'MAIL' = '/var/mail/stackato'
'MEMORY_LIMIT' = '256m'
'NLSPATH' = '/usr/dt/lib/nls/msg/%L/%N.cat'
'OLDPWD' = '/home/stackato/app'
'PACKAGES_COMMON' = 'git'
'PATH' = '/opt/ActivePython-2.7/bin:/opt/ActivePython-3.3/bin:/opt/ActivePerl-5.16/bin:/opt/rubies/current/bin:/opt/node-v0.10/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
'PORT' = '58761'
'PWD' = '/home/stackato/app'
'SHELL' = '/bin/bash'
'SHLVL' = '2'
'SSH_CLIENT' = '172.17.42.1 51755 22'
'SSH_CONNECTION' = '172.17.42.1 51755 172.17.0.86 22'
'STACKATO_APP_ENV' = 'JAVA_OPTS'
'STACKATO_APP_NAME' = 'simple-executable-jar-web-server'
'STACKATO_APP_NAME_UPCASE' = 'SIMPLE_EXECUTABLE_JAR_WEB_SERVER'
'STACKATO_APP_ROOT' = '/home/stackato'
'STACKATO_DOCKER' = 'True'
'STACKATO_LOG_FILES' = 'stdout=/home/stackato/logs/stdout.log:stderr=/home/stackato/logs/stderr.log'
'STACKATO_SERVICES' = '{}'
'TMPDIR' = '/home/stackato/tmp'
'USER' = 'stackato'
'VCAP_APPLICATION' = '{"instance_id":"e20054cb47ed479c843142b480e12f52","instance_index":0,"host":"0.0.0.0","port":58761,"started_at":"2014-06-02 06:33:19 -0700","started_at_timestamp":1401715999,"start":"2014-06-02 06:33:19 -0700","state_timestamp":1401715999,"limits":{"mem":256,"disk":2048,"fds":16384,"allow_sudo":false},"application_version":"8c5b4b0a-5e50-4d69-bf92-f4fe7c5ef0ec","application_name":"simple-executable-jar-web-server","application_uris":["simple-executable-jar-web-server.stackato-cr6q.local"],"sso_enabled":false,"version":"8c5b4b0a-5e50-4d69-bf92-f4fe7c5ef0ec","name":"simple-executable-jar-web-server","uris":["simple-executable-jar-web-server.stackato-cr6q.local"],"users":null}'
'VCAP_APP_HOST' = '0.0.0.0'
'VCAP_APP_PORT' = '58761'
'VCAP_SERVICES' = '{}'
'XFILESEARCHPATH' = '/usr/dt/app-defaults/%L/Dt'
'_' = '/home/stackato/app/.java-buildpack/open_jdk/bin/java'

System Properties

'awt.toolkit' = 'sun.awt.X11.XToolkit'
'file.encoding' = 'UTF-8'
'file.encoding.pkg' = 'sun.io'
'file.separator' = '/'
'java.awt.graphicsenv' = 'sun.awt.X11GraphicsEnvironment'
'java.awt.printerjob' = 'sun.print.PSPrinterJob'
'java.class.path' = '/home/stackato/app/.'
'java.class.version' = '51.0'
'java.endorsed.dirs' = '/home/stackato/app/.java-buildpack/open_jdk/lib/endorsed'
'java.ext.dirs' = '/home/stackato/app/.java-buildpack/open_jdk/lib/ext:/usr/java/packages/lib/ext'
'java.home' = '/home/stackato/app/.java-buildpack/open_jdk'
'java.io.tmpdir' = '/home/stackato/tmp'
'java.library.path' = '/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib'
'java.runtime.name' = 'OpenJDK Runtime Environment'
'java.runtime.version' = '1.7.0_60-b19'
'java.specification.name' = 'Java Platform API Specification'
'java.specification.vendor' = 'Oracle Corporation'
'java.specification.version' = '1.7'
'java.vendor' = 'Oracle Corporation'
'java.vendor.url' = 'http://java.oracle.com/'
'java.vendor.url.bug' = 'http://bugreport.sun.com/bugreport/'
'java.version' = '1.7.0_60'
'java.vm.info' = 'mixed mode'
'java.vm.name' = 'OpenJDK 64-Bit Server VM'
'java.vm.specification.name' = 'Java Virtual Machine Specification'
'java.vm.specification.vendor' = 'Oracle Corporation'
'java.vm.specification.version' = '1.7'
'java.vm.vendor' = 'Oracle Corporation'
'java.vm.version' = '24.80-b07'
'line.separator' = '    '
'os.arch' = 'amd64'
'os.name' = 'Linux'
'os.version' = '3.8.0-30-generic'
'path.separator' = ':'
'sun.arch.data.model' = '64'
'sun.boot.class.path' = '/home/stackato/app/.java-buildpack/open_jdk/lib/resources.jar:/home/stackato/app/.java-buildpack/open_jdk/lib/rt.jar:/home/stackato/app/.java-buildpack/open_jdk/lib/sunrsasign.jar:/home/stackato/app/.java-buildpack/open_jdk/lib/jsse.jar:/home/stackato/app/.java-buildpack/open_jdk/lib/jce.jar:/home/stackato/app/.java-buildpack/open_jdk/lib/charsets.jar:/home/stackato/app/.java-buildpack/open_jdk/lib/jfr.jar:/home/stackato/app/.java-buildpack/open_jdk/classes'
'sun.boot.library.path' = '/home/stackato/app/.java-buildpack/open_jdk/lib/amd64'
'sun.cpu.endian' = 'little'
'sun.cpu.isalist' = ''
'sun.io.unicode.encoding' = 'UnicodeLittle'
'sun.java.command' = 'at.mnm.util.SimpleTestWebServer'
'sun.java.launcher' = 'SUN_STANDARD'
'sun.jnu.encoding' = 'UTF-8'
'sun.management.compiler' = 'HotSpot 64-Bit Tiered Compilers'
'sun.os.patch.level' = 'unknown'
'user.country' = 'US'
'user.dir' = '/home/stackato/app'
'user.home' = '/home/stackato'
'user.language' = 'en'
'user.name' = 'stackato'

Adding services

Wanted to add the service via the web UI but did not immediately see how.

stackato create-service mysql testdb simple-executable-jar-web-server

Afterwards the following new environment properties were added :

> 'DATABASE_URL' = 'mysql://ucLE9lXtowAqf:pYSRyL7jO1vgi@172.16.127.133:3306/d415c91f5251b450d9a3c20c45b5d7777'
> 'JDBC_MYSQL_URL' = 'jdbc:mysql://ucLE9lXtowAqf:pYSRyL7jO1vgi@172.16.127.133:3306/d415c91f5251b450d9a3c20c45b5d7777'
> 'MYSQL_URL' = 'mysql://ucLE9lXtowAqf:pYSRyL7jO1vgi@172.16.127.133:3306/d415c91f5251b450d9a3c20c45b5d7777'

And these changed : < ‘STACKATO_SERVICES’ = ‘{}’ —

‘STACKATO_SERVICES’ = ‘{“testdb”:{“name”:”d415c91f5251b450d9a3c20c45b5d7777″, “hostname”:”172.16.127.133″,”host”:”172.16.127.133″,”port”:3306, “user”:”ucLE9lXtowAqf”,”username”:”ucLE9lXtowAqf”,”password”:”pYSRyL7jO1vgi”, “uri”:”mysql://ucLE9lXtowAqf:pYSRyL7jO1vgi@172.16.127.133:3306/d415c91f5251b450d9a3c20c45b5d7777″, “jdbcUrl”:”jdbc:mysql://ucLE9lXtowAqf:pYSRyL7jO1vgi@172.16.127.133:3306/d415c91f5251b450d9a3c20c45b5d7777″}}’

< 'VCAP_SERVICES' = '{}'
---
> 'VCAP_SERVICES' = '{"mysql":[{"name":"testdb","label":"mysql-5.5","tags":[],
    "plan":"free","credentials":{"name":"d415c91f5251b450d9a3c20c45b5d7777",
    "hostname":"172.16.127.133","host":"172.16.127.133","port":3306,
    "user":"ucLE9lXtowAqf","username":"ucLE9lXtowAqf","password":"pYSRyL7jO1vgi",
    "uri":"mysql://ucLE9lXtowAqf:pYSRyL7jO1vgi@172.16.127.133:3306/d415c91f5251b450d9a3c20c45b5d7777",
    "jdbcUrl":"jdbc:mysql://ucLE9lXtowAqf:pYSRyL7jO1vgi@172.16.127.133:3306/d415c91f5251b450d9a3c20c45b5d7777"}}]}'

VCAP_APPLICATION seemed to change like for CloudFoundry – but unrelated to to service.

and this system proeprty changed, simialr to Cloud Foundry:

< 'java.class.path' = '/home/stackato/app/.'
---
> 'java.class.path' = '/home/stackato/app/.:/home/stackato/app/.java-buildpack/maria_db_jdbc/maria_db_jdbc-1.1.7.jar'

Appendix : How to Not Set Environment

Not sure how this should have worked, but it didn’t for me…

I wanted to set Java System Properties to pass in the server.address and server.port. The same worked for Cloud Foundry

Tried to figure out the right amount of escaping … this is what we want to see: ‘JAVA_OPTS’ = ‘-Dserver.port=$VCAP_APP_PORT -Dserver.address=$VCAP_APP_HOST’

stackato set-env simple-executable-jar-web-server JAVA_OPTS "-Dserver.port=\\\$VCAP_APP_PORT -Dserver.address=\\\$VCAP_APP_HOST"
Unknown option -Dserver.port

stackato set-env simple-executable-jar-web-server JAVA_OPTS '-Dserver.port=$VCAP_APP_PORT -Dserver.address=$VCAP_APP_HOST'
Unknown option -Dserver.port


stackato set-env simple-executable-jar-web-server JAVA_OPTS '\-Dserver.port=\$VCAP_APP_PORT \-Dserver.address=\$VCAP_APP_HOST'
Adding Environment Variable [JAVA_OPTS=\-Dserver.port=\$VCAP_APP_PORT \-Dserver.address=\$VCAP_APP_HOST] ... 
...
app[stdout.0]:    'JAVA_OPTS' = '\-Dserver.port=$VCAP_APP_PORT \-Dserver.address=$VCAP_APP_HOST'
...




stackato set-env simple-executable-jar-web-server JAVA_OPTS '\"-Dserver.port=\$VCAP_APP_PORT \-Dserver.address=\$VCAP_APP_HOST\"'
Adding Environment Variable [JAVA_OPTS=\"-Dserver.port=\$VCAP_APP_PORT \-Dserver.address=\$VCAP_APP_HOST\"] ... 
...
app[stdout.0]:    'JAVA_OPTS' = '\-Dserver.port=$VCAP_APP_PORT'
...


stackato set-env simple-executable-jar-web-server JAVA_OPTS "\"-Dserver.port=\$VCAP_APP_PORT \-Dserver.address=\$VCAP_APP_HOST\""
Adding Environment Variable [JAVA_OPTS="-Dserver.port=$VCAP_APP_PORT \-Dserver.address=$VCAP_APP_HOST"] ... 
...
app[stdout.0]:    'JAVA_OPTS' = '"-Dserver.port=45238 \-Dserver.address=0.0.0.0"'
...

stackato env-add simple-executable-jar-web-server JAVA_OPTS "\"-Dserver.port=\$VCAP_APP_PORT \-Dserver.address=\$VCAP_APP_HOST\""
Adding Environment Variable [JAVA_OPTS="-Dserver.port=$VCAP_APP_PORT \-Dserver.address=$VCAP_APP_HOST"] ... 
...
app[stdout.0]:    'JAVA_OPTS' = '"-Dserver.port=43998 \-Dserver.address=0.0.0.0"'
...


stackato set-env simple-executable-jar-web-server JAVA_OPTS "\-Dserver.port=\\\$VCAP_APP_PORT \-Dserver.address=\\\$VCAP_APP_HOST"
Adding Environment Variable [JAVA_OPTS=\-Dserver.port=\$VCAP_APP_PORT \-Dserver.address=\$VCAP_APP_HOST] ... 
...
app[stdout.0]:    'JAVA_OPTS' = '\-Dserver.port=$VCAP_APP_PORT \-Dserver.address=$VCAP_APP_HOST'
...


stackato env-add simple-executable-jar-web-server JAVA_OPTS "\"-Dserver.port=\$VCAP_APP_PORT -Dserver.address=\$VCAP_APP_HOST\""
Adding Environment Variable [JAVA_OPTS="-Dserver.port=$VCAP_APP_PORT -Dserver.address=$VCAP_APP_HOST"] ... 
...
app[stdout.0]:    'JAVA_OPTS' = '"-Dserver.port=48420 -Dserver.address=0.0.0.0"'
...

stackato env-add simple-executable-jar-web-server JAVA_OPTS "\"-Dserver.port=\\\$VCAP_APP_PORT -Dserver.address=\\\$VCAP_APP_HOST\""
Adding Environment Variable [JAVA_OPTS="-Dserver.port=\$VCAP_APP_PORT -Dserver.address=\$VCAP_APP_HOST"] ... 
...
app[stdout.0]:    'JAVA_OPTS' = '"-Dserver.port=$VCAP_APP_PORT -Dserver.address=$VCAP_APP_HOST"'
...


stackato env-add simple-executable-jar-web-server JAVA_OPTS "\-Dserver.port=\\\$VCAP_APP_PORT \-Dserver.address=\\\$VCAP_APP_HOST"
Adding Environment Variable [JAVA_OPTS=\-Dserver.port=\$VCAP_APP_PORT \-Dserver.address=\$VCAP_APP_HOST] ... 
...
app[stdout.0]:    'JAVA_OPTS' = '\-Dserver.port=$VCAP_APP_PORT \-Dserver.address=$VCAP_APP_HOST'
...

stackato env-add simple-executable-jar-web-server JAVA_OPTS '"-"Dserver.port=\$VCAP_APP_PORT "-"Dserver.address=\$VCAP_APP_HOST"'
Adding Environment Variable [JAVA_OPTS="-"Dserver.port=\$VCAP_APP_PORT "-"Dserver.address=\$VCAP_APP_HOST"] ... 
...
app[stdout.0]:    'JAVA_OPTS' = '"-"Dserver.port=$VCAP_APP_PORT "-"Dserver.address=$VCAP_APP_HOST"'
...

giving up. I use the way it works descibed at http://community.activestate.com/node/9487 (or I could use cf).

vi build/stackato.yml

app-dir: /xdata/local/dev/markus/git/simple-executable-jar-web-server/build
disk: 2048
memory: 256
name: simple-executable-jar-web-server
env:
JAVA_OPTS: "-Dserver.port=$VCAP_APP_PORT -Dserver.address=$VCAP_APP_HOST"


stackato push --path /xdata/local/dev/markus/git/simple-executable-jar-web-server/build
...
app[stdout.0]:    'JAVA_OPTS' = '"-"Dserver.port=$VCAP_APP_PORT "-"Dserver.address=$VCAP_APP_HOST"'
...


stackato env-del simple-executable-jar-web-server JAVA_OPTS
Deleting Environment Variable [JAVA_OPTS] ... 



stackato push --path /xdata/local/dev/markus/git/simple-executable-jar-web-server/build
Using manifest file "build/stackato.yml"
...
Enter JAVA_OPTS [-Dserver.port=$VCAP_APP_PORT -Dserver.address=$VCAP_APP_HOST]: 
  Adding Environment Variable [JAVA_OPTS=-Dserver.port=$VCAP_APP_PORT -Dserver.address=$VCAP_APP_HOST]
...

but no JAVA_OPTS and no system properties

stackato env-del simple-executable-jar-web-server JAVA_OPTS


cf login  --skip-ssl-validation -a https://api.stackato-cr6q.local
API endpoint: https://api.stackato-cr6q.local
...

cf set-env simple-executable-jar-web-server JAVA_OPTS "-Dserver.port=\\\$VCAP_APP_PORT -Dserver.address=\\\$VCAP_APP_HOST"
Setting env variable 'JAVA_OPTS' to '-Dserver.port=\$VCAP_APP_PORT -Dserver.address=\$VCAP_APP_HOST' for app simple-executable-jar-web-server in org mnm.at / space demos as admin...
OK
TIP: Use 'cf push' to ensure your env variable changes take effect

rm build/stackato.yml 
stackato push --path /xdata/local/dev/markus/git/simple-executable-jar-web-server/build

even though this time the JAVA_OPTS variable looks right:

app[stdout.0]:    'JAVA_OPTS' = '-Dserver.port=$VCAP_APP_PORT -Dserver.address=$VCAP_APP_HOST'

there is not server.port system property. so it seems that the build back is different (though it is the java build pack)