Date
1 - 7 of 7
Failing to push standalone java app
Rahul Gupta
Hi,
I am trying to push a standalone Java app that has a 'public static void main(..)' and uses other dependencies. I tried setting the classpath in the jar's MANIFEST.MF, created a new jar that also contains dependent jars in its root and did a cf push but that didn't help either - the 'cf push -p xxxxxxx.jar' fails while resolving runtime dependencies e.g. ERR Exception in thread "main" java.lang.NoClassDefFoundError: com/XXX/client/AbcXyz Here is the content of manifest.mf: Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Built-By: smokingfly Class-Path: XXX-123.jar AAA.789.jar Created-By: Apache Maven 3.2.3 Build-Jdk: 1.8.0_40 Main-Class: com.cf.samples.TestClient TestClient is the class with main method. I could not find any documentation that could help me with this. Could someone please help? Many thanks. |
|
Rahul Gupta
Forgot to mention that all the dependencies are correctly configured in pom.xml
|
|
Daniel Mikusa
Adding a "Class-Path:" entry to a MANIFEST.MF file seems to work for me.
toggle quoted message
Show quoted text
The two entries were present in the command that was generated by the build pack. Ex: `CALCULATED_MEMORY=$($PWD/.java-buildpack/open_jdk_jre/bin/java-buildpack-memory-calculator-2.0.1_RELEASE -memorySizes=metaspace:64m.. -memoryWeights=heap:75,metaspace:10,native:10,stack:5 -memoryInitials=heap:100%,metaspace:100% -totMemory=$MEMORY_LIMIT) && JAVA_OPTS="-Djava.io.tmpdir=$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/killjava.sh $CALCULATED_MEMORY" && SERVER_PORT=$PORT eval exec $PWD/.java-buildpack/open_jdk_jre/bin/java $JAVA_OPTS -cp $PWD/.:$PWD/.java-buildpack/spring_auto_reconfiguration/spring_auto_reconfiguration-1.10.0_RELEASE.jar *:$PWD/another-new.jar:$PWD/some-new.jar* org.springframework.boot.loader.JarLauncher` This was with v3.4. If you're on an older version, you might try upgrading. Do you see your entries listed in the start command that's generated by the build pack? Dan On Tue, Dec 15, 2015 at 11:19 PM, Rahul Gupta <wildnez(a)gmail.com> wrote:
Forgot to mention that all the dependencies are correctly configured in |
|
Rahul Gupta
I had to resort to using 'Procfile' + creating big fat jar with dependent jars inside. So the application worked but it crashes after a little while.
The application starts, makes a connection with a remote db server and goes in an infinite loop that sleeps for 5 seconds and sysout something. I did this to ensure app was running long enough for the 'cf push' process to show that 1 out of 1 instance running, 1 running, but that did not happen. The application runs, makes connection, goes inside the infinite loop and then crashes. Here are the logs: 2015-12-17T13:52:32.04+0530 [App/0] OUT Connection with server established... sleeping for 5 seconds... 2015-12-17T13:52:37.10+0530 [App/0] OUT Distributed Map size: 0 2015-12-17T13:52:37.10+0530 [App/0] OUT ***************** XXXXXXXXX **************** 2015-12-17T13:52:37.10+0530 [App/0] OUT Printing Environment variables... 2015-12-17T13:52:37.10+0530 [App/0] OUT {}Woke up... bye bye !! 2015-12-17T13:52:37.10+0530 [App/0] OUT In a loop. Waiting for 5 seconds.... 2015-12-17T13:52:42.10+0530 [App/0] OUT In a loop. Waiting for 5 seconds.... 2015-12-17T13:52:47.10+0530 [App/0] OUT In a loop. Waiting for 5 seconds.... 2015-12-17T13:52:52.10+0530 [App/0] OUT In a loop. Waiting for 5 seconds.... 2015-12-17T13:52:57.10+0530 [App/0] OUT In a loop. Waiting for 5 seconds.... 2015-12-17T13:53:02.10+0530 [App/0] OUT In a loop. Waiting for 5 seconds.... 2015-12-17T13:53:07.10+0530 [App/0] OUT In a loop. Waiting for 5 seconds.... 2015-12-17T13:53:12.10+0530 [App/0] OUT In a loop. Waiting for 5 seconds.... 2015-12-17T13:53:17.10+0530 [App/0] OUT In a loop. Waiting for 5 seconds.... 2015-12-17T13:53:22.10+0530 [App/0] OUT In a loop. Waiting for 5 seconds.... 2015-12-17T13:53:27.10+0530 [App/0] OUT In a loop. Waiting for 5 seconds.... 2015-12-17T13:53:31.58+0530 [API/0] OUT App instance exited with guid bff76e66-3c91-4c9f-b38c-1cd384576156 payload: {"cc_partition"=>"default", "droplet"=>"bff76e66-3c91-4c9f-b38c-1cd384576156", "version"=>"6d1f4c31-96dd-4d13-b231-f0dc7306924c", "instance"=>"5e2fbac6edce472d98f9d7ba09d6e8dc", "index"=>0, "reason"=>"CRASHED", "exit_status"=>-1, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1450340611} 2015-12-17T13:53:31.58+0530 [DEA/0] ERR Instance (index 0) failed to start accepting connections 2015-12-17T13:53:31.88+0530 [DEA/0] OUT Removing crash for app with id bff76e66-3c91-4c9f-b38c-1cd384576156 2015-12-17T13:53:31.88+0530 [DEA/0] OUT Stopping app instance (index 0) with guid bff76e66-3c91-4c9f-b38c-1cd384576156 The remote db is a Hazelcast server process. Logging that confirms connection is: 2015-12-17T13:55:11.67+0530 [App/0] ERR Dec 17, 2015 8:25:11 AM com.hazelcast.core.LifecycleService 2015-12-17T13:55:11.67+0530 [App/0] ERR INFO: HazelcastClient[hz.client_0_dev][3.5.4] is STARTING 2015-12-17T13:55:11.89+0530 [App/0] ERR Dec 17, 2015 8:25:11 AM com.hazelcast.core.LifecycleService 2015-12-17T13:55:11.89+0530 [App/0] ERR INFO: HazelcastClient[hz.client_0_dev][3.5.4] is STARTED 2015-12-17T13:55:12.01+0530 [App/0] ERR Dec 17, 2015 8:25:12 AM com.hazelcast.core.LifecycleService 2015-12-17T13:55:12.01+0530 [App/0] ERR INFO: HazelcastClient[hz.client_0_dev][3.5.4] is CLIENT_CONNECTED 2015-12-17T13:55:12.02+0530 [App/0] ERR Dec 17, 2015 8:25:12 AM com.hazelcast.client.spi.impl.ClientMembershipListener 2015-12-17T13:55:12.02+0530 [App/0] ERR INFO: 2015-12-17T13:55:12.02+0530 [App/0] ERR Members [1] { 2015-12-17T13:55:12.02+0530 [App/0] ERR Member [10.234.84.216]:5701 2015-12-17T13:55:12.02+0530 [App/0] ERR } But strangely this also is considered as ERR by cloud foundry. Attached is the output of CF_TRACE cf push. Any idea what might be causing this? |
|
Rahul Gupta
Attached is the app-crash log.
|
|
Daniel Mikusa
Are you setting `--no-route` (or `no-route: true` in the manifest.yml)?
toggle quoted message
Show quoted text
Since your app is not listening for incoming web requests you need to tell CF that. Otherwise CF will continue to perform it's port health check (i.e. are you listening on the assigned port), which is going to fail. You're using a DEA, so that's all you need to do. With Diego, you need to also specifically disable the health check with `cf set-health-check app none` or in the manifest with `health-check-type: none`. The Hazelcast stuff is OK. It says "ERR" because the app wrote that to STDERR. Dan On Thu, Dec 17, 2015 at 3:44 AM, Rahul Gupta <wildnez(a)gmail.com> wrote:
I had to resort to using 'Procfile' + creating big fat jar with dependent |
|
Rahul Gupta
Cool. This worked. Thanks Dan.
|
|