Running spring boot native application getting the following error - spring

While running a spring boot 3 native application on bellsoft-liberica-vm-core-openjdk17-22.3.0 I'm getting this following error after creating the image.
./target/blog: error while loading shared libraries: libfreetype.so: cannot open shared object file: No such file or directory
mvn -Pnative native:compile to create the image.
./target/blog to start the image.

Related

How to solve the problem with docker run while running image of Spring Boot App

I am new at Docker and trying to build and run my own container with Spring Boot Application. It runs on Kotlin and Gradle.
I have built the image with simply this command, provided by gradle with spring boot plugin (id("org.springframework.boot") version "2.7.0-SNAPSHOT")
gradlew bootBuildImage
As a result i am getting this. Here are the logs: https://pastebin.com/xMW82vcw
The problem is, while trying to run my built image i am getting this error.
C:\projects\monetka-app>docker run docker.io/library/monetka-app:0.0.1-SNAPSHOT
Setting Active Processor Count to 6
unable to determine class count
unable to walk /workspace
unable to open ZIP /workspace/META-INF/licenses/client-2.1.jar
read /workspace/META-INF/licenses/client-2.1.jar: is a directory
ERROR: failed to launch: exec.d: failed to execute exec.d file at path '/layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/memory-calculator': exit status 1
Here are the docker images i have locally
in docker desktop.
My gradle version is 7.4.1, and JDK in use is 17.
When you run gradlew bootBuildImage, you're using Cloud-Native buildpacks to generate the image. This is a bug in a tool installed by the buildpack.
The Java Cloud-Native buildpack will install a tool called memory-calculator. This tool runs prior to your application starting up and sets up all the JVM memory flags that are required to keep the JVM from going past the defined memory limit you set. For example, if you set the memory limit of your container to be 1G, the memory calculator will adjust settings like -Xmx accordingly.
To do this, the memory calculator needs to know how many class files you have in your application, so it searches for them. This process is failing because it sees something with an extension of .jar and so it's trying to read the number of class files in that JAR, however, what it's seeing META-INF/licenses/client-2.1.jar isn't actually a JAR. It's a directory.
I opened a bug report for you here: https://github.com/paketo-buildpacks/libjvm/issues/160
If you are able to remove the file META-INF/licenses/client-2.1.jar (or change so it doesn't have a .jar extension) you should be able to work around this until we can resolve the issue.

Problem in deploying to IBM bluemix java/spring service

I am deploying a java spring boot application as a deployable war into an IBM bluemix environment via jenkins. I am able to build and run the service in my local environment. During the build pipeline, I am getting this. Any ideas?
Staging app and tracing logs...
Downloading liberty-for-java...
Downloaded liberty-for-java
Cell 26776ec2-6370-4ef1-8987-54aa61d8fe79 creating container for instance 1cc919a5-8e81-4c91-aa64-9b7274d7715d
Cell 26776ec2-6370-4ef1-8987-54aa61d8fe79 successfully created container for instance 1cc919a5-8e81-4c91-aa64-9b7274d7715d
Downloading app package...
Downloaded app package (2.6K)
-----> Liberty Buildpack Version: v3.44-20200430-1451
E, [2021-02-22T22:06:45.730075 #22] ERROR -- /tmp/buildpacks/fb2e823ce09e8909e2afd757be3d1971/lib/liberty_buildpack/buildpack.rb:50:in `rescue in drive_buildpack_with_logger': Compile failed with exception #<RuntimeError: No supported application type was detected>
No supported application type was detected
Failed to compile droplet: Failed to compile droplet: exit status 1
Exit status 223
Cell 26776ec2-6370-4ef1-8987-54aa61d8fe79 stopping instance 1cc919a5-8e81-4c91-aa64-9b7274d7715d
Cell 26776ec2-6370-4ef1-8987-54aa61d8fe79 destroying container for instance 1cc919a5-8e81-4c91-aa64-9b7274d7715d
Error staging application: App staging failed in the buildpack compile phase
FAILED
The error basically means the buildpack did not find an artifact it recognizes as an app it supports. The liberty buildpack recognizes wars, jars, liberty server directories and packaged servers.
The buildpack will look for an artifact in the current directory or in the directory specified with the -p CLI flag or path in the manifest.
Ensure your artifact exists where the buildpack can find it.

Error occurred during initialization of boot layer java.lang.module.FindException: Module jdk.management.agent not found

I am setting up my first Spring Boot application using Eclipse > New > Spring-Starter project
The project files are appearing and compiling.
I am even able to RunAs > Java project with console output.
On choosing RunAs > Spring Boot, I am getting the above error in the console:
Error occurred during initialization of boot layer java.lang.module.FindException: Module jdk.management.agent not found
My Java version is Java15, and I have also verified the same path is being used by Eclipse in About Eclispse > Installation Details > Configuration which shows
-vm C:\Program Files\Java\jdk-15.0.1\bin\server\jvm.dll
Running java --list-modules shows the management.agent module in the list shown in the command line output:
jdk.localedata#15.0.1
jdk.management#15.0.1
jdk.management.agent#15.0.1
jdk.management.jfr#15.0.1
Maven version installed is 3.3.6
I am not sure what I am missing. Any ideas?

Springboot Strange Resource Loading Behavior

I'm working on a springboot 1.5.1 application that I'm trying to load a WSDL included in my resources directory in the wsdl directory. Depending on where my application executes I'm getting different results (command line, intellij, cloud foundry) and I can't seem to get all three to work at the same time.
I've tried several ways of locating the resource:
From prior to the migration to springboot we had this (worked in IntelliJ but not java -jar myboot.jar):
this.getClass().getResource("/wsdl/my.wsdl");
I switched it to the typically more correct version and got it to work in IntelliJ and java -jar but not Cloud Foundry:
this.getClass().getClassLoader().getResource("/wsdl/my.wsdl");
I switched it to use the Spring Resource Loader version and it worked in IntelliJ and CloudFoundry but not java -jar:
#Value("classpath:/wsdl/my.wsdl")
private Resource wsdlResource;
wsdlResource.getURL();
On the command line what I've noticed is that it seems to be thinking that BOOT-INF/classes is a JAR file (Note the ! after classes):
Caused by: javax.xml.ws.WebServiceException: Failed to access the WSDL at: jar:file:/C:/dev/redacted/build/libs/redacted.jar!/BOOT-INF/classes!/wsdl/my.wsdl. It failed with:
JAR entry BOOT-INF/classes!/wsdl/my.wsdl not found in C:\dev\redacted\build\libs\redacted.jar.
From looking at IntelliJ's URL, it's referring to the actual source folder which explains why it seems to always work.
What is causing this and how might I universally load these class path resources successfully with springboot?

TIBCO Error: One Concept file not compiling

I am trying to build the project and the build is successful. However when I try to deploy the EAR file, it is throwing a class not found exception. I looked into the EAR file and I am seeing that the file which is throwing the error is not compiling and creating a class file. It is a concept file. Any help would be appreciated.
Try manually adding the missing file on the Resources tab of the enterprise archive's Shared Archive object. This should force it to be included in the EAR file.

Resources