Encountered "no netty_resolver_dns_native_macos_x86_64 in java.library.path" when attempting use Spring Webflux WebClient - spring-boot

as per the title above.
Been getting this error:
00:41:21.549 [main] DEBUG io.netty.util.internal.NativeLibraryLoader - Unable to load the library 'netty_resolver_dns_native_macos_x86_64', trying other loading mechanism.
java.lang.UnsatisfiedLinkError: no netty_resolver_dns_native_macos_x86_64 in java.library.path:
While trying to test out WebClient as a replacement for RestTemplate.
What I've tried:
Excluding Netty from the spring-boot-starter-webflux dependency and adding spring-boot-starter-reactor-netty as an explicit dependency.
Adding netty-resolver-dns-native-macos as a dependency.
Neither seems to work.
Using spring boot parent 2.4.2
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<version>4.1.79.Final</version>
<classifier>osx-aarch_64</classifier>
</dependency>

Related

No operations defined in spec! error on swagger UI

I am working on to migrate the version of spring boot. I am using spring boot with jersey. After upgrade the version of spring boot and other dependencies, swagger is not working for me. I did not modified any configuration.
Dependencies in pom:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.10</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.SR1</version> <type>pom</type> <scope>import</scope> </dependency> -->
<!-- Jersey -->
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<version>1.6.6</version>
</dependency>
Swagger configuration:
private void configureSwagger() {
register(SwaggerSerializers.class);
register(ApiListingResource.class);
BeanConfig beanConfig = new BeanConfig();
beanConfig.setTitle("API documentation");
beanConfig.setVersion(api.name());
beanConfig.setSchemes(new String[] {
"https", "http"
});
beanConfig.setBasePath("/api" + api.getPath());
// ConfigId and ScannerId must also be set as init parameters
// during servlet configuration
beanConfig.setConfigId(api.name());
beanConfig.setScannerId(api.name());
beanConfig.setUsePathBasedConfig(true);
beanConfig.setResourcePackage("com.api.v1.priv.resources");
beanConfig.setPrettyPrint(true);
beanConfig.setScan(true);
}
Changes in migration:
Spring boot version upgraded from 2.0.5.RELEASE => 2.6.10
swagger-jersey2-jaxrs upgraded from 1.5.18 => 1.6.6
Note - Swagger configuration was already existing. No changes has been done.
I am able to run the project successfully after migration. All api end points are working fine. But unfortunately swagger stopped working.
Swagger error:
I have gone through the lot of tutorials/blogs but not able to find the solution. Thanks everyone in advance.
In my case, it was due to conflict of org.reflections library. switched from 0.10 back to 0.9.12 fixed the issue.
Recommendation for migration:
Actually the problem was in technique of migration. We should not jump to latest version directly. We should continue version by version by considering the release notes. If you want to switch from spring 2.0.0 to 2.7.0, don't directly jump into it. Just move first 2.1.0..2.2.0.. etc. Clean and Build the project on each and every step of the migration.
Thanks!!!

RESOLVED - Spring Boot Starter Mail - failed to access class com.sun.activation.registries.LogSupport from class javax.activation.MimetypesFileTypeMap

I want to share the solution for above issue when using Spring Boot Starter Mail and attempt to create instance of MimeMessageHelper results in exception:
failed to access class com.sun.activation.registries.LogSupport from class javax.activation.MimetypesFileTypeMap
The issue is behind the jaxb-core dependency in version 4.0.0 which brings angus-activation library dependency. The library if loaded first doesn't have a public class of LogSupport.
The correct source of LogSupport is from com.sun.activation:jakarta.activation library.
Solution is to exclude the following in jaxb-core dependency:
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>4.0.0</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.angus</groupId>
<artifactId>angus-activation</artifactId>
</exclusion>
</exclusions>
</dependency>
At the same time the following dependency should be available:
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
<version>2.0.1</version>
</dependency>

Is the latest Spring cloud task incompatible with spring-boot 2.6.6?

I am trying to use the spring-cloud-task-core version 2.4.1 with the spring-boot version 2.6.6 (from the 2021.0.x release train).
This is showing me the below error:
Your project setup is incompatible with our requirements due to following reasons:
- Spring Boot [2.6.6] is not compatible with this Spring Cloud release train
Action:
Consider applying the following actions:
- Change Spring Boot version to one of the following versions [2.4.x, 2.5.x] .
You can find the latest Spring Boot versions here [https://spring.io/projects/spring-boot#learn].
If you want to learn more about the Spring Cloud Release train compatibility, you can visit this page [https://spring.io/projects/spring-cloud#overview] and check the [Release Trains] section.
If you want to disable this check, just set the property [spring.cloud.compatibility-verifier.enabled=false]
Does it mean that the cloud-task 2.4.1 is incompatible with spring-boot 2.6.6? Wanted to confirm here first before I raise the issue with the spring community.
Edit-1:
My Pom.xml for using spring-cloud-task-dependencies as BOM:
For previous spring-boot 2.1.1:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
For proposed spring-boot 2.6.6 or 2.5.12:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>${spring-cloud-task-dependencies.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Here, I have to use the spring-cloud-task-dependencies.version because the spring-boot.version gives below error:
Spring Boot 2.6.6 and Spring Cloud Task 2.4.1 are compatible.
The message is generated by the SpringBootVersionVerifier that is part of spring-cloud-commons. You seem to have that artifact with version 3.0.x on your classpath although you need version 3.1.x.
You need to ensure that the version of spring-cloud-commons is not somehow fixed to some old version. It's easiest to have the version managed by the bom of the Spring Cloud release train 2021.0.x.
The maven snippet from the Spring Initializr for this is
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
where spring-cloud.version should be set to 2021.0.1.

Getting java.lang.NoSuchMethodError: org.yaml.snakeyaml.Yaml.<init> while running spark based spring boot application

SnakeYaml jar present at classPath: snakeyaml-1.26.jar
2330 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.yaml.snakeyaml.Yaml.<init>(Lorg/yaml/snakeyaml/constructor/BaseConstructor;Lorg/yaml/snakeyaml/representer/Representer;Lorg/yaml/snakeyaml/DumperOptions;Lorg/yaml/snakeyaml/LoaderOptions;Lorg/yaml/snakeyaml/resolver/Resolver;)V
at org.springframework.boot.env.OriginTrackedYamlLoader.createYaml(OriginTrackedYamlLoader.java:71)
at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:162)
at org.springframework.boot.env.OriginTrackedYamlLoader.load(OriginTrackedYamlLoader.java:76)
at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:50)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadDocuments(ConfigFileApplicationListener.java:607)
I had a similar problem and my solution was to use snakeyaml in the exact same version as spring boot does.
In general a good trick is to import maven dependencies from org.springframework.boot:spring-boot-dependencies in order to avoid version incompatibilities.
If you're using mvn, add this under <dependencyManagement> in your pom:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
and then this under <dependencies>:
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<scope>runtime</scope>
</dependency>
For example spring-boot-dependencies-2.3.6.RELEASE.pom uses snakeyaml in 1.26:
<snakeyaml.version>1.26</snakeyaml.version>
Whereas spring-boot-dependencies-2.5.12.pom uses 1.28:
<snakeyaml.version>1.28</snakeyaml.version>
And spring-boot-dependencies-2.6.1.pom uses 1.29:
<snakeyaml.version>1.29</snakeyaml.version>
Hope this helps.

ValidationException with Spring boot and Jetty

I set up a spring boot application(1.4.0.RELEASE) with the following configuration
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
As expected, this ran with embedded Tomcat. I then thought of trying the same with a Jetty server and followed the steps mentioned in the documentation here:
Using Jetty instead of Tomcat
Basically excluding Tomcat and adding dependency for Jetty.Running mvn clean install from the command line or running the main method resulted in the following exception:
Caused by: javax.validation.ValidationException: HV000183: Unable to
load 'javax.el.ExpressionFactory'. Check that you have the EL
dependencies on the classpath, or use ParameterMessageInterpolator
instead
I could solve this by adding the following dependency in the pom.xml:
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
</dependency>
I am not directly using any validation related code but I suspect this is getting pulled from the spring boot jpa starter which pulls in Hibernate. I have also seen a discussion around this here: Similar issue
Questions:
1) Is this the right fix?
2) If it is the right fix, should the documentation be updated to add this dependency as well?
You are correct in using the javax.el dependency. When the JPA pulls in Hibernate as you stated, it will use the Hibernate Validator. It's specified here. This is the right fix. As for the documentation, I personally would raise it but I suspect not everyone will have the same issue. I still can run my mvn clean install without errors however if I run mvn spring-boot:run it starts up and shuts-down straight after.

Resources