Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy standalone jar pointing javaagent to Bluemix CloudFoundry

I have been developing a small app through Vert.x and especially with Vertx-Sync. Vertx-sync allows you to work with asynchronous APIs, but using a direct synchronous style using lightweight threads aka Fibers. To start fiber instrumentation a javaagent option should be passed as a vm argument. As a example I run my app through:

 java -jar vertxTestCF -javaagent:{path-to-the-jar}/quasar-core-0.7.5-jdk8.jar 

. Everything works well on local but I am unable to deploy vertxTestCF on the cloud vi cloudfoundry CLI. I deploy vertxTestCF with following CLI:

cf push -f manifest.yml vertxTestCF

That is my manifest.yml:

    applications:
    - path: ./target/vertxTestCF-1.0-fat.jar
      memory: 256M
      instances: 1
      name: vertxTestCf
      buildpack: https://github.com/cloudfoundry/java-buildpack.git#3.x
      env:
          JAVA_OPTS: -javaagent:target/quasar-core-0.7.5-jdk8.jar

Error message during deployment is :

[APP/PROC/WEB/0] ERR Error opening zip file or JAR manifest missing : target/quasar-core-0.7.5-jdk8.

Any hint will be helpful.

like image 340
Nikolay Petkov Avatar asked Dec 06 '25 16:12

Nikolay Petkov


1 Answers

You're on the right track by using JAVA_OPTS, but the path you're setting is wrong. It's the path on your local machine, however, the code is running on Cloud Foundry which will have a different path.

JAVA_OPTS: -javaagent:target/quasar-core-0.7.5-jdk8.jar

Based on your manifest.yml, you are pushing this file:

 - path: ./target/vertxTestCF-1.0-fat.jar

That means the root of your application is going to be the root of this JAR file. That's essentially what path means. The root of your app on CF will start with the path you specify.

Thus, if you need to reference quasar-core-0.7.5-jdk8.jar it would need to be included in vertxTestCF-1.0-fat.jar and the relative path to quasar-core-0.7.5-jdk8.jar would be the path where you put the file inside vertxTestCF-1.0-fat.jar.

Ex:

I have test-fat.jar. Inside it I hav another JAR located at lib/my-second.jar. If I need to reference the second JAR, it would be -javaagent:lib/my-second.jar.

Hope that helps!

like image 123
Daniel Mikusa Avatar answered Dec 08 '25 08:12

Daniel Mikusa