question

RohithR-0007 avatar image
0 Votes"
RohithR-0007 asked srbose-msft commented

Not able to start the server while deploying the java (springboot) service on to the AKS

I am trying to deploy a java (springboot) service on to the AKS cluster. Using the azure pipelines to build and deploy the java service to AKS.
Below is the docker files used to build the image

FROM maven:3.8.1-adoptopenjdk-15
WORKDIR /app
COPY . /app
RUN mvn install -Dmaven.test.skip=true
RUN cd /app/target && chmod 777 <jar_name>.jar
RUN mv /app/target/<jar_name>.jar /app
EXPOSE 8080
CMD ["java","-jar","-Dspring-boot.run.profiles=dev","<jar_name>.jar" ]

FROM ubuntu
RUN apt-get update -y
RUN apt-get install openjdk-11-jdk -y
RUN apt install maven -y
WORKDIR /app
COPY . /app
RUN mvn install -Dmaven.test.skip=true
RUN cp /app/target/<jar_name>.jar /app
EXPOSE 8080
CMD ["java","-jar","<jar_name>.jar" ]

I used above mentioned both docker files to create images and run the jar.But I got the same issue while starting the server in both images.
Below is the snapshot the error response


2021-07-21 13:52:31.253 WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to create tempDir. java.io.tmpdir is set to /tmp
2021-07-21 13:52:31.357 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to create tempDir. java.io.tmpdir is set to /tmp
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163) ~[spring-boot-2.5.2.jar!/:2.5.2]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[spring-context-5.3.8.jar!/:5.3.8]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.2.jar!/:2.5.2]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.2.jar!/:2.5.2]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.2.jar!/:2.5.2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.2.jar!/:2.5.2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.2.jar!/:2.5.2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.2.jar!/:2.5.2]
at com.plmtrustlink.java.platformjavautilities.PlatformJavaUtilitesApplication.main(PlatformJavaUtilitesApplication.java:18) ~[classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[platform-java-utilites-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) ~[platform-java-utilites-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[platform-java-utilites-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[platform-java-utilites-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to create tempDir. java.io.tmpdir is set to /tmp
at org.springframework.boot.web.server.AbstractConfigurableWebServerFactory.createTempDir(AbstractConfigurableWebServerFactory.java:195) ~[spring-boot-2.5.2.jar!/:2.5.2]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:186) ~[spring-boot-2.5.2.jar!/:2.5.2]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182) ~[spring-boot-2.5.2.jar!/:2.5.2]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160) ~[spring-boot-2.5.2.jar!/:2.5.2]
... 16 common frames omitted
Caused by: java.nio.file.FileSystemException: /tmp/tomcat.8080.6332585667532630013: Read-only file system
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100) ~[na:na]
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[na:na]
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) ~[na:na]
at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:389) ~[na:na]
at java.base/java.nio.file.Files.createDirectory(Files.java:690) ~[na:na]
at java.base/java.nio.file.TempFileHelper.create(TempFileHelper.java:135) ~[na:na]
at java.base/java.nio.file.TempFileHelper.createTempDirectory(TempFileHelper.java:172) ~[na:na]
at java.base/java.nio.file.Files.createTempDirectory(Files.java:1007) ~[na:na]
at org.springframework.boot.web.server.AbstractConfigurableWebServerFactory.createTempDir(AbstractConfigurableWebServerFactory.java:189) ~[spring-boot-2.5.2.jar!/:2.5.2]
... 19 common frames omitted




it is not able to start the SpringApplication.run and i even tried with enabling jetty and undertow servers by disabling tomcat server.In those cases also i got encountered with same issue.

Can anyone help my out the fix this and where iam making mistake.


azure-kubernetes-service
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RohithR-0007 , Thank you for your question.

If you are running the container with enhanced security/limited permissions can you please check if the workarounds suggested here help?

Also there is a spring-boot issue currently open on GitHub which addresses this.

Please do let us know if this is helpful.


0 Votes 0 ·

0 Answers