Spring NoClassDefFoundError: JAXBException

If you facing this error: Then the reason is Java XML Binding, it is a tool for mapping between XML documents and Java objects. These classes has been removed from internal of JDK since 11 version and moved to Jakarta EE. This transition was happened with replacing javax to jakarta in package names. javax in your stacktrace tells us that […]

READ MORE

Accessing Spring Boot Actuator metrics programmatically

Suppose you have Spring Boot actuator in your application, and you want to access metrics programmatically. Or you want to gather a lot of system/application metrics initially. After you enable the Spring Boot actuator in your application (https://www.baeldung.com/spring-boot-actuators), just autowire all actuator auto wire candidates: You can use them like this: That’s all.

READ MORE

Java 8 date/time type not supported

Suppose you want to serialize some object to JSON. You may encounter the exception: We need to do two steps: Firstly, let’s add dependency from https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310. Next, let’s register JavaTimeModule within ObjectMapper: If you working with Spring or with some other framework, ObjectMapper can be instantiated implicitly. You need to override instantiation by yourself. For […]

READ MORE

No implementation of L32X64MixRandom

You may encounter exception, that states: The reason is JDK/JRE version and vendor. I noticed, that at least JBR-17 (JetBrains Runtime) hasn’t got L32X64MixRandom algorithm. You may want to switch to Azul-17 (Azul Zulu) to make it works again. If you build/run your application with Gradle, don’t forget to change Gradle JVM version in IntelliJ […]

READ MORE

How to generate heavy CPU load

Sometimes you need to generate heavy CPU load in your app for testing purposes. if you are using Spring, it will be very convenient to run multi-threaded password hashing: That code is non-blocking, so your program are not going to pause. If you want to pause, you may add the line to the end of […]

READ MORE

Send JSON as parameter in url using RestTemplate

If you try to send the json as a parameter in url via Spring’s RestTemplate, you will encounter the following error: In order to solve this problem, you need to: Encode the URL yourself Disable url encoding at the RestTemplate level. Let’s do that: Many thanks to Chris Liu for showing how to disable url […]

READ MORE