Error starting Tomcat using Gradle Tomcat Plugin, getting JVM_Bind error


(Kasturi Kumthekar) #1

I am getting the

java.net.BindException: Address already in use: JVM_Bind

error.

gradle tomcatRunWar --info --stacktrace
......
Tomcat server exiting.
:tomcatRun FAILED
  FAILURE: Build failed with an exception.
  * What went wrong:
Execution failed for task ':tomcatRun'.
> An error occurred starting the Tomcat server.
  * Try:
Run with --debug option to get more log output.
  * Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':tomcatRun'.
....
Caused by: org.gradle.api.GradleException: An error occurred starting the Tomcat server.
        at org.gradle.api.plugins.tomcat.AbstractTomcatRunTask.startTomcat(AbstractTomcatRunTask.groovy:243)
        at org.gradle.api.plugins.tomcat.AbstractTomcatRunTask$_validateConfigurationAndStartTomcat_closure1.doCall(AbstractTomcatRunTask.groovy:115)
        at org.gradle.api.plugins.tomcat.AbstractTomcatRunTask$_validateConfigurationAndStartTomcat_closure1.doCall(AbstractTomcatRunTask.groovy)
        at org.gradle.api.plugins.tomcat.internal.LoggingHandler.withJdkFileLogger(LoggingHandler.groovy:52)
        at org.gradle.api.plugins.tomcat.internal.LoggingHandler$withJdkFileLogger.callStatic(Unknown Source)
        at org.gradle.api.plugins.tomcat.AbstractTomcatRunTask.validateConfigurationAndStartTomcat(AbstractTomcatRunTask.groovy:114)
        at org.gradle.api.plugins.tomcat.AbstractTomcatRunTask.start(AbstractTomcatRunTask.groovy:76)
        at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216)
        at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122)
        at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
        at org.gradle.api.plugins.tomcat.TomcatRun_Decorated.invokeMethod(Unknown Source)
        at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$4.execute(AnnotationProcessingTaskFactory.java:161)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$4.execute(AnnotationProcessingTaskFactory.java:156)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:510)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:499)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:64)
        ... 57 more
Caused by: java.net.BindException: Address already in use: JVM_Bind
        at org.gradle.api.plugins.tomcat.internal.ShutdownMonitor.<init>(ShutdownMonitor.groovy:48)
        at org.gradle.api.plugins.tomcat.AbstractTomcatRunTask.startTomcat(AbstractTomcatRunTask.groovy:235)
        ... 73 more

I run the command

"netstat -aon | findstr "8080"

. But I find no process locking down that port. I also try to change the httpPort to some different port numbers like this in the build.gradle file, I still get the same error, inspite of using bizarre port numbers -

tomcatRunWar {
    httpPort = 8190
}

(Benjamin Muschko) #2

The port that is failing for you is the stop port. As you are not defining one it uses the default port: 8081. Try to change that one.

tomcatRunWar.stopPort = 8191

(Brijesh Singh) #3

I am also facing the same problem… tried changing like that tomcatRunWar {

contextPath = “”

stopPort = 8191 } Caused by: java.net.BindException: Address already in use: JVM_Bind :8080

at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:406)

at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:610)

at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:429)

at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)

at org.apache.catalina.connector.Connector.initInternal(Connector.java:981)

… 161 more