Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] don't require smime-module when adding collection of headers (also used when copying email) #493

Closed
jbonn1 opened this issue Jan 25, 2024 · 2 comments

Comments

@jbonn1
Copy link

jbonn1 commented Jan 25, 2024

When attempting to use EmailBuilder.copying(Email email), it throws an exception NoClassDefFoundError: org/simplejavamail/internal/smimesupport/SmimeRecognitionUtil. This can be fixed by adding smime-module to the pom.xml, but I don't need any smime support. Is there another copy option perhaps?

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.example</groupId>
  <artifactId>simplejavamailtest</artifactId>
  <version>1.0-SNAPSHOT</version>

  <properties>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.simplejavamail</groupId>
      <artifactId>simple-java-mail</artifactId>
      <version>8.5.1</version>
    </dependency>
  </dependencies>

</project>

Code:

package org.example;

import org.simplejavamail.email.EmailBuilder;

public class Main {

    public static void main(String[] args) {
        var email = EmailBuilder.startingBlank()
                .withHeader("header", "hello")
                .buildEmail();

        var newEmail = EmailBuilder.copying(email).buildEmail(); // <--- Throws exception here

        System.out.println(newEmail);
    }
}

Exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/simplejavamail/internal/smimesupport/SmimeRecognitionUtil
	at org.simplejavamail.email.internal.EmailPopulatingBuilderImpl.withHeaders(EmailPopulatingBuilderImpl.java:1728)
	at org.simplejavamail.email.internal.EmailStartingBuilderImpl.copying(EmailStartingBuilderImpl.java:244)
	at org.simplejavamail.email.EmailBuilder.copying(EmailBuilder.java:149)
	at org.example.Main.main(Main.java:15)
Caused by: java.lang.ClassNotFoundException: org.simplejavamail.internal.smimesupport.SmimeRecognitionUtil
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
	... 4 more
@bbottema
Copy link
Owner

Yikes, this is a bug. Thanks for reporting! I'll get a patch out soon.

@bbottema bbottema added this to the 8.6.2 milestone Jan 27, 2024
@bbottema bbottema changed the title Copying Email throws NoClassDefFoundError: org/simplejavamail/internal/smimesupport/SmimeRecognitionUtil [bug] don't require smime-module when adding collection of headers (also used when copying email) Jan 27, 2024
bbottema added a commit that referenced this issue Jan 27, 2024
@bbottema
Copy link
Owner

Fix released in 8.6.2!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants