Search code examples
javaemailjakarta-eejava-ee-6runtime-error

Strange error when trying to send email


The following strange error is returned. I cannot understand where it's coming from as the Netbeans debugger is quite lacking.

Exception in thread "AWT-EventQueue-0" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/Address
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at modules.impl.EmailModule.process(EmailModule.java:41)
    at agent.AgentDriver.callModules(AgentDriver.java:66)
    at agent.AgentDriver.process(AgentDriver.java:33)
    at agent.AgentUI.agentTextFieldActionPerformed(AgentUI.java:71)

Solution

  • Turns out this actually has to do with Java EE. This solution comes from here and here.

    Java EE can screw up your classpath, so often it just needs to be removed and added again (or just removed). If your classpath has issues, you can occasionally get a java.lang.ClassFormatError, which is what happened here.