grails / grails-core

The Grails Web Application Framework
http://grails.org
Apache License 2.0
2.78k stars 949 forks source link

Grails 4.0.1 running jar "port already in use", but Grails 4.0.0 works #11470

Closed leandrokohlrausch closed 4 years ago

leandrokohlrausch commented 4 years ago

Using grails 4.0.1 (last stable version) using running by command line occurred "port already in use", but same code using grails 4.0.0 works fine.

How i start my application :

java -jar myapplication.jar --spring.config.location=/path/where/stay/externalconfig-application.yml

build.gradle file it same for two versions (Grails 4.0.1 and 4.0.0):

buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "org.grails.plugins:hibernate5:7.0.0"
        classpath "gradle.plugin.com.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:2.0"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:$gradleAssetsPipelineVersion"
        classpath 'org.grails.plugins:quartz:2.0.13'        
        classpath 'org.codehaus.groovy:groovy-all:2.5.8'
    }
}

version "2.20.2"
group "myapplication"

apply plugin:"eclipse"
apply plugin:"idea"
//apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"com.github.erdi.webdriver-binaries"
apply plugin:"asset-pipeline"
apply plugin:"org.grails.grails-gsp"
apply plugin:"com.bertramlabs.asset-pipeline"

repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
    maven {
        url "https://www.oracle.com/content/secure/maven/content"
        name "maven.oracle.com"
        credentials {
            username "myemailoracleaccount@domain.com"
            password "mySecretPassword"
        }
    }
}

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

dependencies {
    developmentOnly("org.springframework.boot:spring-boot-devtools")
    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-web-boot"
    compile "org.grails:grails-logging"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-plugin-i18n"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-url-mappings"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:async"
    compile "org.grails.plugins:scaffolding"
    compile "org.grails.plugins:events"
    compile "org.grails.plugins:hibernate5"
    compile "org.hibernate:hibernate-core"
    compile "org.grails.plugins:gsp"
    compileOnly "io.micronaut:micronaut-inject-groovy"
    console "org.grails:grails-console"
    profile "org.grails.profiles:web"
    runtime "org.glassfish.web:el-impl:2.1.2-b03"
    runtime "com.h2database:h2"
    runtime "org.apache.tomcat:tomcat-jdbc"
    runtime "javax.xml.bind:jaxb-api"
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:$gradleAssetsPipelineVersion"
    testCompile "org.grails:grails-gorm-testing-support"
    testCompile "org.mockito:mockito-core"
    testCompile "org.grails:grails-web-testing-support"
    testCompile "org.grails.plugins:geb"
    testCompile "org.seleniumhq.selenium:selenium-remote-driver:3.14.0"
    testCompile "org.seleniumhq.selenium:selenium-api:3.14.0"
    testCompile "org.seleniumhq.selenium:selenium-support:3.14.0"
    testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:3.14.0"
    testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:3.14.0"
    compile group: 'org.apache.commons', name: 'commons-email', version: '1.5'
    compile group: 'com.oracle', name: 'ojdbc6', version: '11.2.0.3'
    compile 'org.grails.plugins:quartz:2.0.13'
    compile 'org.quartz-scheduler:quartz:2.2.1' // Is not pulled in by default?
    compile fileTree(dir: 'lib', include: '*.jar')

    compile('com.lowagie:itext:2.1.7')
    compile group: 'net.sf.jasperreports', name: 'jasperreports', version: '6.9.0'
    compile group: 'net.sourceforge.barbecue', name: 'barbecue', version: '1.5-beta1'
    compile group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0.1'
    compile group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.2'
    runtime 'org.grails.plugins:grails-melody-plugin:1.80.0'
}

bootRun {
    jvmArgs = ['-Xms512m', '-Xmx1280m', '-Dspring.output.ansi.enabled=always','-noverify', '-XX:TieredStopAtLevel=1']
    sourceResources sourceSets.main
    String springProfilesActive = 'spring.profiles.active'
    systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}

webdriverBinaries {
    chromedriver '2.45.0'
    geckodriver '0.24.0'
}

tasks.withType(Test) {
    systemProperty "geb.env", System.getProperty('geb.env')
    systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
    systemProperty "webdriver.chrome.driver", System.getProperty('webdriver.chrome.driver')
    systemProperty "webdriver.gecko.driver", System.getProperty('webdriver.gecko.driver')
}

assets {
    minifyJs = true
    minifyCss = true
}

Externalconfig YML file (externalconfig-application.yml)

---
grails:
    profile: web
    codegen:
        defaultPackage: applicationpackage
    spring:
        transactionManagement:
            proxies: false
    gorm:
        # Whether to autowire entities. 
        # Disabled by default for performance reasons.
        autowire: false
        reactor:
            # Whether to translate GORM events into Reactor events
            # Disabled by default for performance reasons
            events: false
info:
    app:
        name: '@info.app.name@'
        version: '@info.app.version@'
        grailsVersion: '@info.app.grailsVersion@'
spring:
    jmx:
        unique-names: true
    main:
        banner-mode: "off"
    groovy:
        template:
            check-template-location: false
    devtools:
        restart:
            additional-exclude:
                - '*.gsp'
                - '**/*.gsp'
                - '*.gson'
                - '**/*.gson'
                - 'logback.groovy'
                - '*.properties'
management:
    endpoints:
        enabled-by-default: false
server:
    port: 8090
    ssl:
        enabled: true
        key-store: /path/where/stay/keystore.p12
        key-store-password: keystorepassword
        keyStoreType: PKCS12
        keyAlias: keyalias
    session:
    #timeout: 3600  #seconds
---
grails:
    mime:
        disable:
            accept:
                header:
                    userAgents:
                    - Gecko
                    - WebKit
                    - Presto
                    - Trident
        types:
            all: '*/*'
            atom: application/atom+xml
            css: text/css
            csv: text/csv
            form: application/x-www-form-urlencoded
            html:
            - text/html
            - application/xhtml+xml
            js: text/javascript
            json:
            - application/json
            - text/json
            multipartForm: multipart/form-data
            pdf: application/pdf
            rss: application/rss+xml
            text: text/plain
            hal:
            - application/hal+json
            - application/hal+xml
            xml:
            - text/xml
            - application/xml
    urlmapping:
        cache:
            maxsize: 1000
    controllers:
        defaultScope: singleton
        upload:
            maxFileSize: 4000000
            maxRequestSize: 42000000
    converters:
        encoding: UTF-8
    views:
        default:
            codec: html
        gsp:
            encoding: UTF-8
            htmlcodec: xml
            codecs:
                expression: html
                scriptlets: html
                taglib: none
                staticparts: none
management:
    endpoints:
        jmx:
            unique-names: true
---
hibernate:
    allow_update_outside_transaction: true
    format_sql: true
    cache:
        queries: false
        use_second_level_cache: false
        use_query_cache: false
dataSource:
    pooled: true
    jmxExport: true
    driverClassName: oracle.jdbc.OracleDriver
    dialect: org.hibernate.dialect.Oracle10gDialect
    username: username
    password: password
    dbCreate: "none"
    logSql: true

environments:
    development:
        dataSource:
            url: jdbc:oracle:thin:@127.0.0.1:1521:xe
    test:
        dataSource:
            url: jdbc:oracle:thin:@127.0.0.1:1521:xe
    production:
        dataSource:
            url: jdbc:oracle:thin:@127.0.0.1:1521:xe
            properties:
                jmxEnabled: true
                initialSize: 5
                maxActive: 50
                minIdle: 5
                maxIdle: 25
                maxWait: 10000
                maxAge: 600000
                timeBetweenEvictionRunsMillis: 5000
                minEvictableIdleTimeMillis: 60000
                validationQuery: SELECT 1 FROM DUAL
                validationQueryTimeout: 3
                validationInterval: 15000
                testOnBorrow: true
                testWhileIdle: true
                testOnReturn: false
                jdbcInterceptors: ConnectionState
                defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
javamelody:
    disabled: false
    sql-transform-pattern: \d+
    http-transform-pattern: \d+

Gradle properties file :

grailsVersion=4.0.1
gorm.version=7.0.2.RELEASE
gradleWrapperVersion=5.0
gradleAssetsPipelineVersion=3.0.10

Using grailsVersion=4.0.1 dont work, but change for grailsVersion=4.0.0 works.

grailsVersion=4.0.0
gorm.version=7.0.2.RELEASE
gradleWrapperVersion=5.0
gradleAssetsPipelineVersion=3.0.10

How i generate jar file .

Using gradle build tasks

1 - clean 2 - build 3 - assemble

In the development environment it is working, but when I generate the executable (jar) the error "port already in use" occurs. I execute command line 'fuser -n tcp 8090' not have process using on this port.

Thanks for your attention and sorry for my bad english. If you want more informations, i will be available

leandrokohlrausch commented 4 years ago

I updated project to Grails 4.0.2 and the problem is solved. I dont know, but works from me lol

Thanks for your attention