1
votes

I have a project in which I'm working that it is made, among everything, with Java 11+Spring Boot+Gradle.
All of a sudden, when I press play on IntelliJ Idea Ultimate 2019.3 I'm getting the following error.

<String that tells the given command for launching the app>
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.4.RELEASE)

org.springframework.boot.web.embedded.tomcat.ConnectorStartFailedException: Connector configured to listen on port 8080 failed to start
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.checkConnectorHasStarted(TomcatWebServer.java:232)
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.checkThatConnectorsHaveStarted(TomcatWebServer.java:224)
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:202)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:311)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:164)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
    at it.niuma.epp.EPPApplication.main(EPPApplication.java:79)

Process finished with exit code 0

And that's just it. The code of the Main class is made just by these lines

@EnableScheduling
@EnableAsync
@SpringBootApplication(scanBasePackages = {list of packages})
public class EPPApplication implements WebMvcConfigurer {

    public static void main(String[] args) {
        /* Allows slash url encoding */
        // System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH",
        // "true");
            SpringApplication.run(EPPApplication.class, args);

    }

And if I don't surround the SpringApplication.run in a try-catch scope, I wouldn't even get the error.
The project tries to boot on port 8080, which is not occupied by anything. In fact, by typing

netstat -ano|findstr "PID :8080"

on my Windows machine, this is the result shown

C:\Users\Gianmarco>netstat -ano|findstr "PID :8080"
  Proto  Indirizzo locale          Indirizzo esterno        Stato           PID
  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       18152
  TCP    [::]:8080              [::]:0                 LISTENING       18152

When if I try to change to any other port possible, I always get the same error.

What am I missing? I've tried to see other similar questions on SO but nobody had my same issue

EDIT: The same happens on Eclipse as well

EDIT2: By following the debbuger starting from org.apache.catalina.connector.Connector.startInternal() I see that it even reaches the logger part in which it states that has started tomcat on port 8080 but this isn't logged on the console. Shortly after, I reach SpringApplication.java on line 400 which calls line 327 in which I see that a variable colled exceptionReporters (a collection) holds an expection. The following screenshot represent what this collection holds. After this point, though, it looks like I can't debug anymore but the application remains stuck

enter image description here

application.properties

EDIT3: As requested, here's my application.properties, my build.gradle

server.port=8080
application.base.path=/opt/epp
spring.datasource.tomcat.minSize=35
spring.datasource.tomcat.initialSize=35
spring.datasource.tomcat.maxActive=250

logging.config=file:config/logback.xml

datasource.type = oracle

# spring.mvc.throw-exception-if-no-handler-found=true
# spring.resources.add-mappings=false
# spring.mvc.static-path-pattern=/**
# spring.resources.static-locations=classpath:/static/

#MAIL CONFIG
spring.mail.default-encoding=UTF-8
[...]


# FROM OLD INTERNAL APPLICATION.PROPERTIES
server.servlet.context-path=/epp
spring.session.store-type=none
#logging.level.org.springframework.web=INFO
#logging.file=log/asta.log
#logging.pattern.file=="%d{dd-MMM-yyyy HH:mm:ss,SSS} %-5p [%c:%L]-> %m%n
spring.mustache.expose-session-attributes=true
spring.mustache.allow-request-override=true
#spring.mustache.allow-session-override=true
#server.session.cookie.max-age=60
#server.session.timeout=60
# Charset of HTTP requests and responses. Added to the "Content-Type" header if not set explicitly.
spring.http.encoding.charset=UTF-8
# Enable http encoding support.
spring.http.encoding.enabled=true
# Force the encoding to the configured charset on HTTP requests and responses.
spring.http.encoding.force=true
spring.servlet.multipart.max-file-size=150MB
spring.servlet.multipart.max-request-size=150MB
spring.mustache.suffix=.html

####### DEV ONLY, TO CHANGE IN PRODUCTION ##########
#logging.level.org.springframework.security=DEBUG
# see ldap.enabled
ldap.mock_email = false
debug.clientTrace = false
remember_me.cookie_only = true
remember_me.enabled_by_default = false
spring.mustache.cache = true
spring.cache.type = simple

#GESTIONE APERTURA VALUTAZIONE DA PARTE DEL BUYER
flg.can.buyer.evaluate=true
flg.gestione.prequalifica=false

#soglia di sbarramento in percentuale
soglia.sbarramento = 40

# in ambiente integrato va decommentato
# server.servlet.session.cookie.name = MYSESSIONID


zip.buffer.size = 8192

build.gradle

buildscript {
  dependencies {
    classpath ("org.hidetake:gradle-ssh-plugin:2.8.0")
  }
}

plugins {
    id 'org.springframework.boot' version '2.1.4.RELEASE'
    id 'java'
    id 'eclipse-wtp'
    id "org.zeroturnaround.gradle.jrebel" version "1.1.8"
}

apply plugin: 'org.hidetake.ssh'
apply plugin: 'io.spring.dependency-management'

jar.dependsOn(generateRebel)

compileJava {
    options.encoding = 'UTF-8' 
}

bootJar {
    launchScript()
}

springBoot {
    buildInfo {
        properties {
            artifact = 'EPP-ORDER NTT'
            version = project.hasProperty('buildversion') ? buildversion: ''
            group = 'it.niuma.epp'
            name = 'test+order'
            additionalProperties = [
                operatingSystem: "${System.properties['os.name']} (${System.properties['os.version']})",
                //machine: InetAddress.localHost.hostName,
            ]
        }       
    }
}

archivesBaseName = project.hasProperty('archives_base_name') ? archives_base_name : 'epp'
ext.jarPath = project.hasProperty('jarPath') ? "${projectDir}/${jarPath}" : "${buildDir}/libs/epp.jar"

//archivesBaseName = project.hasProperty('archives_base_name') ? archives_base_name : 'supplier_portal'
//ext.jarPath = project.hasProperty('jarPath') ? "${projectDir}/${jarPath}" : "${buildDir}/libs/supplier_portal.jar"

ext.deployPath = project.hasProperty('deployPath') ? deployPath : '/opt/epp'

sourceCompatibility = 11
targetCompatibility = 11

repositories {
    mavenCentral()
    maven {
      url "https://plugins.gradle.org/m2/"
    }
}

dependencies {
    // Framework - START
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation('org.springframework.boot:spring-boot-starter-data-rest')
    implementation('org.springframework.boot:spring-boot-starter-jdbc')
    implementation('org.springframework.boot:spring-boot-starter-websocket')
    implementation('org.springframework.boot:spring-boot-starter-mustache')
    implementation('com.github.sps.mustache:mustache-spring-view:1.4')
    implementation('org.springframework.boot:spring-boot-starter-mail')
    implementation('org.springframework.boot:spring-boot-starter-web-services')
    implementation('org.springframework.boot:spring-boot-starter-security')
    implementation('org.springframework.security:spring-security-ldap')

    // required by LDAP (spring-ldap bug?)
    implementation group: 'commons-pool', name: 'commons-pool', version: '1.6'

    // required by Logback for conditional processing
    implementation group: 'org.codehaus.janino', name: 'janino', version: '3.0.12'

    // Framework - END

    // DB - START
    implementation('org.sql2o:sql2o:1.6.0-RC3')
    implementation group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '7.2.1.jre11'
    // FOR INTEGRATION TEST DB
    implementation files('libs/ojdbc8.jar')
    implementation('org.sql2o.extensions:sql2o-oracle:1.6.0-RC3') {
        exclude group:'com.oracle'
    }
    // DB - END

    // Excel support - START
    implementation('org.apache.poi:poi:3.16')
    implementation('org.apache.poi:poi-ooxml:3.16') {
        exclude group:'stax', module: 'stax-api'
    }
    // Excel support - END

    // Cerved - START
    implementation files('libs/CervedObject.jar')
    implementation files('libs/CervedWebServices.jar')
    implementation group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.2'
    implementation group: 'com.sun.istack', name: 'istack-commons-runtime', version: '3.0.8'
    // Cerved - END

    // START FLYING SAUCER
    implementation group: 'org.xhtmlrenderer', name: 'flying-saucer-pdf-openpdf', version: '9.1.18'
    implementation group: 'org.jsoup', name: 'jsoup', version: '1.11.3'
    // END FLYING SAUCER

    // START DSS
    implementation('org.digidoc4j.dss:dss-pades:5.2.d4j.3')
    implementation group: 'org.digidoc4j.dss', name: 'dss-service', version: '5.2.d4j.3'
    implementation group: 'org.digidoc4j.dss', name: 'dss-token', version: '5.2.d4j.3'
    implementation group: 'org.digidoc4j.dss', name: 'dss-utils-apache-commons', version: '5.2.d4j.3'
    // END DSS

    // START UNIT TEST 1
    testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude group: 'junit', module: 'junit'
    }
    testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.4.2'
    testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.4.2'
    testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.4.2'
    testImplementation group: 'org.junit.platform', name: 'junit-platform-commons', version: '1.4.2'
    testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.4.2'
    // END UNIT TEST 1

    // MISCELLANEOUS - START

    implementation group: 'org.iban4j', name: 'iban4j', version: '3.2.1'
    implementation group: 'org.hibernate', name: 'hibernate-validator', version: '6.0.8.Final'
    implementation 'com.opencsv:opencsv:4.0'
    implementation group: 'org.unbescape', name: 'unbescape', version: '1.1.6.RELEASE'

    // MISCELLANEOUS - END


    /***** TOREMOVE - START *****/

    // iText 5 - START
    implementation('com.itextpdf:itextpdf:5.5.11')
    implementation('com.itextpdf.tool:xmlworker:5.5.11')
    // iText 5 - END

    /***** TOREMOVE - END *****/



    /* ORDER Dependecies */
    compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
    compile group: 'org.digidoc4j.dss', name: 'dss-utils-google-guava', version: '5.2.d4j.3'
    compile group: 'org.xhtmlrenderer', name: 'flying-saucer-pdf-openpdf', version: '9.1.12'

    // https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-rt
    compile group: 'com.sun.xml.ws', name: 'jaxws-rt', version: '2.3.2'

    // https://mvnrepository.com/artifact/org.passay/passay
    compile group: 'org.passay', name: 'passay', version: '1.4.0'

    // SWAGGER
    /*****compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
    compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'

   // LOMBOK
    compile group: 'org.projectlombok', name: 'lombok', version: '1.18.10' *****/

   // MODEL MAPPER
    compile group: 'org.modelmapper.extensions', name: 'modelmapper-spring', version: '2.3.2'






}


// START UNIT TEST 2
test {
    useJUnitPlatform()
}
test.enabled = gradle.startParameter.taskNames.contains('test') || gradle.startParameter.taskNames.contains('check')
// END UNIT TEST 2

// Remote administration - START

remotes {
  server {
    deleted sensible data
  }
}

ssh.settings {
  logging = 'stdout'
    knownHosts = allowAnyHosts
}

task copyjar {
  doLast {
    if (!project.hasProperty('ip')){
      logger.lifecycle("No IP - Launch with -Pip=xxx.xxx.xxx.xxx");
      throw new StopExecutionException()
    }

    logger.lifecycle("Copying... <$jarPath to $deployPath>") 

    ssh.run{
      session(remotes.server) {
        put from: jarPath, into: deployPath
      }
    }
  }
}

task stopServer {
  doLast {
    if (!project.hasProperty('ip')){
      logger.lifecycle("No IP - Launch with -Pip=xxx.xxx.xxx.xxx");
      throw new StopExecutionException()
    }
    logger.lifecycle("Execute stopServer on $remotes.server.host");

    if (project.hasProperty('cmd')){
        cmd = project.hasProperty('cmd') ? cmd : ''
        ssh.run {
        session(remotes.server) {
           execute cmd
        }
      }
    } else {
    ssh.run {
      session(remotes.server) {
        execute 'sudo systemctl stop epp.service'
      }
    }
  }
}
}

task startServer{
  doLast {
    if (!project.hasProperty('ip')){
      logger.lifecycle("No IP - Launch with -Pip=xxx.xxx.xxx.xxx");
      throw new StopExecutionException()
    }
    logger.lifecycle("Execute stopServer on $remotes.server.host");

    if (project.hasProperty('cmd')){
        cmd = project.hasProperty('cmd') ? cmd : ''
        ssh.run {
           session(remotes.server) {
              execute cmd
           }
        }
    } else {
      ssh.run {
        session(remotes.server) {
        execute 'sudo systemctl start epp.service'
         }
      }
    }
  }
}

// Remote administration - STOP

task copyBuildFiles(type: Copy) {
    from file("application.properties")
    into ("$buildDir/libs/")
}

build.dependsOn(copyBuildFiles)
1
Is there any earlier log output? Tomcat should log something when it fails to start the connector. Failing that, you could debug the application with a breakpoint on org.apache.catalina.connector.Connector.startInternal() and step through the code to see what the failure actually is.Andy Wilkinson
Somewhat related, if that's all the output that's being produced, you may have a problem with some logging related dependencies. For example, a dependency on commons-logging:commons-logging can caused problems and should be excluded in favour of spring-jcl.Andy Wilkinson
@PatelRomil yes, no luck at allGianmarco F.
@AndyWilkinson I don't have a dependency like commons-logging, so I wouldn't really now even where to start to eliminate dependecies... As for the debugger, I've followed all the process and it doesn't bring to a crash point. It even reaches the logger part in which it states that has started tomcat on port 8080 but this isn't logged on the console. Shortly after, I reach SpringApplication.java on line 400 which calls line 327 in which I see that a variable colled exceptionReporters (a collection) holds an expection. Screen in the postGianmarco F.

1 Answers

2
votes

Given the lack of logging output, you may have a problem with some logging related dependencies. For example, a dependency on commons-logging:commons-logging can cause problems and should be excluded in favour of org.springframework:spring-jcl. org.slf4j:jcl-over-slf4j should be treated similarly.

You can learn if you have either of these dependencies on the classpath using Gradle's dependencyInsight task:

gradle dependencyInsight --dependency commons-logging:commons-logging
gradle dependencyInsight --dependency org.slf4j:jcl-over-slf4j