java - Running Spring app built with gradle on Heroku -



java - Running Spring app built with gradle on Heroku -

i have problem spring application built gradle. app includes mongodb(mongohq heroku).

i managed how force on heroku, i've added code project:

@configuration public class mongohqconfiguration { public @bean mongodbfactory mongodbfactory() throws mongoexception, unknownhostexception { homecoming new simplemongodbfactory(new mongouri(system.getenv("mongohq_url"))); } public @bean mongotemplate mongotemplate() throws exception { homecoming new mongotemplate(mongodbfactory()); } }

after changing buildpacks 1 gradle, pushed on heroku free business relationship mongohq sandbox.

but after trying run app through web browser, i'm getting error:

an error occurred in application , page not served. please seek 1 time again in few moments.

if application owner, check logs details.

heroku logs gives me output:

2014-10-15t18:19:30.293964+00:00 heroku[web.1]: starting process command java -xmx384m -xss512k -xx:+usecompressedoops -jar build/libs/*.jar

2014-10-15t18:19:30.797673+00:00 app[web.1]: error: unable access jarfile build/libs/*.jar

2014-10-15t18:19:31.474525+00:00 heroku[web.1]: state changed starting crashed

2014-10-15t18:19:31.464753+00:00 heroku[web.1]: process exited status 1

2014-10-15t18:19:32.577398+00:00 heroku[router]: at=error code=h10 desc="app crashed" method=get path="/" host=tvmaniac.herokuap p.com request_id=7e8bfe6c-2669-405e-9bce-59fde09f71ef fwd="89.129.247.185" dyno= connect= service= status=503 bytes=

2014-10-15t18:19:34.016281+00:00 heroku[router]: at=error code=h10 desc="app crashed" method=get path="/favicon.ico" host=tvmani ac.herokuapp.com request_id=4300386e-dc5c-47ed-9878-0bee87128fc9 fwd="89.129.247.185" dyno= connect= service= status=503 bytes=

2014-10-15t18:19:41.988204+00:00 heroku[router]: at=error code=h10 desc="app crashed" method=get path="/" host=tvmaniac.herokuap p.com request_id=436db871-ea8c-428f-8cc7-160c3cb96a2d fwd="50.16.146.194" dyno= connect= service= status=503 bytes=

i think problem in procfile, have no thought should add together there, here's current code:

default_process_types:

web: java $java_opts -jar build/libs/*.jar

edited

here's build.gradle:

buildscript { repositories { maven { url "http://repo.spring.io/libs-release" } mavencentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.8.release") } } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'spring-boot' mainclassname = "com.shalastra.tvmaniac.tvmaniacconfiguration" jar { basename = 'tvmaniac' version = '0.1.0' } repositories { mavencentral() maven { url "http://repo.spring.io/libs-release" } maven { url "http://m2.neo4j.org" } } dependencies { compile("org.springframework.boot:spring-boot-starter-web") compile("org.springframework.boot:spring-boot-starter-actuator") testcompile("junit:junit") compile("org.springframework.data:spring-data-rest-webmvc") compile("org.springframework.data:spring-data-mongodb") compile("com.google.guava:guava:17.0") compile("org.apache.commons:commons-lang3:3.3.2") } task wrapper(type: wrapper) { gradleversion = '2.0' } task stage(dependson: ['clean', 'build', 'installapp'])

thanks in advance help.

after short give-and-take in comments seems (according this instructions) need add together next task build.gradle file:

task stage(type: copy, dependson: [clean, build]) { jar.archivepath project.rootdir rename { 'app.jar' } } stage.mustrunafter(clean) clean << { project.file('app.jar').delete() }

and content of procfile be:

web: java $java_opts -jar app.jar

now should work fine.

explanation:

task stage prepares jar file run. after it's finished output jar copied project.rootdir , renamed app.jar. guarantees have same name , can run command procfile. stage task depends on clean (which has additional action remove app.jar) , build (which builds app). it's of import set stage.mustrunafter(clean) because otherwise order in tasks run not determined (this happens - check locally). mean if dependson specified build may run, clean , stage - , nil created. hope it's clear.

java spring heroku deployment gradle

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -