classnotfound when POP3s account connected to before IMAPs account
I have implemented the DummySSLSocketFactory stuff for handling unsinged certs on POP3s ser vers and it works fine, However is I connect to one of these servers before connecting to an IMAPs server I get the following error:
javax.mail.MessagingException: java.lang.ClassNotFoundException: com.cc.util.controller.email.DummySSLSocketFactory;
nested exception is:
java.net.SocketException: java.lang.ClassNotFoundException: com.cc.util.controller.email.DummySSLSocketFactory
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at com.cc.util.controller.email.JavaMailEmailController.getJavaMailStoreIMAPS(JavaMailEmailController.java:203)
at com.cc.util.controller.email.JavaMailEmailController.getJavaMailStore(JavaMailEmailController.java:173)
at com.cc.util.controller.email.JavaMailEmailController.<init>(JavaMailEmailController.java:88)
at com.cc.util.controller.email.IMAPEmailController.<init>(IMAPEmailController.java:20)
at com.cc.util.controller.ControllerFactory.getEmailController(ControllerFactory.java:151)
at com.cc.util.controller.ControllerFactory.verifyLoginInformation(ControllerFactory.java:72)
at com.cc.util.discovery.DiscoveryService.discoverIMAPService(DiscoveryService.java:277)
at com.cc.util.discovery.DiscoveryService.checkEmailService(DiscoveryService.java:101)
at com.cc.applet.CCNonBlockingThread$1.run(CCNonBlockingThread.java:205)
at java.security.AccessController.$$YJP$$doPrivileged(Native Method)
at java.security.AccessController.doPrivileged(Unknown Source)
at com.cc.applet.CCNonBlockingThread.processEventData(CCNonBlockingThread.java:203)
at com.cc.applet.CCNonBlockingThread.run(CCNonBlockingThread.java:154)
Caused by: java.net.SocketException: java.lang.ClassNotFoundException: com.cc.util.controller.email.DummySSLSocketFactory
at javax.net.ssl.DefaultSSLSocketFactory.throwException(Unknown Source)
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:224)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.iap.Protocol.<init>(Protocol.java:84)
at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:87)
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:446)
... 15 more
Caused by: java.lang.ClassNotFoundException: com.cc.util.controller.email.DummySSLSocketFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.$$YJP$$doPrivileged(Native Method)
at java.security.AccessController.doPrivileged(Unknown Source)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at javax.net.ssl.SSLSocketFactory.getDefault(Unknown Source)
... 20 more
If the I reverse it, connect to IMAPs first and then to POP3s it works fine. I assume that this has to do with this code:
// the line below is for java 1.5
java.security.Security.setProperty("ssl.SocketFactory.provider","com.cc.util.controller.email.DummySSLSocketFactory");
// these are for java 1.4
props.setProperty("mail.pop3s.socketFactory.class","com.cc.util.controller.email.DummySSLSocketFactory");
props.setProperty("mail.pop3s.socketFactory.fallback","false");
which I do before connecting to the POP3s service. In this case the connection being made to POP3s comes from a different thread than the connection to the IMAPs. Everything is in a single jar and this is an applet. I'm confused as to why it can't find the class after it has already found it. I mean at the root the threads should all have the same class loader shouldn't they?

