• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java mail with WLS8.1

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi! everybody
Im developing a mailing system and im using WLS8.1 as the application server.
I've set the following session propeties using admin console when creating a mailsession.
The parameters are:

mail.host=localhost
mail.transort.protocol=smtp
mail.store.protocol=imap
mail.imap.host=localhost
mail.user=postmaster
mail.debug=true

Im retriving the mail using this code
public class MailRetriver
{
...
...
string host="";
string username="";
string password=""
...
...
//JNDI look up for the session

Store store = session.getStore();
store.connect(host, username, password);
Folder folder = store.getDefaultFolder();
folder = folder.getFolder("INBOX");
...
...
}

im getting the the following error

DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:265)
at javax.mail.Service.connect(Service.java:135)
at javax.mail.Service.connect(Service.java:87)
at com.MailReciever.getAllMessages(MailReciever.java:53)
at jsp_servlet.__inbox._jspService(__inbox.java:155)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:463)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6452)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
<Nov 27, 2004 9:11:23 PM GMT+05:30> <Error> <HTTP> <BEA-101020> <[ServletContext(id=33486858,name=lms,context-path=/lms)
] Servlet failed with Exception
java.lang.NullPointerException
at jsp_servlet.__inbox._jspService(__inbox.java:158)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:463)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6452)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
>


My question is what values should i provide in the connect()method.
ie the values for host,username,password considering the session properties that i've provided above.
The username and the password for the server,which is providing me the mail service is

username = admin
password = password

Pleez anyone look in to it and proviede me with the help.
Thanking in advance.
With Regards
Ved gunjan
 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have developed about a year ago a simple bunch of classes that I have already used under tomcat and weblogic, It send's siple text messages, you may change as you need to fit your requirements. Note that messages are in portuguese you may want to change that, for sure.

The exception class:



A simple Autenticato class:



Finally the class that does all the stuff:




To use it you just have to create an instance and pass the infomation for the method, follows a sample using struts to get the input from a jsp page:




Notice that I don't do password encription here, it's passed as simple text, if you need it you'll have to implement.

regards.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic