2017-04-09 14 views
1

Heroku에서 Grails 3 앱을 배포하려고합니다.Heroku에서 Grails 3 앱을 배포 할 수 없습니다.

나는 this blog을 언급하고 각각의 단계마다 따라 갔지만, git push heroku master 명령을 실행하려고하면 다음과 같은 출력이 생성됩니다.

remote:  FAILURE: Build failed with an exception. 
remote:   
remote:  * What went wrong: 
remote:  Task 'stage' not found in root project 'build_6ce46a3ec9d8cecee177ef2d3589c9f1'. 
remote:   
remote:  * Try: 
remote:  Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 
remote:   
remote:  BUILD FAILED 
remote:   
remote:  Total time: 1 mins 2.541 secs 
remote: 
remote: !  ERROR: Failed to run Gradle! 
remote:  It looks like your project does not contain a 'stage' task, which Heroku needs in order 
remote:  to build your app. Our Dev Center article on preparing a Gradle application for Heroku 
remote:  describes how to create this task: 
remote:  https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku 
remote:   
remote:  If you're stilling having trouble, please submit a ticket so we can help: 
remote:  https://help.heroku.com 
remote:   
remote:  Thanks, 
remote:  Heroku 
remote: 
remote: !  Push rejected, failed to compile Gradle app. 
remote: 
remote: !  Push failed 
remote: Verifying deploy... 
remote: 
remote: ! Push rejected to employeedatabase. 
remote: 

그래서 출력에 따라, 나는 this 기사에게 Heroku에 의해 제공 참조 일부 변경했습니다. 이제 명령을 실행하려고 할 때마다 ./gradlew stage 모두 정상적으로 작동하지만 로컬로 heroku 앱을 실행하려고하면 다음 출력을 사용하여 heroku local web 출력이 생성됩니다.

[WARN] No ENV file found 
10:14:18 PM web.1 | Expanding EmployeeDatabase-0.1.war into /home/ankit/Desktop/Causecode/EmployeeDatabase/build/target/tomcat.5000/webapps/expanded 
10:14:18 PM web.1 | Adding Context for /home/ankit/Desktop/Causecode/EmployeeDatabase/build/target/tomcat.5000/webapps/expanded 
10:14:19 PM web.1 | Apr 09, 2017 10:14:19 PM org.apache.coyote.AbstractProtocol init 
10:14:19 PM web.1 | INFO: Initializing ProtocolHandler ["http-nio-5000"] 
10:14:19 PM web.1 | Apr 09, 2017 10:14:19 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector 
10:14:19 PM web.1 | INFO: Using a shared selector for servlet write/read 
10:14:19 PM web.1 | Apr 09, 2017 10:14:19 PM org.apache.catalina.core.StandardService startInternal 
10:14:19 PM web.1 | INFO: Starting service Tomcat 
10:14:19 PM web.1 | Apr 09, 2017 10:14:19 PM org.apache.catalina.core.StandardEngine startInternal 
10:14:19 PM web.1 | INFO: Starting Servlet Engine: Apache Tomcat/8.0.30 
10:14:19 PM web.1 | Apr 09, 2017 10:14:19 PM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment 
10:14:19 PM web.1 | INFO: No global web.xml found 
10:14:28 PM web.1 | Apr 09, 2017 10:14:28 PM org.apache.jasper.servlet.TldScanner scanJars 
10:14:28 PM web.1 | INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 
10:14:29 PM web.1 | Apr 09, 2017 10:14:29 PM org.apache.catalina.core.ApplicationContext log 
10:14:29 PM web.1 | INFO: 2 Spring WebApplicationInitializers detected on classpath 
10:14:33 PM web.1 | Exception in thread "main" org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]] 
10:14:33 PM web.1 |  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) 
10:14:33 PM web.1 |  at org.apache.catalina.startup.Tomcat.start(Tomcat.java:344) 
10:14:33 PM web.1 |  at webapp.runner.launch.Main.main(Main.java:261) 
10:14:33 PM web.1 | Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]] 
10:14:33 PM web.1 |  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) 
10:14:33 PM web.1 |  at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769) 
10:14:33 PM web.1 |  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
10:14:33 PM web.1 |  ... 2 more 
10:14:33 PM web.1 | Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]] 
10:14:33 PM web.1 |  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) 
10:14:33 PM web.1 |  at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441) 
10:14:33 PM web.1 |  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
10:14:33 PM web.1 |  ... 4 more 
10:14:33 PM web.1 | Caused by: org.apache.catalina.LifecycleException: A child container failed during start 
10:14:33 PM web.1 |  at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924) 
10:14:33 PM web.1 |  at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) 
10:14:33 PM web.1 |  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
10:14:33 PM web.1 |  ... 6 more 
[DONE] Killing all processes with signal null 
10:14:33 PM web.1 Exited with exit code 1 

이 내 Procfile입니다 :

web: cd build ; java -Dgrails.env=prod -jar ../build/server/webapp-runner-*.jar --expand-war --port $PORT libs/*.war 

이 내 build.gradle

buildscript { 
    ext { 
     grailsVersion = project.grailsVersion 
    } 
    repositories { 
     mavenLocal() 
     maven { url "https://repo.grails.org/grails/core" } 
    } 
    dependencies { 
     classpath "org.grails:grails-gradle-plugin:$grailsVersion" 
     classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.8.2" 
     classpath "org.grails.plugins:hibernate4:5.0.10" 
    } 
} 

plugins { 
    id "io.spring.dependency-management" version "0.4.0.RELEASE" 
} 

version "0.1" 
group "employeedatabase" 

apply plugin: "spring-boot" 
apply plugin:"eclipse" 
apply plugin:"idea" 
apply plugin:"war" 
apply plugin:"org.grails.grails-web" 
apply plugin:"org.grails.grails-gsp" 
apply plugin:"asset-pipeline" 

ext { 
    grailsVersion = project.grailsVersion 
    gradleWrapperVersion = project.gradleWrapperVersion 
} 

repositories { 
    mavenLocal() 
    maven { url "https://repo.grails.org/grails/core" } 
} 

dependencyManagement { 
    imports { 
     mavenBom "org.grails:grails-bom:$grailsVersion" 
    } 
    applyMavenExclusions false 
} 

dependencies { 
    compile "org.springframework.boot:spring-boot-starter-logging" 
    compile "org.springframework.boot:spring-boot-autoconfigure" 
    compile "org.grails:grails-core" 
    compile "org.springframework.boot:spring-boot-starter-actuator" 
    compile "org.springframework.boot:spring-boot-starter-tomcat" 
    compile "org.grails:grails-dependencies" 
    compile "org.grails:grails-web-boot" 
    compile "org.grails.plugins:cache" 
    compile "org.grails.plugins:scaffolding" 
    compile "org.grails.plugins:hibernate4" 
    compile "org.hibernate:hibernate-ehcache" 
    console "org.grails:grails-console" 
    profile "org.grails.profiles:web" 
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2" 

    runtime 'org.postgresql:postgresql:9.4-1201-jdbc4' 
    provided "org.springframework.boot:spring-boot-starter-tomcat" 

    //runtime "com.h2database:h2" 
    runtime "mysql:mysql-connector-java:5.1.29" 
    testCompile "org.grails:grails-plugin-testing" 
    testCompile "org.grails.plugins:geb" 
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1" 
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18" 

    compile 'org.eclipse.jetty:jetty-runner:9.2.11.v20150529' 
    compile 'com.github.jsimone:webapp-runner:8.0.30.2' 

    //adding spring security core plugin 
    compile 'org.grails.plugins:spring-security-core:3.0.3' 
    //adding oauth plugin 
    compile 'org.grails.plugins:oauth:3.0.1' 
} 

assets { 
    minifyJs = true 
    minifyCss = true 
} 

task wrapper(type: Wrapper) { 
    gradleVersion = gradleWrapperVersion 
} 

task stage() { 
    dependsOn clean, war 
} 
tasks.stage.doLast() { 
    delete fileTree(dir: "build/distributions") 
    delete fileTree(dir: "build/assetCompile") 
    delete fileTree(dir: "build/distributions") 
    delete fileTree(dir: "build/libs", exclude: "*.war") 
} 
war.mustRunAfter clean 

task copyToLib(type: Copy) { 
    into "$buildDir/server" 
    from(configurations.compile) { 
     include "webapp-runner*" 
    } 
} 

stage.dependsOn(copyToLib) 

내가 사용하고 Grails는 3.1.10입니다. Heroku에 Grails 3 앱을 성공적으로 배포 한 경우 단계별 방법을 사용하는 것이 값어치가 없습니다.

+0

Heroku에서 앱을 실행할 때 ('stage' 작업 추가 후) 동일한 예외가 발생합니까? – codefinger

+0

@codefinger : 예! –

답변

0

나는 Heroku에 대한 경험이 없지만 귀하의 build.gradle에 문제가 있습니다. 당신에게 Heroku에 Grails의 3 응용 프로그램을 실행하기위한 언급 한 그 문서의 링크는 두 종속성을 추가하도록 요청하여 build.gradle

runtime 'postgresql:postgresql:8.4-702.jdbc3' 
provided "org.springframework.boot:spring-boot-starter-tomcat" 

하지만 의존성 org.springframework.boot:spring-boot-starter-tomcat이 이미 존재하는 당신의 build.gradle 때문에 중복 종속성이 범위 compile에서.

org.springframework.boot:spring-boot-starter-tomcat은 Grails 3에서 제공하는 임베디드 톰캣으로 독립 실행 형 톰캣에 배포하려는 경우 제거해야합니다. 그렇지 않으면 포함 된 톰캣에서 WAR를 실행하면 두 개의 tomcat 인스턴스가 생성되고 오류가 전부입니다. docs에 따르면

: 톰캣의 다른 버전으로 배포하는 경우 기본적으로 Grails는이 WAR 파일 내의 톰캣의 임베디드 버전을 포함 할 것

참고,이 문제가 발생할 수 있습니다.

provided "org.springframework.boot:spring-boot-starter-tomcat" 

그래서 제거 고려 : 당신이 포함 된 컨테이너를 사용하지 않는 경우에 당신은 build.gradle에서 생산 컨테이너에 배포하기 전에 제공에 종속성 톰캣의 범위를 변경해야 라인 compile "org.springframework.boot:spring-boot-starter-tomcat".