What I'm trying to do is to run simple spring boot application inside a docker container (openjdk:8-jre) via docker-compose. The code works fine on my machine (macbook pro). The problem is when I'm trying to run the same piece of docker containers on my raspberry pi with raspbian. It's stuck just before logging Tomcat initialized with port(s): 8080 (http).
The container with spring application only does java -jar and exposes port 8080 for my another container (on port 8888) with my single page application. Does anyone had similar problem or know how to fix this?
Here are the logs for running the container on raspberrypi:
wfeservices | . ____ _ __ _ _
wfeservices | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
wfeservices | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
wfeservices | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
wfeservices | ' |____| .__|_| |_|_| |_\__, | / / / /
wfeservices | =========|_|==============|___/=/_/_/_/
wfeservices | :: Spring Boot :: (v2.0.3.RELEASE)
wfeservices |
wfeservices | 2018-08-22 20:36:24 - Starting Application v1.0-SNAPSHOT on 4b7fcb7b344c with PID 7 (/wfeservices.jar started by root in /)
wfeservices | 2018-08-22 20:36:24 - No active profile set, falling back to default profiles: default
wfeservices | 2018-08-22 20:36:28 - Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#1412c2f: startup date [Wed Aug 22 20:36:28 UTC 2018]; root of context hierarchy
I had the exact same problem on AWS ECS then I realized that I had way to little memory so I increased the memory to 4096 megabytes and it worked.
Related
I am currently trying to restructure my Spring Boot project so that all the configuration files are no longer bundled in the jar. However, I still want the bootRun task to make use of them.
For the application.properties, I was able to do that quite easily by pulling it out of the src/resources folder and onto the surface of the project (for now) and adding this to the build.gradle:
tasks.named("bootRun") {
systemProperty "spring.config.location", "file:$projectDir/"
mainClass = "my.project.MyMainClass"
}
For the logback configuration, I was trying the same thing, so:
tasks.named("bootRun") {
systemProperty "spring.config.location", "file:$projectDir/"
systemProperty "logback.configurationFile", "file:$projectDir/"
mainClass = "my.project.MyMainClass"
}
...however, that did not work at all. Now instead of the logback configuration that I configured I just get the default configuration.
What am I doing wrong here? Based on what I've managed to find, this should work. My logback-spring.xml is located directly next to the application.properties.
Variations which I've also tried to the same end:
systemProperty "logback.configurationFile", "file:$projectDir/logback-spring.xml"
systemProperty "logback.configurationFile", "$projectDir/logback-spring.xml"
systemProperty "logback.configurationFile", "C:/projects/myProject/logback-spring.xml"
systemProperty "logback.configurationFile", "file:C:/projects/myProject/logback-spring.xml"
Update:
I have now debugged it a bit and arrived at this, which I feel even more should work, but doesn't:
tasks.named("bootRun") {
println "Hi, I'm BootRun!"
System.setProperty("spring.config.location", "file:$projectDir/")
println "System Property spring.config.location is: " + System.getProperty('spring.config.location')
System.setProperty("Logback.configurationFile", "$projectDir\\logback-spring.xml")
println "System Property Logback.configurationFile is: " + System.getProperty('Logback.configurationFile')
mainClass = "myProject.MyMainClass"
}
This gives me this output at the beginning of each build, way before Spring starts up:
> Configure project :
$0.1.0-SNAPSHOT$
Hi, I'm BootRun!
System Property spring.config.location is: file:C:\projects\myProject/
System Property Logback.configurationFile is: C:\projects\myProject\logback-spring.xml
> Task :createVersionFile
createVersionFile called. Path C:\projects\myProject\src\main\java\myProject
> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes
> Task :bootRun
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.4)
[...}
It feels like this should work to me, because the path to the logback-spring.xml. But could it maybe be an issue because it's run as part of a different task? That would feel weird because those are system variables...
I think you should use logging.config instead of logback.configurationFile.
https://docs.spring.io/spring-boot/docs/2.7.6/reference/html/features.html#features.logging.custom-log-configuration
This one got me in trouble too once, but I was lucky to receive an error message: https://github.com/spring-projects/spring-boot/issues/4969
I'm trying to deploy a Quarkus app to a Kubernetes cluster, but I got the following stacktrace:
exec java -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/quarkus-run.jar
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-05-11 16:47:19,455 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): java.lang.NumberFormatException: SRCFG00029: Expected an integer value, got "tcp://10.233.12.82:80"
at io.smallrye.config.Converters.lambda$static$60db1e39$1(Converters.java:104)
at io.smallrye.config.Converters$EmptyValueConverter.convert(Converters.java:949)
at io.smallrye.config.Converters$TrimmingConverter.convert(Converters.java:970)
at io.smallrye.config.Converters$BuiltInConverter.convert(Converters.java:872)
at io.smallrye.config.Converters$OptionalConverter.convert(Converters.java:790)
at io.smallrye.config.Converters$OptionalConverter.convert(Converters.java:771)
at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:225)
at io.smallrye.config.SmallRyeConfig.getOptionalValue(SmallRyeConfig.java:270)
at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:37)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties1249763973.deploy_0(ConfigBuildStep$validateConfigProperties1249763973.zig:328)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties1249763973.deploy(ConfigBuildStep$validateConfigProperties1249763973.zig:40)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:576)
at io.quarkus.runtime.Application.start(Application.java:90)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:100)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:48)
at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:25)
I build the Docker image with the default dockerfile, and my quarkus-related dependencies are the following:
dependencies {
implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
implementation("org.optaplanner:optaplanner-quarkus")
implementation("io.quarkus:quarkus-resteasy")
implementation("io.quarkus:quarkus-vertx")
implementation("io.quarkus:quarkus-resteasy-jackson")
implementation("io.quarkus:quarkus-undertow-websockets")
implementation("io.quarkus:quarkus-smallrye-health")
}
I'm using Quarkus 1.13.3.Final, and I've written a helm chart for my deployment by hand. The deployed dockerfile runs fine on my machine, and the kubernetes deployment descriptor does not have that IP address in it. I think that IP is a ClusterIP of the cluster.
Any idea? Thanks
It's due to the docker link variables that kubernetes mimics for Service names in scope; it bites people a lot when they have generically named services such as { apiVersion: v1, kind: Service, metadata: { name: http }, ... as it will cheerfully produce environment variables of the form HTTP_PORT=tcp://10.233.12.82:80 in the Pod, and things such as Spring boot or evidently Quarkus which coerce env-vars into configuration overrides can cause the exact outcome you're experiencing
The solution is (a) don't name Services with bland names (b) "mask off" the offensive env-vars for the Pod:
...
containers:
- ...
env:
- name: HTTP_PORT
# it doesn't need a value:, it just needs the name to be specified
# so it hides the injected version
- ... any remaining env-vars you really want
Not found anything interesting so far, so here am I, asking a question.
I got a spring boot application, that runs fine. Problem is : custom configuration !
I want it to run on port 8081 (and not default port 8080). So I added the application.yml in the src/main/resources directory, packaged it... And it run on port 8080
When I run the #SpringBootApplication class from intellij, it does run on port 8081 (I just added the application.yml file.) So why ?
It's a gradle multi module project. T added the application.yml file into the module that is actually packaged into a jar file. It is packaged using tha gradle shadow plugin, and does contain the application.yml file at the root of the jar file.
The application.yml is like this :
server:
port: 8081
I don't really know which information you'll need, so feel free to ask !
Any idea is welcome.
EDIT 1 :
"Stacktrace" when I start the server :
java -jar serverApp.jar
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::
août 29, 2020 5:50:54 PM org.apache.coyote.AbstractProtocol init
INFOS: Initializing ProtocolHandler ["http-nio-8080"]
août 29, 2020 5:50:54 PM org.apache.catalina.core.StandardService startInternal
INFOS: Starting service [Tomcat]
août 29, 2020 5:50:54 PM org.apache.catalina.core.StandardEngine startInternal
INFOS: Starting Servlet engine: [Apache Tomcat/9.0.37]
août 29, 2020 5:50:54 PM org.apache.catalina.core.ApplicationContext log
INFOS: Initializing Spring embedded WebApplicationContext
août 29, 2020 5:50:55 PM org.apache.coyote.AbstractProtocol start
INFOS: Starting ProtocolHandler ["http-nio-8080"]
Without seeing the actual code, I can recommend 2 things to try.
1- Have you missed to use the argument in main method-
public static void main(String[] args) {
SpringApplication.run(ServerApplication.class, args);
}
2- Try to start the springboot server with arguments-
java -jar -Dserver.port=8081 ServerApplication.jar
It seems that Shadow Plugin is not the right thing to use with Spring Boot according to this comment:
the boot framework has it's own gradle plugin and method for packaging ditributable jar files. I dont' think I would combine shadow and the boot plugin in the same project. They will collide.
and also this.
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?
I'm having a little problem with command "play test" or "play auto-test"...The first command gives me something like this:
My-heaven:jobboard Droid$ play test
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.2.3, http://www.playframework.org
~ framework ID is test
~
~ Running in test mode
~ Ctrl+C to stop
~
Listening for transport dt_socket at address: 8000
23:07:33,827 INFO ~ Starting /Users/Droid/Downloads/play-1.2.3/play-1.2.3/samples-and-tests/jobboard
23:07:33,832 WARN ~ Declaring modules in application.conf is deprecated. Use dependencies.yml instead (module.crud)
23:07:33,833 INFO ~ Module crud is available (/Users/Droid/Downloads/play-1.2.3/play-1.2.3/modules/crud)
23:07:34,858 WARN ~ You're running Play! in DEV mode
23:07:35,020 INFO ~ Listening for HTTP on port 9000 (Waiting a first request to start) ...
And http://localhost:9000/#tests shows me, that the route wan't found. After "play auto-test", the output looks like this:
My-heaven:jobboard Droid$ play auto-test
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.2.3, http://www.playframework.org
~ framework ID is test
~
~ Running in test mode
~ Ctrl+C to stop
~
~ Deleting /Users/Droid/Downloads/play-1.2.3/play-1.2.3/samples-and-tests/jobboard/tmp
~
Listening for transport dt_socket at address: 8000
23:09:29,670 INFO ~ Starting /Users/Droid/Downloads/play-1.2.3/play-1.2.3/samples-and-tests/jobboard
23:09:29,678 WARN ~ Declaring modules in application.conf is deprecated. Use dependencies.yml instead (module.crud)
23:09:29,679 INFO ~ Module crud is available (/Users/Droid/Downloads/play-1.2.3/play-1.2.3/modules/crud)
23:09:30,913 WARN ~ You're running Play! in DEV mode
23:09:31,077 INFO ~ Listening for HTTP on port 9000 (Waiting a first request to start) ...
~
Exception in thread "main" java.lang.NoClassDefFoundError: play/modules/testrunner/FirePhoque
Caused by: java.lang.ClassNotFoundException: play.modules.testrunner.FirePhoque
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
~
What is wrong with that?
Solved - Download and build current version from Github.