Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Exception in thread "main" javax.mail.NoSuchProviderException:

843789May 4 2009
I was using [this tutorial|http://www.javaworld.com/javatips/jw-javatip115.html?page=2] to write a basic JavaMail program using JSSE that makes a connection to a mail server and lists imap folders. I used the code for the DummySSLSocketFactory class in this tutorial to create a custom SSLSocketFactory that accepts all certificates without validation. I was able to successfully run my program from the command line using a shell script
JAVAHOME=/opt/java
export JAVAHOME
CLASSPATH=".:activation.jar:commons-logging.jar:jdom.jar:mail.jar:mstor.jar:javamaildir-0.4pre9.jar"
export CLASSPATH

cd "`dirname $0`"

exec "${JAVAHOME}/bin/java" -Xmx2048m imaptest 
When I import my project into NetBeans I'm able to compile successfully, but I get the following error when I try to run it
Exception in thread "main" javax.mail.NoSuchProviderException: No provider for imaps
this is because NetBeans is not finding the DummySSLSocketFactory class and is not able to set the Property
            Security.setProperty("ssl.SocketFactory.provider",
                    "DummySSLSocketFactory");
I need to make the DummySSLSocketFactory class available to my code in NetBeans. By placing the DummySSLSocketFactory.class in the same directory as my code, I was able to run it from the command line, but NetBeans is not able to see it. I've tried adding the DummySSLSocketFactory.class to my package, and I've tried creating a jar file from this .class file and adding it to my project libs, but I'm getting the same error.

Thanks for any advice, I'd be happy to provide any other information.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 1 2009
Added on May 4 2009
0 comments
137 views