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

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>

Related

Getting "Finished Loading Resource Information. Rendering Swagger UI..." on loading swagger after migration from spring to sprinboot

We just migrated our application from Spring to Sprinboot (2.7.0). whenever i load swagger, all the apis dont get loaded and i get this line "Finished Loading Resource Information. Rendering Swagger UI..." on the top.
But http://host:port/v2/api-docs loads all the apis.
earlier we have below swagger related dependencies in our pom.xml
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${version.io.springfox}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.8</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.6.8</version>
</dependency>
dependencies. I tried with that, i got same issue.
Later i tried adding springfox-boot-starter dependency and commenting out specific swagger based spring dependencies but no luck. I tried to search for a solution but couldnt find anything concrete.
Any idea why this is happening?

"No tests were found" when running individual test in Intellij with Spock and Spring Boot

Running whole test class works just fine. However when I try to click gutter icon next to the test method I get following error:
org.junit.platform.commons.JUnitException: TestEngine with ID
'junit-jupiter' failed to discover tests
Problem is related with newest changes in junit platform. Not sure what exactly changed, but following steps fixed tests for me:
Change junit platform version to 1.5.2 (this is the last one working):
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<version>1.5.2</version>
</dependency>
Exclude junit vintage engine from spring-boot-starter-test:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>

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

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>

Spring Boot No Class found error though starter dependency has added classes in classpath

Despite having appropriate jars in classpath Spring Boot throws - java.lang.ClassNotFoundException: org.apache.camel.spring.spi.XmlCamelContextConfigurer
Any suggestions what is missing here.
I have added the respective starters in pom.xml as shown below:
<dependency>
<groupId>org.springframework.boot</groupId>[![enter image description here][1]][1]
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>2.19.3</version>
</dependency>
The project maven dependencies also shows the class availability, as in given image attachment.
the answer is here - https://stackoverflow.com/a/34271507/2885422 It all depends how maven loads the class. There are 2 version of camel-spring.jars available in classpath (2.20.1 and 2.19.3. Ref: my original post image)
And org.apache.camel.spring.spi.XmlCamelContextConfigurer class is available only in 2.20.1 jars. And maven by default looks in earlier one and once package found matching but no class found throws error (?)
And the reason I believe 2.19.3 get loaded is Apache-cxf jars is of 2.19.3. Unfortunately our project repository does not have apache-cxf starter jars.
https://stackoverflow.com/a/34271507/2885422
Solution: - I hope it may be helpful for future references
By adding options I could resolve the issue,by having exclusion clause added as given below. Thus I could load only required version jars.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>2.19.3</version>
<exclusions>
<exclusion>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</exclusion>
</exclusions>
</dependency>'

How to exclude dependency of wsdl4j in axis1.4 as it is affecting the application not to work by throwing InovcationTargetException

Caused by:
java.lang.IncompatibleClassChangeError: Class com.ibm.wsdl.DefinitionImpl does not implement the requested interface javax.wsdl.extensions.AttributeExtensible
The reason for axis-wsdl4j-1.5.1.jar getting downloaded when you try and build using axis:1.4 in your project is that it is defined within dependency for the artifact itself..
If you don't want to download axis-wsdl4j-1.5.1.jar, you can exclude it from your project by making following changes to your pom.xml -
<dependencies>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
<exclusions>
<exclusion> <!-- declaring the exclusion here -->
<groupId>axis</groupId>
<artifactId>axis-wsdl4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--...other dependencies -->
<dependencies>

Resources