1

I'm new to Java and am getting the dreaded java.lang.NoClassDefFoundError for javax.mail.internet.AddressException

I've followed most of the usual debugging methods but can't see why the class is only missing in my dependencies. The class is found fine in my own code.

//Set up 
EncryptionUtils utilities = EncryptionManager.getEncryptionUtils(EncryptionManager.PGP);
EncryptionKeyManager pgpKeyMgr = utilities.createKeyManager();

//this works fine, and creates the object as expected
javax.mail.internet.AddressException addressException = new AddressException();

//this crashes, java.lang.ClassNotFoundException: javax.mail.internet.AddressException
pgpKeyMgr.publicKeyAliases();

I sort of understand that EncryptionKeyManager must be looking in a different place for classes. My understanding hits a brick wall at this point. What could be going wrong?

ERROR [2015-11-27 17:43:32,205] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: d2d5e42dae1bb16d
! java.lang.ClassNotFoundException: javax.mail.internet.AddressException
! at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_65]
! at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_65]
! at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_65]
! ... 64 common frames omitted
! Causing: java.lang.NoClassDefFoundError: javax/mail/internet/AddressException
! at net.suberic.crypto.cryptix.CryptixKeyManager$CryptixKeyAlias.<init>(CryptixKeyManager.java:468) ~[javamail-crypto-cryptix-openpgp.jar:na]
! at net.suberic.crypto.cryptix.CryptixKeyManager.publicKeyAliases(CryptixKeyManager.java:355) ~[javamail-crypto-cryptix-openpgp.jar:na]
christofr
  • 2,680
  • 1
  • 18
  • 19
  • Show us the command you are using to run your program. The classpath *MUST* be different than the classpath you are compiling with. – JJF Nov 27 '15 at 18:17
  • Hi! > sudo mvn compile exec:exec -pl misc-service --quiet – christofr Nov 27 '15 at 18:42
  • My pom.xml is here: http://pastebin.com/WX9sssVQ (thanks) – christofr Nov 27 '15 at 18:42
  • What is javamail-crypt-cryptix-opengpg.jar? You don't have anything like that included in your POM. Did you specify this JAR in your IDE as project dependency? In that case it is clear it won't work. You have to specify every library as Maven dependency. – dunni Nov 27 '15 at 20:29
  • How are you executing the project? In command line using java -jar command or in eclipse? – Omkar Puttagunta Nov 28 '15 at 08:59
  • Are you trying it in Android? Because I faced a similar issue, added Android specific port of JavaMail and all the NoClassDefFoundError disappeared! – Shishir Gupta Apr 18 '16 at 18:10

0 Answers0