Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Problem in sending a mail from a servlet

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

I am developing a servlet which will send email... i am calling a java class from that servlet which will take care of sending the mail. But when i am trying it as standalone its working fine, but trying from a servlet its giving problem like throwing .
Javax.activation.DataSource class is not found.
But i have added all the jars required for that.. incuding javax.action.*

What may be the problem??

Thaks and regards in advance...
[ May 14, 2008: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hope it will work if you add activation.jar file.
 
Arun Kumar Gaddam
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have done that also ,not only i added that jar to web-inf lib but also to tomcat lib....... but at the last same problem................ it is giving exception at this line...........

MimeMessage message = new MimeMessage(session);
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.. could you copy paste the code?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Arun Kumar Gaddam:
i have done that also ,not only i added that jar to web-inf



You put it in 'web-inf' or you put it in 'WEB-INF'?
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

It would be helpful if you can post the code which you have used.
 
Arun Kumar Gaddam
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok ill post the code........


//Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
//Adding required properties to send an email
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", "smtp.gmail.com");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
//props.put("mail.debug", "true");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");

System.out.println("Added all properties ..........\n");

//Creating an session object
System.out.println("==== 1 =====");
//javax.mail.Session sess = javax.mail.Session.getDefaultInstance(props,new Authenticate());
javax.mail.Session sess = javax.mail.Session.getInstance(props,new Authenticate());
//session.setDebug(true);

System.out.println("==== 2 =====");

//Creating an transport object
Transport transport = sess.getTransport();

InternetAddress addressFrom = new InternetAddress(_userName);

javax.mail.Message message = new MimeMessage(sess);------>1

System.out.println("Created an mimemessage obj........\n");
InternetAddress _to=new InternetAddress(email);


message.setRecipient(RecipientType.TO, _to);
message.setSubject("YOUR PASSWORD");
message.setContent(_emailMessageText, "text/html");
//message.addRecipients(Message.RecipientType.TO,_to);

System.out.println("Message obj ready to transport.....\n");

transport.connect();
transport.send(message);
transport.close();

System.out.print(" \nSuccess, Email sent to "+email);

System.out.println("<============== After sending to SendEmail class ============>\n");
System.out.println("Email Sent ....");*/

RequestDispatcher rd = request.getRequestDispatcher("successemail.jsp");
rd.forward(request, response);




Its throwing exception at line ------->1
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
Arun Kumar Gaddam
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats ok sorry for not using code tags.....

here is my code please help me......
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Prasad Tamirisa:
Hi,

It would be helpful if you can post the code which you have used.



If the original poster is having a problem with a class not found exception, and has already stated that his code is working in a stand alone application, how would posting his code help?
 
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The three jars needed to send mail with your code are activation.jar, mailapi.jar and smtp.jar. Of these 3 jars only activation.jar contains javax.activation.DataSource.

Hence kindly ensure you have copied it in the correct WEB-INF/lib. [There may be a chance you are copying it into yet another web application's WEB-INF/lib.
 
Arun Kumar Gaddam
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now its another one.........

its giving......

java.lang.SecurityException: SHA1 digest error for javax/mail/Authenticator.class
sun.security.util.ManifestEntryVerifier.verify(Unknown Source)
java.util.jar.JarVerifier.processEntry(Unknown Source)
java.util.jar.JarVerifier.update(Unknown Source)
java.util.jar.JarVerifier$VerifierStream.read(Unknown Source)
sun.misc.Resource.getBytes(Unknown Source)
java.net.URLClassLoader.defineClass(Unknown Source)
java.net.URLClassLoader.access$100(Unknown Source)
java.net.URLClassLoader$1.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(Unknown Source)
java.lang.ClassLoader.loadClass(Unknown Source)
java.lang.ClassLoader.loadClass(Unknown Source)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1345)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
java.lang.Class.getConstructor0(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Unknown Source)
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic