Heroku: Unable to connect to middleware. Middleware block 'app-core' failed to start

Hi everyone, help the guys. repeat everything step by step from the tutorial , and an error occurs when opening the app. Rechecked everything - everything was done correctly. Where should I look ? Errors attached. Thanks


buildscript {
    ext.cubaVersion = '7.2.4'
    repositories {
        maven {
            url 'https://dl.bintray.com/cuba-platform/main'
            
        }
        jcenter()

        
    }
    dependencies {
        classpath "com.haulmont.gradle:cuba-plugin:$cubaVersion"
    }
}

def modulePrefix = 'app'

def globalModule = project(":${modulePrefix}-global")
def coreModule = project(":${modulePrefix}-core")
def webModule = project(":${modulePrefix}-web")

def servletApi = 'javax.servlet:javax.servlet-api:3.1.0'

apply(plugin: 'cuba')

cuba {
    artifact {
        group = 'com.company.test'
        version = '0.1'
        isSnapshot = true
    }
}

dependencies {
    appComponent("com.haulmont.cuba:cuba-global:$cubaVersion")
}

def postgres = 'org.postgresql:postgresql:42.2.9'

configure([globalModule, coreModule, webModule]) {
    apply(plugin: 'java')
    apply(plugin: 'maven')
    apply(plugin: 'cuba')

    dependencies {
            testCompile('org.junit.jupiter:junit-jupiter-api:5.5.2')
            testCompile('org.junit.jupiter:junit-jupiter-engine:5.5.2')
            testCompile('org.junit.vintage:junit-vintage-engine:5.5.2')  
        }

    task sourceJar(type: Jar) {
        from file('src')
        classifier = 'sources'
    }

    artifacts {
        archives sourceJar
    } 
    test {
        useJUnitPlatform()
    }
}


configure(globalModule) {
    dependencies {
        if (!JavaVersion.current().isJava8()) {
            runtime('javax.xml.bind:jaxb-api:2.3.1')
            runtime('org.glassfish.jaxb:jaxb-runtime:2.3.1')
        }
    }

    entitiesEnhancing {
        main {
            enabled = true
        }
    }
}

configure(coreModule) {

    configurations {
        jdbc
        dbscripts
    }

    dependencies {
        compile(globalModule)
        compileOnly(servletApi)
        jdbc(postgres)
        testRuntime(postgres)
    }

    task cleanConf(description: 'Cleans up conf directory', type: Delete) {
        delete "$cuba.appHome/${modulePrefix}-core/conf"
    }

    task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
        appName = "${modulePrefix}-core"
        appJars(modulePrefix + '-global', modulePrefix + '-core')
    }

    task createDb(dependsOn: assembleDbScripts, description: 'Creates local database', type: CubaDbCreation) {
    }

    task updateDb(dependsOn: assembleDbScripts, description: 'Updates local database', type: CubaDbUpdate) {
    }
}

configure(webModule) {
    configurations {
        webcontent
    }

    dependencies {
        compileOnly(servletApi)
        compile(globalModule)
    }

    task webArchive(type: Zip) {
        from file("$buildDir/web")
        from file('web')
        classifier = 'web'
    }

    artifacts {
        archives webArchive
    }

    task deployConf(type: Copy) {
        from file('src')
        include "com/company/test/**"
        into "$cuba.appHome/${modulePrefix}/conf"
    }

    task clearMessagesCache(type: CubaClearMessagesCache) {
        appName = "${modulePrefix}"
    }
    deployConf.dependsOn clearMessagesCache

    task cleanConf(description: 'Cleans up conf directory', type: Delete) {
        delete "$cuba.appHome/${modulePrefix}/conf"
    }

    task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
        appName = "${modulePrefix}"
        appJars(modulePrefix + '-global', modulePrefix + '-web')
    }
}

task undeploy(type: Delete, dependsOn: ":${modulePrefix}-web:cleanConf") {
    delete("$cuba.tomcat.dir/shared")
    delete("$cuba.tomcat.dir/webapps/${modulePrefix}-core")
    delete("$cuba.tomcat.dir/webapps/${modulePrefix}")
}

task stage(dependsOn: ['setupTomcat', ':app-core:deploy', ':app-web:deploy']) {
    doLast {
        // replace context.xml with heroku-context.xml
        def src = new File('modules/core/web/META-INF/heroku-context.xml')
        def dst = new File('deploy/tomcat/webapps/app-core/META-INF/context.xml')
        dst.delete()
        dst << src.text

        // change port from 8080 to heroku $PORT
        def file = new File('deploy/tomcat/conf/server.xml')
        file.text = file.text.replace('8080', '${port.http}')

        // add local.app.properties for core application
        def coreConfDir = new File('deploy/tomcat/conf/app-core/')
        coreConfDir.mkdirs()
        def coreProperties = new File(coreConfDir, 'local.app.properties')
        coreProperties.text = ''' cuba.automaticDatabaseUpdate = true '''

        // rename deploy/tomcat/webapps/app to deploy/tomcat/webapps/ROOT
        def rootFolder = new File('deploy/tomcat/webapps/ROOT')
        if (rootFolder.exists()) {
            rootFolder.deleteDir()
        }

        def webAppDir = new File('deploy/tomcat/webapps/app')
        webAppDir.renameTo( new File(rootFolder.path) )

        // add local.app.properties for web application
        def webConfDir = new File('deploy/tomcat/conf/ROOT/')
        webConfDir.mkdirs()
        def webProperties = new File(webConfDir, 'local.app.properties')
        webProperties.text = ''' cuba.webContextName = / '''
    }
}

task restart(dependsOn: ['stop', ":${modulePrefix}-core:deploy", ":${modulePrefix}-web:deploy"], description: 'Redeploys applications and restarts local Tomcat') {
    doLast {
        ant.waitfor(maxwait: 6, maxwaitunit: 'second', checkevery: 2, checkeveryunit: 'second') {
            not {
                socket(server: 'localhost', port: '8787')
            }
        }
    }
}
restart.finalizedBy start


image

spacecorpsv-logs-1589896561744.txt (238.8 KB)

https://github.com/svgetm/testsimple

Hi,

we need the logs of herokus attempt to start the server.
I will try to reproduce this problem later on.

Meanwhile maybe this is helpful for you: Deploy CUBA to Heroku in ten steps - CUBA.Platform

Cheers
Nico

Sorry,

I didn’t see the logfile.

The problem is that the db is specified as localhost connection.

2020-05-19T13:54:55.831894+00:00 app[web.1]: Some environment checks failed on core module:
2020-05-19T13:54:55.831894+00:00 app[web.1]: Exception occurred while connecting to data store _MAIN_
2020-05-19T13:54:55.831895+00:00 app[web.1]: 	org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

You need to adopt the db settings from step 6 & 7 from the mentioned tutorial

Deploy CUBA to Heroku in ten steps - CUBA.Platform

Cheers

2 Likes

Thank you very much !!! Nowhere in the documentation was it specified to change in properties as specified in paragraph 7. Thank you again !!!