After migrating to Spring Boot 3 from 2.6.9, I am encountering the following error.
Root cause:
Caused by: java.lang.ArrayStoreException: arraycopy: element type mismatch: can not cast one of the elements of java.lang.Object[] to the type of the destination array, jakarta.activation.MimeTypeRegistry
at java.base/java.lang.System.arraycopy(Native Method)
at java.base/java.util.Vector.copyInto(Vector.java:205)
at jakarta.activation.MimetypesFileTypeMap.<init>(MimetypesFileTypeMap.java:140)
at jakarta.activation.MimetypesFileTypeMap.<init>(MimetypesFileTypeMap.java:312)
at org.springframework.mail.javamail.ConfigurableMimeFileTypeMap.createFileTypeMap(ConfigurableMimeFileTypeMap.java:150)
at org.springframework.mail.javamail.ConfigurableMimeFileTypeMap.getFileTypeMap(ConfigurableMimeFileTypeMap.java:123)
at org.springframework.mail.javamail.ConfigurableMimeFileTypeMap.afterPropertiesSet(ConfigurableMimeFileTypeMap.java:110)
at org.springframework.mail.javamail.JavaMailSenderImpl.<init>(JavaMailSenderImpl.java:115)
at org.springframework.boot.autoconfigure.mail.MailSenderPropertiesConfiguration.mailSender(MailSenderPropertiesConfiguration.java:44)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:139)
... 74 common frames omitted
I have added following two dependencies as a solution suggested by other Stack Overflow answers, but that didn't work.
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb-runtime.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>2.1.1</version>
<scope>runtime</scope>
</dependency>
I also tried solution provided by Tomcat 10, Java 17 - JavaMailSender cannot cast one of elements of java.lang.Object[] and https://github.com/spring-projects/spring-boot/issues/33452, which didn't work either.