• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with java mail.

 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to include the java mail functionality in my application.
i got an example for mailing. As an individual class with main it worked good. But i removed the main part of that program and made that as the function so that i can call that by passing the arguments. but i am getting javax.mail.NoSuchProviderException: No provider for smtps error.
i have included the code(what i made as function by just removing the main )

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See http://java.sun.com/products/javamail/FAQ.html#gmail for an example of how to connect to Gmail; the "mail.transport.protocol" thing looks odd.
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No did not get the solution.
 
Paul Clapham
Sheriff
Posts: 20986
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But presumably you modified your code based on what you read in the FAQ? If not, then you should. But now notice that we can't see the code you are asking about. Nor, for that matter, do we know what problem you are now having.
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Backtracked to my code posted above, getting the same error. javax.mail.NoSuchProviderException: No provider for smtps
What exactly it means " No provider for smtps" i have included all the jars.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "backtracked" - that you're now again using the code you posted above? Why? What was the result of you reading and implementing the FAQ entry I pointed you to?
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to implement in the method given in FAQ. But it gave me an error i was really frustrated with all those errors and i deleted that program. So i am trying to implement in the way in which i started.
i need to know why javax.mail.NoSuchProviderException: No provider for smtps this exception raises?
Can someone please explain this?
Thanks
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to implement in the method given in FAQ. But it gave me an error i was really frustrated with all those errors and i deleted that program. So i am trying to implement in the way in which i started.

So now you're using code that you KNOW does not work, because you couldn't understand the code that purportedly does work? Did it occur to you to try and track down the problem (whichever that was) you had with that code?
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. I would like to know why its throwing that error.
The code works as a class with the main in it. But if i make it as a function and call it from another class then its throwing this error.
So i am trying to find out the reason for its behavior. (May be something i have missed) So need to know the reason.
Thanks
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do help in integrating java mail to my application.
i am getting the below error
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does session.getProviders() return? Is smtps one of the supported providers?
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It says no provider.



So what am i suppose to use for GMAIL?

Please help
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You haven't even tried my advice, have you? Because that exception is definitely not thrown when you call getProviders().
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,
I did try that. in the list of providers SMTP,POP3 and IMAP are listed. But not the SMTPS.
That exception is thrown when the we call the getProvider is called.
Please advise what we have to use for gmail.
thanks
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect that you would have long solved this problem if you had followed the advice I gave in my first post.
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If SMTPS is not one of the providers then no secure SMTP connections can be made at all. JAidev, have you tried updating your JavaMail libraries? Perhaps they are older versions that don't have SMTPS yet - mine do.
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have two different code. The first code works fine. Its a class with main().

1st code

I can send the mail using this code.
When i remove the main and make the same code to be a function and call it from another function then i am getting this error javax.mail.NoSuchProviderException: smtps
Modified code (as a function)

 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From debug i have noticed the resource file is getting loaded from the wrong place. Basically its not pointing to the new mail.jar(1.4.3).
First is the debug from the working code-
----
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
Here struts_1_0_2.jar,weblogic_modified.jar are used.
----
But in my code the resource is getting loaded from a different location.
DEBUG: not loading system providers in <java.home>/lib
DEBUG: not loading optional custom providers file: /META-INF/javamail.providers
DEBUG: successfully loaded default providers
I am using message.jar,mysql-connector-java-3.1.12.jar,struts_1_0_2.jar,weblogic_modified.jar in my application.
Is any of the jar file is creating the conflict?Both are running on the same eclipse but in different projects.
Please let me know.
Thanks
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now its picking from the correct resource file after including the mail.jar and activation.jar to the classpath.
But now i am getting another exception.
error

Please help with the exception.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.NoClassDefFoundError: javax/net/ssl/SSLPeerUnverifiedException

Yikes! That class has been part of the JRE since Java 1.4; which JRE version are you using?
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using JRE 1.6.0
Do i need to place jsse.jar in lib\ext folder?
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is anything missing in the classpath?
 
Jaidev Arer
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As mentioned earlier i have two codes.
One the independent code which works and another code which is the part of the application and this has an issue.
Today i used the System.out.println("classpath = " + System.getProperty("java.class.path")); to see what was in the classpath. i got two different output.
classpath for the working code


classpath for the application code

None of the jar file are present in the classpath.
Can someone please help with the reason for the strange behavior in picking the classpath.
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic