Crash when trying to run WebGoat with a Java Agent - java

I am currently learning how to boot a web application with a java agent for monitoring.
The Web Application I chose was WebGoat, and running WebGoat with java -jar webgoat-server-8.0.0.M17.jar as stated in WebGoat's README works perfectly fine.
However, when I try to add my agent, I get the following mess of an error log:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.12.RELEASE)
2018-06-06 22:36:08.528 INFO 3741 --- [ main] org.owasp.webgoat.StartWebGoat : Starting StartWebGoat v8.0.0.M17 on MacBook-Pro.local with PID 3741 (/Users/andrewfan/Desktop/Lang Agent Dev Proj help info/webgoat-server-8.0.0.M17.jar started by andrewfan in /Users/andrewfan/Desktop/Lang Agent Dev Proj help info)
2018-06-06 22:36:08.531 INFO 3741 --- [ main] org.owasp.webgoat.StartWebGoat : No active profile set, falling back to default profiles: default
2018-06-06 22:36:08.844 INFO 3741 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1376c05c: startup date [Wed Jun 06 22:36:08 EDT 2018]; root of context hierarchy
2018-06-06 22:36:11.354 INFO 3741 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$8e12590a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-06-06 22:36:11.442 WARN 3741 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'webgoat.user.directory' in value "${webgoat.user.directory}"
2018-06-06 22:36:11.455 INFO 3741 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-06-06 22:36:11.464 ERROR 3741 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'webgoat.user.directory' in value "${webgoat.user.directory}"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372) ~[spring-beans-4.3.16.RELEASE.jar!/:4.3.16.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1268) ~[spring-beans-4.3.16.RELEASE.jar!/:4.3.16.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.16.RELEASE.jar!/:4.3.16.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.16.RELEASE.jar!/:4.3.16.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) ~[spring-beans-4.3.16.RELEASE.jar!/:4.3.16.RELEASE]
at
...
I cut the error messages short since the trace is a few pages long, but the main error seems to be org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'webgoat.user.directory' in value "${webgoat.user.directory}"
I am running my agent as follows:
java -javaagent:/Users/path/to/jar/Spn-LangAgent-0.0.jar -jar webgoat-server-8.0.0.M17.jar --server.port=8080 --server.address=localhost
My agent is as follows:
package com.spnlangagent.langagent;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.lang.reflect.Field;
import java.lang.instrument.Instrumentation;
import java.lang.instrument.UnmodifiableClassException;
import com.google.monitoring.runtime.instrumentation.AllocationRecorder;
public class LangAgent {
public static void premain(String agentArgs, Instrumentation inst) throws Exception {
System.out.println("LangAgent: premain now running");
setupInstrumentation(agentArgs, inst);
startRuntime(agentArgs);
}
private static void setupInstrumentation(String agentArgs, Instrumentation inst) throws Exception {
System.out.println("setupInstrumentation: now running with agentArgs: " + agentArgs);
}
private static void startRuntime(String agentArgs) throws Exception {
System.out.println("startRuntime: now running with agentArgs: " + agentArgs);
}
}
The original contents of the agent were commented out except for a few print statements, and yet even with this, WebGoat is crashing on startup.
I tried another agent with WebGoat and it worked fine, so the only thing I can think of is that something is wrong with either my agent, or the way it is being packaged.
I am using Maven, and my MANIFEST.MF is as follows:
Manifest-Version: 1.0
Premain-Class: com.spnlangagent.langagent.LangAgent
Can-Redefine-Classes: true
Can-Retransform-Classes: true
After running mvn package, the MANIFEST packaged in the .jar is as follows:
Manifest-Version: 1.0
Premain-Class: com.spnlangagent.langagent.LangAgent
Built-By: andrewfan
Can-Redefine-Classes: true
Can-Retransform-Classes: true
Created-By: Apache Maven 3.5.3
Build-Jdk: 1.8.0_172
In my pom.xml, I am doing the following to reach the manifest:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
If someone could point me in the right direction in regards to figuring out why WebGoat is crashing, or if someone could provide more insight into why what I am currently doing is wrong, that would be greatly appreciated.
Thank you.
Note: If the rest of my pom.xml is necessary for debugging, I will gladly provide it; it's just that the question is already very long as-is.

Webgoat (and also in most Spring-based application) relies on properties file (in properties or yaml format usually) to perform placeholder lookup.
The symptom in your failure indicate that Spring failed to lookup properties for placeholder processing.
Given that placeholder lookup works well without presence of your agent JAR, and with information you mentioned in comment, the problem is caused by
Your agent JAR provided application.properties (which has name collision with the properties file used by Webgoat for placeholder)
Agent JAR will be part of classpath, and probably even appear earlier than the main JAR
your empty application.properties "shadowed" the one in Webgoat main JAR. Which means, when Webgoat starts, Spring picked up your empty application.properties for its placeholder processing, hence failed.

The solution was mvn clean
Earlier I had an application.properties that was automatically added as part of the Spring Boot Initializr. The very presence of this file in my agent .jar, even with nothing inside, seems to have been the reason why WebGoat freaked out. Now that it is no longer present, WebGoat is running normally via java -javaagent:/Users/path/to/jar/Spn-LangAgent-0.0.jar -jar webgoat-server-8.0.0.M17.jar --server.port=8080 --server.address=localhost
I'd like to thank Adrian Shum for mentioning application.properties, since I had removed it a while back. mvn package didn't actually rebuild the .jar when I ran it, so the jar I had been testing on was the one that still contained application.properties.

Related

Spring loads context for each unit test file

I have 16 Unit test case files. Each in this format:
#SpringBootTest
class UserServiceTest {
#Autowired
UserService userService;
#MockBean
SomeDependency someDependency;
#Test
...and so on
}
Whenever I run mvn clean install, it seems that spring is restarting/loading context 16 times. I see these logs 16 times:
[INFO] Running com.base.UserServiceTest
2021-07-16 04:35:39.421 [INFO ] [main] o.s.t.c.s.AbstractTestContextBootstrapper - Neither #ContextConfiguration nor #ContextHierarchy found for test class [com.base.UserServiceTest], using SpringBootContextLoader
2021-07-16 04:35:39.423 [INFO ] [main] o.s.t.c.s.AbstractContextLoader - Could not detect default resource locations for test class [com.base.UserServiceTest]: no resource found for suffixes {-context.xml, Context.groovy}.
2021-07-16 04:35:39.424 [INFO ] [main] o.s.t.c.s.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.base.UserServiceTest]: UserServiceTest does not declare any static, non-private, non-final, nested classes annotated with #Configuration.
2021-07-16 04:35:39.473 [INFO ] [main] o.s.b.t.c.SpringBootTestContextBootstrapper - Found #SpringBootConfiguration com.base.Application for test class com.base.UserServiceTest
2021-07-16 04:35:39.475 [INFO ] [main] o.s.t.c.s.AbstractTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
2021-07-16 04:35:39.476 [INFO ] [main] o.s.t.c.s.AbstractTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener#4dc599a7, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener#635f2d9b, org.springframework.test.context.event.ApplicationEventsTestExecutionListener#7e83380f, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener#6000fc20, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener#1e95926, org.springframework.test.context.support.DirtiesContextTestExecutionListener#1bc08f75, org.springframework.test.context.transaction.TransactionalTestExecutionListener#7ce49f42, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener#1b629d02, org.springframework.test.context.event.EventPublishingTestExecutionListener#5089c721, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener#4fad5162, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener#176bd95a, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener#186edc38, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener#6c0b0db, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener#2343c720, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener#6aab6b1b]
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.0)
2021-07-16 04:35:39.520 [INFO ] [main] o.s.b.StartupInfoLogger - Starting UserServiceTest using Java 11.0.2 on
2021-07-16 04:35:39.523 [INFO ] [main] o.s.b.SpringApplication - The following profiles are active: local
2021-07-16 04:35:40.197 [INFO ] [main] o.s.m.w.MockServletContext - Initializing Spring TestDispatcherServlet ''
2021-07-16 04:35:40.197 [INFO ] [main] o.s.w.s.FrameworkServlet - Initializing Servlet ''
2021-07-16 04:35:40.199 [INFO ] [main] o.s.w.s.FrameworkServlet - Completed initialization in 1 ms
2021-07-16 04:35:40.211 [INFO ] [main] o.s.b.StartupInfoLogger - Started UserServiceTest in 0.732 seconds (JVM running for 9.613)
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.918 s - in com.base.UserServiceTest
This causes 2 problems:
There are a lot more tests to be added. Even with 16 test files, it takes around 20 seconds to execute. So the process is slow.
My application uses JPA to connect with DB, and during mvn clean install, although the application builds successfully, it gives this error in logs random number of times:
2021-07-16 04:35:52.741 [ERROR] [main] c.z.h.p.HikariPool - HikariPool-11 - Exception during pool initialization. org.postgresql.util.PSQLException: FATAL: remaining connection slots are reserved for non-replication superuser connections
I wonder if this context reloading is causing this as I perform mvn clean install often and that there might be a connection leak somewhere.
Using JUnit 5/Jupiter and Spring 5.
Any help in fixing above 2 points is appreciated. Thanks.
Spring Test caches your TestContext and re-uses it for another test if the context configuration fits.
However, if all your tests have a different setup (e.g., the first test wants a mocked version of class A and the second test wants a mocked version of class B), caching won't help and Spring has to start a new context.
If you streamline the context setup for all your tests, Spring will reuse it and hence make the test execution fast.
In addition, the test you added (using #SpringBootTest) is not a unit test (well - it always depends on the definition) as it starts the entire Spring context.
If your plan is to write unit tests for your business logic, rather use just JUnit 5 and Mockito. These tests are fast and there's no Spring support and hence no context started.
For a broad overview of unit, integration, and end-to-end testing strategies for Spring Boot applications, take a look at this article.

pyspark.sql.utils.IllegalArgumentException: 'requirement failed: Was not found appropriate resource to download for request

I'm trying to run the example code below:
import sparknlp
sparknlp.start()
from sparknlp.pretrained import PretrainedPipeline
explain_document_pipeline = PretrainedPipeline("explain_document_ml")
annotations = explain_document_pipeline.annotate("We are very happy about SparkNLP")
print(annotations)
I'm using Pycharm in Anaconda env, originally I downloaded spark-nlp with pip spark-nlp==2.4.4 but I saw someone online said I should use:
pyspark --packages com.johnsnowlabs.nlp:spark-nlp_2.11:2.4.4
Because with pip install I might have some dependencies missing, so better use pyspark --packages, but this gave me error:
:: problems summary ::
:::: WARNINGS
[NOT FOUND ] com.typesafe#config;1.3.0!config.jar(bundle) (0ms)
==== local-m2-cache: tried
file:/C:/Users/xxxxxxxx/.m2/repository/com/typesafe/config/1.3.0/config-1.3.0.jar
[NOT FOUND ] com.fasterxml.jackson.core#jackson-annotations;2.6.0!jackson-annotations.jar(bundle) (0ms)
==== local-m2-cache: tried
file:/C:/Users/xxxxxxx/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.6.0/jackson-annotations-2.6.0.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: FAILED DOWNLOADS ::
:: ^ see resolution messages for details ^ ::
::::::::::::::::::::::::::::::::::::::::::::::
:: com.typesafe#config;1.3.0!config.jar(bundle)
:: com.fasterxml.jackson.core#jackson-annotations;2.6.0!jackson-annotations.jar(bundle)
::::::::::::::::::::::::::::::::::::::::::::::
:::: ERRORS
unknown resolver null
unknown resolver null
unknown resolver null
unknown resolver null
unknown resolver default
unknown resolver null
:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
Exception in thread "main" java.lang.RuntimeException: [download failed: com.typesafe#config;1.3.0!config.jar(bundle), download failed: com.fasterxml.jackson.core#jackson-annotations;2.6.0!jackson-annotations.jar(
bundle)]
Then I downloaded these two missing jars and copy them to the corresponding folder, then run the command and everything seems look fine now:
21/02/05 15:41:13 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/__ / .__/\_,_/_/ /_/\_\ version 2.4.4
/_/
Using Python version 3.7.1 (default, Oct 28 2018 08:39:03)
SparkSession available as 'spark'.
>>>
Then I tried to re-run the example python script at the top, it gave me error, here's the logs:
Ivy Default Cache set to: C:\Users\xxxx\.ivy2\cache
The jars for the packages stored in: C:\Users\xxxx\.ivy2\jars
:: loading settings :: url = jar:file:/C:/Users/xxxx/AppData/Local/Continuum/anaconda3/envs/workEnv-python3.7/lib/site-packages/pyspark/jars/ivy-2.4.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
com.johnsnowlabs.nlp#spark-nlp_2.11 added as a dependency
............
I'm new to this, I've been messing around for two days, might someone able to help me please???

Can't get Spring Boot application to work on Google Cloud Platform Flexible Environment

I'm having trouble deploying my Spring Boot application on the Google Cloud Platform Flexible environment.
I run the following command to deploy: mvn clean compile package -DskipTests appengine:deploy -P cloud-gcp
The cloud-gcp profile in my pom.xml has the following:
<profiles>
<profile>
<id>cloud-gcp</id>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<version>beta3</version>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
This is my app.yaml file located at src/main/appengine/app.yaml:
runtime: java
env: flex
runtime_config:
jdk: openjdk8
env_variables:
SPRING_PROFILES_ACTIVE: "gcp"
handlers:
- url: /.*
script: this field is required, but ignored
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 4
disk_size_gb: 10
Here is my application-gcp.properties:
server.address=0.0.0.0
server.port=8080
# Datasource
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect
spring.datasource.username=xxx
spring.datasource.password=xxx
spring.datasource.url=jdbc:postgresql://google/xxx?cloudSqlInstance=xxx:europe-west4:xxx&autoReconnect=true&user=xxx&password=xxx&socketFactory=com.google.cloud.sql.postgres.SocketFactory&useSSL=false
server.error.whitelabel.enabled=false
# Optimize start of application
spring.jmx.enabled=false
# Gcp configuration
spring.cloud.gcp.sql.enabled=false
spring.cloud.gcp.sql.database-name=xxx
spring.cloud.gcp.sql.instance-connection-name=xxx:europe-west4:xxx
spring.cloud.gcp.logging.enabled=true
The compilation is successful, no problems there. The problem occurs when I want to access my Spring Boot application. I constantly get a 502 Error. There is nothing in the logs that gives me a clue on what is wrong:
A 2020-01-20T16:14:17Z . ____ _ __ _ _
A 2020-01-20T16:14:17Z /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
A 2020-01-20T16:14:17Z ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
A 2020-01-20T16:14:17Z \\/ ___)| |_)| | | | | || (_| | ) ) ) )
A 2020-01-20T16:14:17Z ' |____| .__|_| |_|_| |_\__, | / / / /
A 2020-01-20T16:14:17Z =========|_|==============|___/=/_/_/_/
A 2020-01-20T16:14:17Z :: Spring Boot :: (v2.1.5.RELEASE)
com.xxx.api.xxxApplication : Starting xxxApplication v0.0.1-SNAPSHOT on bc233766746a with PID 1 (/app.jar started by root in /)
com.xxx.api.xxxApplication : The following profiles are active: gcp
.s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
.s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 532ms. Found 17 repository interfaces.
trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$2c4dbf14] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$c4fb874e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
trationDelegate$BeanPostProcessorChecker : Bean 'objectPostProcessor' of type [org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler#6b00f608' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$e9d02a00] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$abce0c46] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
o.apache.catalina.core.StandardService : Starting service [Tomcat]
org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.19]
o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 11326 ms
com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
Connecting to Cloud SQL instance [xxx:europe-west4:xxx] via SSL socket.
First Cloud SQL connection, generating RSA key pair.
This is the last lines I have in the logs. Nothing seems to break, no errors as far as I can tell. It seems to correctly connect to the Cloud SQL instance. I'm lost here. I've tried a lot of things, but I always get a 502 request from Spring Boot no matter what.
For information, the /liveness_check and /readiness_check always return 200 even when the server is not launched (which is strange...).
Tell me if you need any more informations on the configuration I am using.
Thank you in advance!
We finally solved our issue. For those who might have the same issue:
The problem was caused by our guava version. We add the version 18.0, which was problematic apparently. We added the following dependencies in the pom.xml:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.2-jre</version>
</dependency>
And the problem was solved :)
Wow, just doing some venting here but have been pulling my hair out for about 2 weeks now attempting to deploy a spring boot app to google cloud. It's incredibly nerve wracking to hear that a modification of a guava dependency could cause an application to not startup - even far worse make the logs go silent with no trace of what is going on. At the moment, I too am dealing with a situation where there are no application logs to be found and no trace of what is going wrong while just simply trying to hit an endpoint after what google cloud tells me is a successful deploy.
This comment and I'm sure to write others in the future is more aimed at getting other people to vent their frustration as google cloud support is non-existent unless you pay a premium for it. Making matters worse the product appears to be just plain terrible in terms of allowing developers insights into what is actually going wrong when a deployment doesn't work. I hope this gets their attention and I hope others voice their frustration as well because this product is simply unusable when it gives no indication of what is going wrong with a deployment. I've scoured their docs to no avail and it seems others have similar issues. Unfortunately my hands are tied by my client to use google cloud otherwise I would have migrated away from it after seeing first hand some of the very basic ways it is flawed. If you're in the process of evaluating a cloud product I would highly recommend not using google.

SpringApplication in docker doesn't work anymore

i have a strange problem. I have created a spring application with some functional logic and started it locally - it worked.
Then i have exported my whole project to a .war file and build a docker image to run it also locally - it worked.
Since ca. 2 day...i guess i did some changes...i want to build and run my docker file again, but stops always at this point:
Launching defaultServer (WebSphere Application Server 17.0.0.2/wlp-1.0.17.cl170220170523-1818) on IBM J9 VM, version pxa6480sr4fp10-20170727_01 (SR4 FP10) (en_US)
[AUDIT ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT ] CWWKE0100I: This product is licensed for development, and limited production use. The full license terms can be viewed here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/license/base_ilan/ilan/17.0.0.2/lafiles/en.html
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ibm/wlp/usr/servers/defaultServer/configDropins/defaults/keystore.xml
[WARNING ] CWWKS3103W: There are no users defined for the BasicRegistry configuration of ID com.ibm.ws.security.registry.basic.config[basic].
[AUDIT ] CWWKZ0058I: Monitoring dropins for applications.
[AUDIT ] CWWKS4104A: LTPA keys created in 6.228 seconds. LTPA key file: /opt/ibm/wlp/output/defaultServer/resources/security/ltpa.keys
[AUDIT ] CWPKI0803A: SSL certificate created in 8.761 seconds. SSL key file: /opt/ibm/wlp/output/defaultServer/resources/security/key.jks
[AUDIT ] CWWKI0001I: The CORBA name server is now available at corbaloc:iiop:localhost:2809/NameService.
[AUDIT ] CWWKT0016I: Web application available (default_host): http://2b88d6a3093b:9080/xxxxxx/
[AUDIT ] CWWKZ0001I: Application xxxxx started in 1.828 seconds.
[AUDIT ] CWWKF0012I: The server installed the following features: [servlet-3.1, beanValidation-1.1, ssl-1.0, jndi-1.0, jca-1.7, ejbPersistentTimer-3.2, appSecurity-2.0, j2eeManagement-1.1, jdbc-4.1, wasJmsServer-1.0, jaxrs-2.0, javaMail-1.5, cdi-1.2, webProfile-7.0, jcaInboundSecurity-1.0, jpa-2.1, jsp-2.3, ejbLite-3.2, managedBeans-1.0, jsf-2.2, ejbHome-3.2, jaxws-2.2, jsonp-1.0, el-3.0, jaxrsClient-2.0, concurrent-1.0, appClientSupport-1.0, ejbRemote-3.2, javaee-7.0, jaxb-2.2, mdb-3.2, jacc-1.5, batch-1.0, ejb-3.2, json-1.0, jaspic-1.1, jpaContainer-2.1, distributedMap-1.0, websocket-1.1, wasJmsSecurity-1.0, wasJmsClient-2.0].
[AUDIT ]
CWWKF0011I: The server defaultServer is ready to run a smarter planet.
My Spring application doesn't start anymore. In general it would continue with this:
2017-10-05 13:34:46.723 INFO 11136 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#c3c60d: startup date [Thu Oct 05 13:34:46 CEST 2017]; root of context hierarchy
2017-10-05 13:34:47.070 INFO 11136 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-10-05 13:34:47.112 INFO 11136 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$240b40b3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.2.RELEASE)
........
If i start my application locally from eclipse, it still works without any problems, but of course i want to build the docker image again.
Where do i have to search, if the SpringApplication start locally from the environment, but not from the docker images/container. Here it stops at
"The server defaultServer is ready to run a smarter planet."
Thank you in adnvance!
----------------- UPDATE -----------------
I found something. My exported .war file has just a size of 134kb. I am sure, it was ca. 35mb before. Does anyone has an idea?

Terminating mvn spring-boot:run doesn't stop tomcat

I can successfully start spring-boot with mvn spring-boot, the documentation mentions to gracefully exit the application hit ctrl-c.
Terminate batch job (Y/N)? Y
The maven process does terminate but Tomcat is still running and I can still hit the web-page. When I try to start spring-boot again it fails to start Tomcat because the port is in use.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.1.0.BUILD-SNAPSHOT)
2014-05-02 12:13:57.666 INFO 6568 --- [ main] Example : Starting Example on challenger with PID 6568 (E:\workspace\SpringBoot\target\cla
sses started by steven in E:\workspace\SpringBoot)
2014-05-02 12:13:57.707 INFO 6568 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWeb
ApplicationContext#11ecab7c: startup date [Fri May 02 12:13:57 EDT 2014]; root of context hierarchy
2014-05-02 12:13:58.097 INFO 6568 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean
: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfi
gure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class pat
h resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; laz
yInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAuto
ConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfig
ure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2014-05-02 12:13:58.682 INFO 6568 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8080
2014-05-02 12:13:58.892 INFO 6568 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2014-05-02 12:13:58.892 INFO 6568 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.53
2014-05-02 12:13:58.981 INFO 6568 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2014-05-02 12:13:58.981 INFO 6568 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1277 ms
2014-05-02 12:13:59.453 INFO 6568 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2014-05-02 12:13:59.455 INFO 6568 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2014-05-02 12:13:59.570 ERROR 6568 --- [ main] o.a.coyote.http11.Http11NioProtocol : Failed to start end point associated with ProtocolHandler ["http-nio-8080"]
java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:344)
at sun.nio.ch.Net.bind(Net.java:336)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:199)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:473)
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:647)
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:449)
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1007)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:459)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:341)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:79)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:69)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:270)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:145)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:680)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:930)
at Example.main(Example.java:16)
2014-05-02 12:13:59.571 ERROR 6568 --- [ main] o.apache.catalina.core.StandardService : Failed to start connector [Connector[org.apache.coyote.http11.Http11NioProtocol-
8080]]
org.apache.catalina.LifecycleException: Failed to start component [Connector[org.apache.coyote.http11.Http11NioProtocol-8080]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:459)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:341)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:79)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:69)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:270)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:145)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:680)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:930)
at Example.main(Example.java:16)
Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat"; Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1014)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 18 common frames omitted
Caused by: java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:344)
at sun.nio.ch.Net.bind(Net.java:336)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:199)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:473)
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:647)
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:449)
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1007)
... 19 common frames omitted
2014-05-02 12:13:59.572 INFO 6568 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2014-05-02 12:13:59.580 INFO 6568 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/E:/workspace/SpringBoot/src/m
ain/resources, file:/E:/workspace/SpringBoot/src/main/resources, file:/E:/workspace/SpringBoot/target/classes/, file:/C:/Users/steven/.m2/repository/org/springframework/boot/spring
-boot-starter-web/1.1.0.BUILD-SNAPSHOT/spring-boot-starter-web-1.1.0.BUILD-SNAPSHOT.jar, file:/C:/Users/steven/.m2/repository/org/springframework/boot/spring-boot-starter/1.1.0.BUI
LD-SNAPSHOT/spring-boot-starter-1.1.0.BUILD-SNAPSHOT.jar, file:/C:/Users/steven/.m2/repository/org/springframework/boot/spring-boot/1.1.0.BUILD-SNAPSHOT/spring-boot-1.1.0.BUILD-SNA
PSHOT.jar, file:/C:/Users/steven/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.1.0.BUILD-SNAPSHOT/spring-boot-autoconfigure-1.1.0.BUILD-SNAPSHOT.jar, file:/C:
/Users/steven/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.1.0.BUILD-SNAPSHOT/spring-boot-starter-logging-1.1.0.BUILD-SNAPSHOT.jar, file:/C:/Users/steven/.
m2/repository/org/slf4j/jcl-over-slf4j/1.7.7/jcl-over-slf4j-1.7.7.jar, file:/C:/Users/steven/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar, file:/C:/Users/steven/.m2
/repository/org/slf4j/jul-to-slf4j/1.7.7/jul-to-slf4j-1.7.7.jar, file:/C:/Users/steven/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.7/log4j-over-slf4j-1.7.7.jar, file:/C:/Users/st
even/.m2/repository/ch/qos/logback/logback-classic/1.1.2/logback-classic-1.1.2.jar, file:/C:/Users/steven/.m2/repository/ch/qos/logback/logback-core/1.1.2/logback-core-1.1.2.jar, f
ile:/C:/Users/steven/.m2/repository/org/yaml/snakeyaml/1.13/snakeyaml-1.13.jar, file:/C:/Users/steven/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.1.0.BUILD
-SNAPSHOT/spring-boot-starter-tomcat-1.1.0.BUILD-SNAPSHOT.jar, file:/C:/Users/steven/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/7.0.53/tomcat-embed-core-7.0.53.jar, f
ile:/C:/Users/steven/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/7.0.53/tomcat-embed-el-7.0.53.jar, file:/C:/Users/steven/.m2/repository/org/apache/tomcat/embed/tomcat-e
mbed-logging-juli/7.0.53/tomcat-embed-logging-juli-7.0.53.jar, file:/C:/Users/steven/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.3.3/jackson-databind-2.3.3.jar, fi
le:/C:/Users/steven/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.3.0/jackson-annotations-2.3.0.jar, file:/C:/Users/steven/.m2/repository/com/fasterxml/jackson/co
re/jackson-core/2.3.3/jackson-core-2.3.3.jar, file:/C:/Users/steven/.m2/repository/org/springframework/spring-web/4.0.3.RELEASE/spring-web-4.0.3.RELEASE.jar, file:/C:/Users/steven/
.m2/repository/org/springframework/spring-aop/4.0.3.RELEASE/spring-aop-4.0.3.RELEASE.jar, file:/C:/Users/steven/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file
:/C:/Users/steven/.m2/repository/org/springframework/spring-beans/4.0.3.RELEASE/spring-beans-4.0.3.RELEASE.jar, file:/C:/Users/steven/.m2/repository/org/springframework/spring-cont
ext/4.0.3.RELEASE/spring-context-4.0.3.RELEASE.jar, file:/C:/Users/steven/.m2/repository/org/springframework/spring-core/4.0.3.RELEASE/spring-core-4.0.3.RELEASE.jar, file:/C:/Users
/steven/.m2/repository/org/springframework/spring-webmvc/4.0.3.RELEASE/spring-webmvc-4.0.3.RELEASE.jar, file:/C:/Users/steven/.m2/repository/org/springframework/spring-expression/4
.0.3.RELEASE/spring-expression-4.0.3.RELEASE.jar]
Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedde
d.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:135)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
[INFO] ------------------------------------------------------------------------
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
[INFO] BUILD SUCCESS
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:680)
[INFO] ------------------------------------------------------------------------
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
[INFO] Total time: 4.653 s
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:930)
at Example.main(Example.java:16)
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
[INFO] Finished at: 2014-05-02T12:13:59-05:00
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:106)
[INFO] Final Memory: 16M/232M
[INFO] ------------------------------------------------------------------------
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:69)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:270)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:145)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
... 7 more
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:102)
... 12 more
To proceed I have to manually terminate the running process. Is this a bug or am I missing something?
It still happens to me on version 1.1.9 running on windows 7.
So after hitting Ctrl C.
The fastest way to kill the background java will be .
Find the java PID
c:\>netstat -ano | find "8080"
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 1196
TCP [::]:8080 [::]:0 LISTENING 1196
c:\>taskkill /F /PID 1196
SUCCESS: The process with PID 1196 has been terminated.
I am assuming in the example above that you are running on http port 8080
For Mac Users:
$lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java SOME_PID user 417u IPv6 0xa4b3be242c249a27 0t0 TCP *:name (LISTEN)
kill -9 SOME_PID
Here is what I do on Mac:
kill `lsof -i -n -P | grep TCP | grep 8080 | tr -s " " "\n" | sed -n 2p`
It finds the PID using 8080 and kills it.
Edit:
in ubuntu, use the command:
fuser -k 8080/tcp
to kill the process. I'm using spring-boot 1.3.0-Build-snapshot and the problem still persist. My SO is Ubuntu and the problem occurs either running from Eclipse or from the console. The discussion about this issue is here. This seems to be an issue with spring-boot libraries, at least concerning tomcat libraries. I'm also in the line for the this fix. Unfortunately this is the price we pay for trying to use cutting edge technologies until they get matured.
For those using Eclipse, this is by far the best answer:
Open "run configurations", edit the maven launch you defined for your project, and under the "JRE" tab, add -Dfork=false to the VM arguments text area.
Then when you hit the red stop button, the tomcat server will stop and your ports will be released.
Answer comes from a post here on Github by jordihs
In IDEA you have to Stop process before Run it again. That command will shut down embedded Tomcat.
That only happens in Windows. https://github.com/spring-projects/spring-boot/issues/773
Update: should be fixed now.
I know i am too late to answer but may be some one get help with this. STS users can use the Relaunch button rather than Run to ensure that any existing instance is closed.
For Reference :
https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-running-your-application.html
Yes this is correct that when you do a maven install with spring-boot-run and after the application is stopped, tomcat port still listens.
I am attaching a screenshot for those who faced this problem port/address already in use.
What you have to do is before running the spring boot application again,just go to your windows Task manager and end the Process named "Java(TM) Platform SE binary" and run your boot application your port would be free of the process and you wont get the issue again.(You don't have to do this after you run your application for the first time )
It worked miracle for me. Hope it helps Good day
I fall in the same issue, but there is a much better and simple way to run your Spring boot app that does not have this problem.
Run As -> Java Application
Update:
Furthermore, if you use Spring STS (available for VS Code, IntelliJ, Eclipse...) you have the chance to manage your application from the Boot Dashboard. It's really useful.
I've had this problem when running spring boot app from netbeans 8.1 on Mac. The java process was not terminated when I hit red square button in netbeans so when I relaunched the app I always get "bind exception, adress already in use" thing. This is known bug.
The solution was to
add spring-boot:run command to run goals of project...
...and also if you get "No plugin found for prefix 'spring-boot' in the current project and in the plugin groups" you might need to add this to dependencies:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
I encountered same problem running SpringBoot application in eclipse on Mac. I manually had to find all the PID's using 8080 and kill them. But, fortunately, I realized that we can kill that tomcat instance right from the eclipse "console" view, by hitting the stop(Red square icon) button and run the spring boot application again.
You cause a shutdown by calling
curl -v -X POST http://127.0.0.1:8091/shutdown provided you configured spring-boot properly.
To support this you will have to update your application properties. This is partially described in https://stackoverflow.com/a/26563344/58794 .
updating application.yml by adding:
management:
security:
enabled: false
endpoints:
shutdown:
enabled: true
or updating application.properties by adding:
management.security.enabled=false
endpoints.shutdown.enabled=true
Once called
$ curl -v -X POST http://127.0.0.1:8091/shutdown
* STATE: INIT => CONNECT handle 0x600057990; line 1423 (connection #-5000)
* Added connection 0. The cache now contains 1 members
* Trying 127.0.0.1...
* TCP_NODELAY set
* STATE: CONNECT => WAITCONNECT handle 0x600057990; line 1475 (connection #0)
* Connected to 127.0.0.1 (127.0.0.1) port 8091 (#0)
* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x600057990; line 1592 (connection #0)
* Marked for [keep alive]: HTTP default
* STATE: SENDPROTOCONNECT => DO handle 0x600057990; line 1610 (connection #0)
> POST /shutdown HTTP/1.1
> Host: 127.0.0.1:8091
> User-Agent: curl/7.56.1
> Accept: */*
>
* STATE: DO => DO_DONE handle 0x600057990; line 1689 (connection #0)
* STATE: DO_DONE => WAITPERFORM handle 0x600057990; line 1814 (connection #0)
* STATE: WAITPERFORM => PERFORM handle 0x600057990; line 1824 (connection #0)
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 200
< X-Application-Context: application:h2:8091
< Content-Type: application/vnd.spring-boot.actuator.v1+json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Fri, 22 Dec 2017 07:01:04 GMT
<
* STATE: PERFORM => DONE handle 0x600057990; line 1993 (connection #0)
* multi_done
* Connection #0 to host 127.0.0.1 left intact
* Expire cleared
{"message":"Shutting down, bye..."}
the container will shutdown
o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
but if you launched from mvn spring-boot:run you will likely get a:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.613 s
[INFO] Finished at: 2017-12-22T02:01:05-05:00
[INFO] Final Memory: 25M/577M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.7.RELEASE:run (default-cli) on project PROJECTNAME: Could not exec java: Application finished with exit code: 1 -> [Help 1]
If you do not have management.security.enabled=false you may be presented with the following error:
$ curl -v -X POST http://127.0.0.1:8091/shutdown
> POST /shutdown HTTP/1.1
> Host: 127.0.0.1:8091
> User-Agent: curl/7.56.1
> Accept: */*
>
< HTTP/1.1 401
< X-Application-Context: application:h2:8091
< Content-Type: application/vnd.spring-boot.actuator.v1+json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Fri, 22 Dec 2017 06:56:19 GMT
<
{"timestamp":1513925779265,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource.","path":"/shutdown"}
If you do not have endpoints.shutdown.enabled=true you will see:
$ curl -v -X POST http://127.0.0.1:8091/shutdown
> POST /shutdown HTTP/1.1
> Host: 127.0.0.1:8091
> User-Agent: curl/7.56.1
> Accept: */*
>
< HTTP/1.1 404
< X-Application-Context: application:h2:8091
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Fri, 22 Dec 2017 06:58:52 GMT
<
{"timestamp":1513925932345,"status":404,"error":"Not Found","message":"No message available","path":"/shutdown"}
If you try a GET instead of POST this error will be presented:
$ curl -v http://127.0.0.1:8091/shutdown
> GET /shutdown HTTP/1.1
> Host: 127.0.0.1:8091
> User-Agent: curl/7.56.1
> Accept: */*
>
< HTTP/1.1 405
< X-Application-Context: application:h2:8091
< Allow: POST
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Fri, 22 Dec 2017 06:54:12 GMT
<
{"timestamp":1513925652827,"status":405,"error":"Method Not Allowed","exception":"org.springframework.web.HttpRequestMethodNotSupportedException","message":"Request method 'GET' not supported","path":"/shutdown"}
This solution worked for me with Spring Boot v1.x und works now, with v2.x:
hangingJavaProcessToStop=`jps | grep Application | awk '{print $1}'`
echo "hangingJavaProcessToStop: $hangingJavaProcessToStop"
kill -9 $hangingJavaProcessToStop
This way you can kill specifically Spring Boot's Application Java process instead of killing all Java processes at once. I assume if your Spring Boot "Application" (main method containing class) is called differently, you must use its name instead of Application.
I am running the snippet above, on my Windows machine using WSL/Debian. I am not using PowerShell or Windows'command line.
If you are using NetBeans you can stop the server or process by clicking on the cross icon in the bottom right corner where it says Run (Project name).
For Powershell, put the following code in a file ending with '.ps1'
$processes = (get-NetTCPConnection| ? {$_.LocalPort -eq "8080"}).OwningProcess
foreach ($process in $processes) {Get-Process -PID $process | Stop-Process -Force}
We can kill that tomcat instance right from the eclipse console view, by hitting the stop (Red square icon) button and Red button beside the run icon, run the spring boot application again.
I had the same issue in Windows 10, wenn I was running mvn spring-boot:run in a Cygwin Terminal. I wasn't even able to find the Tomcat process in Cygwin using ps -ef; I had to search for the process in PowerShell using netstat -ao.
Using mvn spring-boot:run in PowerShell is working fine for me.
I have the same issue on Mac OS recently, it seems this happened after upgrade my Mac OS version.
Use IntelliJ IDEA as IDE and install a spring boot, running process cannot be stopped as the port is still opened. I must use lsof -i:<running port> and kill -9 <PID> to kill the process manually every time, annoying!
In the case of eclipse::
If getting this error, You con stop it on eclipse, no need to kiling from Task Manager, Please refer SS, Here all running survices present, select one and stop them.
SS for error on eclipse
The issue is resolved in Spring boot 3.0.0 (To be released on 24th Nov 2022).
Issue link : Bug
Release notes : Release notes
Type the following commands in order.
$ ps -ef | grep -i java
$ kill -9 3361

Categories