ADDRESS parse error in java mail

Hi,
I'm trying to retrieve the mails header and I get following error.
javax.mail.MessagingException: Failed to load IMAP envelope: foldername=INBOX[uidvalidity:1222323518] : seqnum=1
After digging source code of java mail I found that one of bad address is causing this problem. One of message is having following format of address.
("test" R "test" NIL "test1" "test.net.au").
According to specifications (RFC 2060) address should have four component personal name, [SMTP] at-domain-list (source route), mailbox name, and host name. When java mail tries parse this address it throws address parsing exception.
Is anyone have come across this issue? I want to know is there any way to handle this scenario. Since other mail client seems to handle it e.g. thunderbird
Regards
Anupriya

I'm using java mail 1.4.1. I downloaded the code from https://glassfish.dev.java.net/javaee5/mail//index.html and I haven't made any changes to code.
I'm running msgshow.java program. I'm not running in any app server or web server.
and following is output from program as i was mentioning earlier it's happening when I try to get the size of the message.
DEBUG: setDebug: JavaMail version 1.4.1
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
DEBUG: mail.imap.fetchsize: 16384
* OK IMAP4 server (InterMail vM.7.05.02.03 201-2174-114-109-20070208) ready Tue, 25 Nov 2008 04:22:06 +0000 (GMT)
A0 CAPABILITY
* CAPABILITY IMAP4rev1 UIDPLUS NAMESPACE QUOTA
A0 OK CAPABILITY completed
DEBUG: protocolConnect login, host=test.com, [email protected], password=<non-null>
A1 LOGIN [email protected] pass
A1 OK LOGIN completed
A2 CAPABILITY
* CAPABILITY IMAP4rev1 UIDPLUS NAMESPACE QUOTA
A2 OK CAPABILITY completed
DEBUG: connection available -- size: 1
A3 SELECT INBOX
* 24 EXISTS
* OK [UIDVALIDITY 1222323518] UIDs valid
* OK [UIDNEXT 1031] Predicted next UID
* FLAGS (\Answered \Flagged \Deleted \Draft \Seen)
* OK [PERMANENTFLAGS (\* \Answered \Flagged \Deleted \Draft \Seen)] Permanent flags
* 0 RECENT
A3 OK [READ-WRITE] SELECT completed
Getting message number: 20
A4 FETCH 20 (BODY[])
* 20 FETCH (BODY[] {569}
Return-Path: <[email protected]>
Received: from [127.0.0.1] by nssas01t.mx.test.com
(InterMail vM.7.05.02.08 201-2174-114-118-20080528) with SMTP
id <20071127054828.IKXY25226.nssas01t.mx.test.com@[127.0.0.1]>
for <[email protected]>; Mon, 17 Nov 2008 05:48:28 +0000
Date: Mon, 7 Feb 2008 21:52:25 -0800 (PST)
From: "Test" R "Us"<[email protected]>
Subject: afternoon meeting 1
To: [email protected]
Message-Id: <20071127054828.IKXY25226.nssas01t.mx.test.com@[127.0.0.1]>
Hello
A4 OK FETCH completed
Return-Path: <[email protected]>
Received: from [127.0.0.1] by nssas01t.mx.test.com
(InterMail vM.7.05.02.08 201-2174-114-118-20080528) with SMTP
id <20071127054828.IKXY25226.nssas01t.mx.test.com@[127.0.0.1]>
for <[email protected]>; Mon, 17 Nov 2008 05:48:28 +0000
Date: Mon, 7 Feb 2008 21:52:25 -0800 (PST)
From: "Test" R "Us"<[email protected]>
Subject: afternoon meeting 1
To: [email protected]
Message-Id: <20071127054828.IKXY25226.nssas01t.mx.test.com@[127.0.0.1]>
Hello
A5 FETCH 20 (FLAGS)
* 20 FETCH (FLAGS (\Seen))
A5 OK FETCH completed
A6 FETCH 20 (ENVELOPE INTERNALDATE RFC822.SIZE)
* 20 FETCH (ENVELOPE ("Mon, 7 Feb 2008 21:52:25 -0800 (PST)" "afternoon meeting 1" (("Test" R "Us" NIL "auto_786" "test.com")) (("Test" R "Us" NIL "auto_786" "test.com")) (("Test" R "Us" NIL "auto_786" "test.com")) ((NIL NIL "auto_786" "test.com")) NIL NIL NIL "<20071127054828.IKXY25226.nssas01t.mx.test.com@[127.0.0.1]>") INTERNALDATE "17-Nov-2008 05:48:46 +0000" RFC822.SIZE 569)
A6 OK FETCH completed
Oops, got exception! Failed to load IMAP envelope
javax.mail.MessagingException: Failed to load IMAP envelope
     at com.sun.mail.imap.IMAPMessage.loadEnvelope(IMAPMessage.java:1226)
     at com.sun.mail.imap.IMAPMessage.getSize(IMAPMessage.java:387)
     at javax.mail.internet.MimeMessage.<init>(MimeMessage.java:229)
     at msgshow.main(msgshow.java:232)

Similar Messages

  • Parse Error in Java

    I am very new to java and I have a piece of code which is written in javascript which i want to replicate in java basically it validates the structure of and XML Dom passed into it.
    function XMLParseError(XMLIsland, XMLName)
    if (XMLIsland.parseError.errorCode != 0)
    alert('XML Parse Error with ' + XMLName + '\n\nreason: ' +
    XMLIsland.parseError.reason +
    '\nline: ' + XMLIsland.parseError.line +
    '\npos: ' + XMLIsland.parseError.linepos +
    '\nsrcText:' + XMLIsland.parseError.srcText +
    '\nurl: ' + XMLIsland.parseError.url);
    in java i have
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    factory.setIgnoringComments(true); // We want to ignore comments
    // Now use the factory to create a DOM parser
    DocumentBuilder parser = factory.newDocumentBuilder();
    //final xml is an xml string
    xmldoc = parser.parse(new InputSource(new StringReader(finalXML)));
    if i want to catch the errors and print them to the screen similar to the javascript program how do i do this.....

    Create a class which extends the DefaultHandler(DefaultHanlder impleents the ErrorHandler interface)
    Set the ErrorHandler on the DocumentBuilder.
    builder.setErrorHandler(errorHandler);

  • WDDX Parse error in cfadmin Mail Spooler respool

    I recently discovered that emails were not being sent and were stacked up in the spooler.  In the CF Administrator interface, I verified that the mail server  connection was fine and it was. I went to "View Undelivered Mail" (under mail spool settings), reviewed the emails that were stuck and selected a random message to "respool".  Unfortunately, on every attempt to respool an email (one or many), I get the following error: "Error: WDDX packet parse error at line 1, column 1. Content is not allowed in prolog.."
    I have restarted the windows service twice, checked my email host...all to no avail. The error still occurs.
    I also unchecked the spooling option and emails (new ones only, not the spooled ones) are coming through just fine.
    I'm running CF9 full on Windows XP.
    How do I get the respool function working so I can send the stuck emails?  all suggestions welcome.

    /app/devtools/gcc-4.2.3-64/bin/g++ -L/home/john/sdc/lib/Linux_2.6.5-7.308.PTF.352368.0-smp.gcc-4.2.3-64 -L/home/john/oracle/lib -L/app/gcc-3.3.4/lib -L/app/gcc-3.2.3/lib -ldl -lpthread -lnsl -lrt -lstdc++ -lvs -lclntsh -L/home/cdev/pkgs/oas/Linux64/oaslinux64_2_4_05_03/lib -loas Linux_2.6.5-7.308.PTF.352368.0-smp.gcc-4.2.3-64-R/db.o Linux_2.6.5-7.308.PTF.352368.0-smp.gcc-4.2.3-64-R/owl.o Linux_2.6.5-7.308.PTF.352368.0-smp.gcc-4.2.3-64-R/queue.o Linux_2.6.5-7.308.PTF.352368.0-smp.gcc-4.2.3-64-R/log.o Linux_2.6.5-7.308.PTF.352368.0-smp.gcc-4.2.3-64-R/titan.o -o /home/amehta17/sdc/bin/Linux_2.6.5-7.308.PTF.352368.0-smp.gcc-4.2.3-64/titan
    /usr/bin/ld: warning: libnnz10.so, needed by /home/john/oracle/lib/libclntsh.so, not found (try using -rpath or -rpath-link)
    /home/amehta17/oracle/lib/libclntsh.so: undefined reference to `nzos_ServiceWriteQueue'
    /home/amehta17/oracle/lib/libclntsh.so: undefined reference to `nzosCipherSpecToStr'
    /home/amehta17/oracle/lib/libclntsh.so: undefined reference to `nzos_setCRLPath'
    /home/amehta17/oracle/lib/libclntsh.so: undefined reference to `nzteOpenPersona'
    /home/amehta17/oracle/lib/libclntsh.so: undefined reference to `nzdsi_initialize'
    All these symbols are not defined in libclntsh.so and also does not exist in libnnz10.so.
    I checked 32bit version of libnnz10.so has all above undefined symbols. This looks really weird to me why 64 bit version of libnnz10.so doesn't define these symbols.
    Let me know if you have any idea.

  • Error implementing Java Mail

    I downloaded the Javamail package extension and placed the mail.jar file in my WEB-INF/lib directory. Then I reloaded the application and did a restart. I am getting the following error message.
    com.sun.mail.smtp.SMTPSendFailedException: 550 bosauthsmtp12: Host 207.119.46.38: No unauthenticated relaying permitted
    Any help would be appreciated.
    Thanks,
    Julie Hall

    I am still having problems after reading the information. The mail is being called by a jsp program. I've taken most of the code from a book on JSP's. Here is the code inside my jsp file.
    <div id="MainLayer" style="padding-left:10px;padding-right:10px; overflow:hidden; height:100%"> <!-- InstanceBeginEditable name="Main" -->
    <%@ page import="java.util.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="javax.mail.*" %>
    <%@ page import="javax.mail.internet.*" %>
    <%@ page import="javax.activation.*" %>
    <jsp:useBean id="inn" scope="request" class="bnbTexas.Inn"/>
    <jsp:setProperty name="inn" property="*" />
    <%
         String host="mail.csites2go.com";
         String to = "[email protected]";
         String from = inn.getEmail();
         String messageText= "Test of email";
         boolean sessionDebug=true;
         Properties props = System.getProperties();
         props.put("mail.host", host);
         props.put("mail.transport.protocol", "smtp");
         Session mailSession= Session.getDefaultInstance(props, null);
         mailSession.setDebug(sessionDebug);
         try
         Message msg = new MimeMessage(mailSession);
         if (from != null)
              msg.setFrom(new InternetAddress(from));
         else
              msg.setFrom();
         InternetAddress[] address = {new InternetAddress(to)};
         msg.setRecipients(Message.RecipientType.TO, address);
         msg.setSubject("bnb Directory");
         msg.setSentDate(Calendar.getInstance().getTime());
         msg.setText(messageText);
         Transport.send(msg);
         catch (MessagingException mex) {
         mex.printStackTrace();
         out.println("mail was sent to " +to);
         out.println(" from " + from);
         out.println(" using host " host ".");
         %>
    <!-- InstanceEndEditable --></div>
    </div>
    Do I need to put the username and password in the properties list before getting a session??

  • Error in java mail

    hi,
    i am getting this error while trying to run a sample program...
    could you help me out....
    thanks
    Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/Lin
    eInputStream
    at javax.mail.Session.loadProvidersFromStream(Session.java:897)
    at javax.mail.Session.access$000(Session.java:151)
    at javax.mail.Session$1.load(Session.java:848)
    at javax.mail.Session.loadFile(Session.java:1002)
    at javax.mail.Session.loadProviders(Session.java:857)
    at javax.mail.Session.<init>(Session.java:187)
    at javax.mail.Session.getInstance(Session.java:226)
    at TestEmail.main(TestEmail.java:26)

    do you know what we need to run a sample mail application ???
    i have mail.jar, activation.jar and offcource jdk..
    as you can see from exception...it's compiling well...
    yes..there is a possibility of some missing classes...but i have downloaded three times these jar files(mail.jar and activation.jar)...
    and that's why i posted this Q's here.....
    Message was edited by:
    Michel0301

  • Message Format parse error

    When I am running the following I get the error Message Format Parse Error at java.text.messageformat.parse(unknown source)
    Any ideas why this is please
    public EventTable()throws IOException, ParseException
              super("EventTable");
              FileReader file = new FileReader("c:\\projects\\FirstSupport\\logfile.txt");
              BufferedReader inputfile = new BufferedReader (file);
              Object[] columnNames = {"Event No",
    "Time Elapsed",
    "Event String",
    "Parameter"};
              ArrayList values = new ArrayList();
              while ((Line = inputfile.readLine())!=null)
                   System.out.println(Line);
                   MessageFormat mf = new MessageFormat("Event No:{0,number} Time Elapsed: {1,number} Event String:{2} Parameter:{3,number}");
                             Object[]val = mf.parse(Line);
                   System.out.println(val);
                   values.add(val);
              System.out.println(values.size());
              Object[][] data = (Object[][])values.toArray(new Object[values.size()][]);
              JTable table = new JTable(data,columnNames);

    Could tabs or something make this error happen
    This is the first line of the text file. Copied and Pasted
    Event No: 1     Time Elapsed: 1.0     Event String: Battery voltage           Parameter: 738

  • Error while sending mail when using Java Mail API

    Hi Experts,
    I am trying to execute a webdynpro application which uses the Java Mail API to send emails. The exception that I get on executing the application is :
    Sending failed;  nested exception is: javax.mail.SendFailedException: Invalid Addresses;  nested exception is: javax.mail.SendFailedException: 550 5.7.1 Unable to relay for [email protected]
    Can anybody please help me sort out the issue.
    Regards
    Abdullah

    Hi,
    Usually one get this error if the SMTP server is configured not to relay mails (a security measure) or the SMTP server need the mail to be sent from a trusted IP or with proper authentication. Some SMTP servers are configured to block junk mails.
    Pls check with your  mail server administrator.
    Regards

  • Java Mail Madness - Doesn't Work but shows no errors ?

    What's up folks. I am trying to implement the java mail library. Unfortunately, I have a problem and I don't know how to track it down. Here is the code that I run in the Netbeans IDE.
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class SendApp {
    public static void send(String smtpHost, int smtpPort,
    String from, String to,
    String subject, String content)
    throws AddressException, MessagingException {
    // Create a mail session
    java.util.Properties props = new java.util.Properties();
    props.put("mail.smtp.host", smtpHost);
    props.put("mail.smtp.port", ""+smtpPort);
    Session session = Session.getDefaultInstance(props, null);
    // Construct the message
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(from));
    msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
    msg.setSubject(subject);
    msg.setText(content);
    // Send the message
    Transport.send(msg);
    public static void main(String[] args) throws Exception {
    // Send a test message
    send("kernel", 25, "jd@kernel", "[email protected]",
    "re: dinner", "How about at 7?");
    Where kernel is the domain name of my computer. However, when I check my email at [email protected] (fake address) I don't see anything and the program exits with success. I don't know if this is cause of a problem with my Netbeans, my code, or my postfix smtp system. Any help is greatly appreciated !
    SIncerely,
    Justin Dallas

    Hi,
    Did you checked the log for any errors
    catch (Exception e) {
         System.out.println("Exception while sending mail" + e.getMessage());
         e.printStackTrace();
    Or else add the following line in your exception handler and check whether their is any error or not.
    wdComponentAPI.getMessageManager().reportException(e.getMessage());
    Regards
    Ayyapparaj

  • Error of using Java Mail in Web Start

    Hi,
    I got a problem when using Java Mail to send email. My apps is a stand alone and no problem when it was deployed normally. When I used the Web Start to deploy it, the following error was caught when I tried to send email:
    javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; boundary="----=_Part_0_2824645.1032281188963"
         at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:851)
         at javax.activation.DataHandler.writeTo(DataHandler.java:305)
         at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1089)
         at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1527)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:321)
         at javax.mail.Transport.send0(Transport.java:164)
         at javax.mail.Transport.send(Transport.java:81)
         at com.mailcom.client.util.EMail.sendMail(EMail.java:180)
    Here is the source code:
    public class EMail {
    public static void sendMail(String host,
    String sender,
    String recipient,
    String subject,
    String content,
    Vector fileNames) throws MessagingException {
    Properties props = new Properties();
    props.put("mail.smtp.host",host);
    Session session = Session.getDefaultInstance(props,null);
    session.setDebug(true);
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(sender));
    msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipient,false));
    msg.setSubject(subject);
    Multipart mp = new MimeMultipart();
         // create and fill the first message part
         MimeBodyPart mbp1 = new MimeBodyPart();
         mbp1.setText(content);
         mp.addBodyPart(mbp1);
    // attach the file to the message
    if(fileNames != null && fileNames.size() != 0) {
    FileDataSource fds = null;
    for(int i = 0; i < fileNames.size(); i++ ) {
    String currentFileName = (String)fileNames.elementAt(i);
         fds = new FileDataSource(currentFileName);
         // create the second message part
         MimeBodyPart mbp2 = new MimeBodyPart();
         mbp2.setDataHandler(new DataHandler(fds));
         mbp2.setFileName(fds.getName());
         // create the Multipart and its parts to it
         mp.addBodyPart(mbp2);
         // add the Multipart to the message
         msg.setContent(mp);
    msg.setHeader("X-Mailer",MAILER);
         // set the Date: header
         msg.setSentDate(new Date());
         // send the message
    line 180     Transport.send(msg);

    Yes. All the third party jar files and our application jar are put on the server side. Here is the JNLP file:
    <?xml version="1.0" encoding="utf-8"?>
    <!-- JNLP File for software-->
    <jnlp spec="1.0+" codebase="http://www.software.com/apps" href="client.JNLP">
    <information>
    <title>client application</title>
    <vendor> * </vendor>
    <homepage href="docs/help.html"/>
    <description>Client</description>
    <description kind="short">A tool</description>
    <icon href="images/logo.jpg"/>
    <offline-allowed/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.3"/>
    <jar href="lib/client.jar"/>
    <jar href="lib/mail.jar"/>
    <jar href="lib/smtp.jar"/>
    <jar href="lib/activation.jar"/>
    </resources>
    <application-desc main-class="com.software.client.MainFrame">
         <argument>2226</argument>
         <argument>www.software.com</argument>
         <argument>5351</argument>
    </application>
    </jnlp>

  • Fatal error in Java Parser V2 :Status??

    We still have a problem with entity references
    in V2 of the JAVA XML parser (see Rolf van Deuresen 24-11).
    It is a very urgent problem for us. We think that the XML-team
    is working on it. Can you inform me abouth the status with the
    (bug??)-fix. If you need more information on the problem, please
    ask.
    Greetings,
    Erik van den Berg.
    null

    Attachments: "1|type=text/plain|desc=SAXSample output|17142|file=output.txt|"
    Oracle XML Team wrote:
    : Erik van den Berg (guest) wrote:
    : : Oracle XML Team wrote:
    : : : Erik van den Berg (guest) wrote:
    : : : : We still have a problem with entity references
    : : : : in V2 of the JAVA XML parser (see Rolf van Deuresen 24-
    11).
    : : : : It is a very urgent problem for us. We think that the
    XML-
    : : team
    : : : : is working on it. Can you inform me abouth the status
    with
    : : the
    : : : : (bug??)-fix. If you need more information on the
    problem,
    : : : please
    : : : : ask.
    : : : : Greetings,
    : : : : Erik van den Berg.
    : : : Have you downloaded the latest version 2.0.2.5 that was
    made
    : : : available this week?
    : : : Oracle XML Team
    : : : http://technet.oracle.com
    : : : Oracle Technology Network
    : : I have downloaded the new version 2.0.2.5 of the Java
    parser,
    : : and it stil doesn't work. Please refer to the original
    message
    : : from Rolf van Deursen (24th november 1999) for the details.
    : : Maybe it will help you if I mail you a XML file that fails.
    If
    : : so, please give me your email account.
    : : Greetings,
    : : Erik van den Berg.
    : You can attach files to messages in the forum here.
    : Oracle XML Team
    : http://technet.oracle.com
    : Oracle Technology Network
    Here's the XML that raises the Fatal error. The following
    information is generated by the parser:
    Fatal Error of Java SAX parser v2.0.2.5:
    XML-0121: (Fatal Error) End tag does not match start
    tag 'WOONPLAATS'. at line 517, column 4151 of XML document.
    I attached the output of the SAXSample class, so you can trace
    the line and column where the error occurs. Also attached is the
    XML file (4Mb).
    An other error that occurs with this XML is the following
    situation:
    <VOLGNR_FILM> 001</VOLGNR_FILM>
    this piece of XML is parsed with the following events:
    StartElement:VOLGNR_FILM
    Characters:NR_
    Characters:001
    EndElement:VOLGNR_FILM
    So the spaces are replace with a part of the start tag! This is
    also only with large files. I tested this piece of XML in a
    seperate file. Then it was parsed correctly.
    Kind regards,
    Erik.
    null

  • Java Mail error rfc822

              Hi,
              Getting following error message when the servlet try to send a
              mail.( Servlet uses Java Mail ApI).
              javax.mail.NoSuchProviderException: No provider for Address type:
              rfc822
              at java.lang.Throwable.fillInStackTrace(Native Method)
              at java.lang.Throwable.fillInStackTrace(Compiled Code)
              at java.lang.Throwable.<init>(Compiled Code)
              at java.lang.Exception.<init>(Compiled Code)
              at javax.mail.MessagingException.<init>(MessagingException.java:42)
              at javax.mail.NoSuchProviderException.<init>(NoSuchProviderException.java:34)
              at javax.mail.Session.getTransport(Session.java:475)
              at javax.mail.Transport.send0(Compiled Code)
              at javax.mail.Transport.send(Transport.java:80)
              at com.arsin.vcommerce.b2beprocurement.SendMail.sendMail(Compiled
              Code)
              at com.arsin.vcommerce.b2beprocurement.StatusServlet.doPost(StatusServlet.java:39)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
              at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:105)
              at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:742)
              at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:686)
              at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:247)
              at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:361)
              at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
              at weblogic.kernel.ExecuteThread.run(Compiled Code)
              Any help.
              Thanks
              Ram.
              

              If Weblogic 6, see if you can get help from
              http://edocs.bea.com/wls/docs60/programming/topics.html
              "ram chinnasamy" <[email protected]> wrote:
              >
              >Hi,
              > Getting following error message when the servlet try
              >to send a
              >mail.( Servlet uses Java Mail ApI).
              >
              >javax.mail.NoSuchProviderException: No provider for Address
              >type:
              >rfc822
              > at java.lang.Throwable.fillInStackTrace(Native
              >Method)
              > at java.lang.Throwable.fillInStackTrace(Compiled
              >Code)
              > at java.lang.Throwable.<init>(Compiled Code)
              > at java.lang.Exception.<init>(Compiled Code)
              > at javax.mail.MessagingException.<init>(MessagingException.java:42)
              > at javax.mail.NoSuchProviderException.<init>(NoSuchProviderException.java:34)
              > at javax.mail.Session.getTransport(Session.java:475)
              > at javax.mail.Transport.send0(Compiled Code)
              > at javax.mail.Transport.send(Transport.java:80)
              > at com.arsin.vcommerce.b2beprocurement.SendMail.sendMail(Compiled
              >Code)
              > at com.arsin.vcommerce.b2beprocurement.StatusServlet.doPost(StatusServlet.java:39)
              > at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
              > at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
              > at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:105)
              > at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:742)
              > at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:686)
              > at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:247)
              > at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:361)
              > at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
              > at weblogic.kernel.ExecuteThread.run(Compiled
              >Code)
              >
              >
              >Any help.
              >Thanks
              >Ram.
              >
              >
              

  • Java mail(fetch default SMTP server address)

    I am writting a code to send an email using Java Mail API.
    I have manged what I wanted(send a mail with an attachment)
    But in my code I have hard coded the SMTP server address,that is what I dont want to do .Is there anything in java which can fetch the default SMTP server address ?

    Let me send the code itself to make it clear
    Here the host is hard coded to10.1.1.5
    I dont want that ,rather I would like my code itself to fetch the host
    package javamail;
    import java.util.*;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class SendMailUsage {
    public static void main(String[] args) {
    // SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!
    String to = "[email protected]";
    String from = "[email protected]";
    // SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
    String host = "10.1.1.5";
    // Create properties for the Session
    Properties props = new Properties();
    // If using static Transport.send(),
    // need to specify the mail server here
    props.put("mail.smtp.host", host);
    // To see what is going on behind the scene
    props.put("mail.debug", "true");
    // Get a session
    Session session = Session.getInstance(props);
    try {
    // Get a Transport object to send e-mail
    Transport bus = session.getTransport("smtp");
    // Connect only once here
    // Transport.send() disconnects after each send
    // Usually, no username and password is required for SMTP
    bus.connect();
    //bus.connect("smtpserver.yourisp.net", "username", "password");
    // Instantiate a message
    Message msg = new MimeMessage(session);
    // Set message attributes
    msg.setFrom(new InternetAddress(from));
    InternetAddress[] address = {new InternetAddress(to)};
    msg.setRecipients(Message.RecipientType.TO, address);
    // Parse a comma-separated list of email addresses. Be strict.
    msg.setRecipients(Message.RecipientType.CC,
    InternetAddress.parse(to, true));
    // Parse comma/space-separated list. Cut some slack.
    msg.setRecipients(Message.RecipientType.BCC,
    InternetAddress.parse(to, false));
    msg.setSubject("Test E-Mail through Java");
    msg.setSentDate(new Date());
    // Set message content and send
    setTextContent(msg);
    msg.saveChanges();
    bus.sendMessage(msg, address);
    setMultipartContent(msg);
    msg.saveChanges();
    bus.sendMessage(msg, address);
    setFileAsAttachment(msg, "D:/ketan.txt");
    msg.saveChanges();
    bus.sendMessage(msg, address);
    setHTMLContent(msg);
    msg.saveChanges();
    bus.sendMessage(msg, address);
    bus.close();
    catch (MessagingException mex) {
    // Prints all nested (chained) exceptions as well
    mex.printStackTrace();
    // How to access nested exceptions
    while (mex.getNextException() != null) {
    // Get next exception in chain
    Exception ex = mex.getNextException();
    ex.printStackTrace();
    if (!(ex instanceof MessagingException)) break;
    else mex = (MessagingException)ex;
    // A simple, single-part text/plain e-mail.
    public static void setTextContent(Message msg) throws MessagingException {
    // Set message content
    String mytxt = "This is a test of sending a " +
    "plain text e-mail through Java.\n" +
    "Here is line 2.";
    msg.setText(mytxt);
    // Alternate form
    msg.setContent(mytxt, "text/plain");
    // A simple multipart/mixed e-mail. Both body parts are text/plain.
    public static void setMultipartContent(Message msg) throws MessagingException {
    // Create and fill first part
    MimeBodyPart p1 = new MimeBodyPart();
    p1.setText("This is part one of a test multipart e-mail.");
    // Create and fill second part
    MimeBodyPart p2 = new MimeBodyPart();
    // Here is how to set a charset on textual content
    p2.setText("This is the second part", "us-ascii");
    // Create the Multipart. Add BodyParts to it.
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(p1);
    mp.addBodyPart(p2);
    // Set Multipart as the message's content
    msg.setContent(mp);
    // Set a file as an attachment. Uses JAF FileDataSource.
    public static void setFileAsAttachment(Message msg, String filename)
    throws MessagingException {
    // Create and fill first part
    MimeBodyPart p1 = new MimeBodyPart();
    p1.setText("This is part one of a test multipart e-mail." +
    "The second part is file as an attachment");
    // Create second part
    MimeBodyPart p2 = new MimeBodyPart();
    // Put a file in the second part
    FileDataSource fds = new FileDataSource(filename);
    p2.setDataHandler(new DataHandler(fds));
    p2.setFileName(fds.getName());
    // Create the Multipart. Add BodyParts to it.
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(p1);
    mp.addBodyPart(p2);
    // Set Multipart as the message's content
    msg.setContent(mp);
    // Set a single part html content.
    // Sending data of any type is similar.
    public static void setHTMLContent(Message msg) throws MessagingException {
    String html = "<html><head><title>" +
    msg.getSubject() +
    "</title></head><body><h1>" +
    msg.getSubject() +
    "</h1><p>This is a test of sending an HTML e-mail" +
    " through Java.</body></html>";
    // HTMLDataSource is an inner class
    msg.setDataHandler(new DataHandler(new HTMLDataSource(html)));
    * Inner class to act as a JAF datasource to send HTML e-mail content
    static class HTMLDataSource implements DataSource {
    private String html;
    public HTMLDataSource(String htmlString) {
    html = htmlString;
    // Return html string in an InputStream.
    // A new stream must be returned each time.
    public InputStream getInputStream() throws IOException {
    if (html == null) throw new IOException("Null HTML");
    return new ByteArrayInputStream(html.getBytes());
    public OutputStream getOutputStream() throws IOException {
    throw new IOException("This DataHandler cannot write HTML");
    public String getContentType() {
    return "text/html";
    public String getName() {
    return "JAF text/html dataSource to send e-mail only";
    } //End of class

  • Parse errors while creating a Web service from Java class!

    Can anybody tell me please, is it possible to create a Web Service from java class where the input from user is required ?
    I have the following program, which is successfully compiled, but when I'm trying to make a web service in JDeveloper, the following error occurs:
    "Validation failed.
    The implementation class primePackage.isPrime ofport type MyWebService contains parse errors."
    import java.io.*;
    import java.util.*;
    class isPrime
    public static void main (String args[])
    Scanner reader = new Scanner(System.in);
    int n;
    System.out.println ("Enter a number you want to know is it prime or not");
    n=reader.nextInt();
    if (isPrime(n))
    System.out.println ("True");
    else
    System.out.println ("False");
    static boolean isPrime (int n)
    int i=2;
    while (i<=n-1)
    if (n%i==0)
    return false;
    i++;
    return true;
    }

    Hi,
    Can anybody tell me please, is it possible to create
    a Web Service from java class where the input from
    user is required ?Yes, the parameters of your method will be mapped in WSDL.
    But i've some considerations about your code.
    I suggest you change the name of isPrime do Prime, its a good code convention to put the name of class starting with Upper case. and isn't good the name of class equals to name of method.
    I suggest you to change the "static boolean isPrime (int n)" to "public boolean isPrime(int n)" to publish a method as a WebService method it's must be public and not static. After this change try to generate your Web Service.
    Regards.

  • Exception in java mail API when parsing email

    I am receiving the following exception when receiving some emails that contain attachments with java mail (irrelevant part of stack trace omitted):
    javax.mail.internet.ParseException: Expected ';', got ","
         at javax.mail.internet.ParameterList.<init>(ParameterList.java:289)
         at javax.mail.internet.ContentDisposition.<init>(ContentDisposition.java:100)
         at javax.mail.internet.MimeBodyPart.getFileName(MimeBodyPart.java:1136)
    The header of a message the causes the problem is:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) ------------ Message headers ------------
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Received: from mail2.uscourts.gov ([10.170.250.2])
    by ushub06.uscmail.dcn (Lotus Domino Release 8.5.2FP1 HF3)
    with SMTP id 2011042514392620-733724 ;
    Mon, 25 Apr 2011 14:39:26 -0400
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Received: from (unknown [63.174.91.123]) by avms-usc-04c-02vh.ibmta.uscourts.gov with smtp
         id 191c_067d_57fad3b8_6f6b_11e0_8de9_00265519f638;
         Mon, 25 Apr 2011 18:39:24 +0000
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) X-WSS-ID: 0LK815L-05-67D-02
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) X-M-MSG:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Received: from kcmexclaim.Our-Firm.com (unknown [10.42.5.222])by mail4.stinson.com (Axway MailGate 3.8.1) with ESMTP id 27239A12C1D;     Mon, 25 Apr 2011 13:39:20 -0500 (CDT)
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Received: from KCME2K7-HUB02.Our-Firm.com ([10.42.5.19]) by kcmexclaim.Our-Firm.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 25 Apr 2011 13:39:23 -0500
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Received: from FIRMCMS01.Our-Firm.com ([fe80::81d0:dd2b:9983:1126]) by KCME2K7-HUB02.Our-Firm.com ([::1]) with mapi; Mon, 25 Apr 2011 13:39:22 -0500
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) From:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) To:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Cc:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Disposition-Notification-To:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Date: Mon, 25 Apr 2011 13:39:21 -0500
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Subject: Order Regarding Application To Employ SMH as Debtor's Counsel
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Thread-Topic: Order Regarding Application To Employ SMH as Debtor's Counsel
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Thread-Index: AcwDb/bpRQlxt/eTQC6BA7G10hdWJQAB99vQ
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Message-ID: <[email protected]>
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Accept-Language: en-US
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) X-MS-Has-Attach: yes
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) X-MS-TNEF-Correlator:
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) acceptlanguage: en-US
    2011-04-25 14:39:48,060 INFO [STDOUT] (WorkManager(2)-97) Importance: Normal
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) Priority: normal
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4841
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) MIME-Version: 1.0
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) Return-Path:
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) X-OriginalArrivalTime: 25 Apr 2011 18:39:23.0526 (UTC) FILETIME=[18E10260:01CC0378]
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) X-MIMETrack: Itemize by SMTP Server on USHUB06/H/US/USCOURTS(Release 8.5.2FP1 HF3|December 21, 2010) at 04/25/2011 02:39:26 PM, Serialize by POP3 Server(Release 8.0.2FP3 HF28|December 28, 2009) at 04/25/2011 02:39:47 PM
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) Content-Transfer-Encoding: 7bit
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) Content-Class: urn:content-classes:message 2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) Content-Type: multipart/mixed;     boundary="_004_52835C1F7A6C8D4F989C433DCC611CA06F252D6682FIRMCMS01OurF_"
    2011-04-25 14:39:48,061 INFO [STDOUT] (WorkManager(2)-97) Content-Language: en-US
    the client/OS combination of the mail sender is Windows XP service Pack 3/Outlook 2007 , Java Mail version 1.4.3
    Any help would be appreciated
    Edited by: 854778 on Apr 26, 2011 8:28 AM

    The exception is occurring when parsing the Content-Disposition header.
    I don't see that header in the list of headers you provided.
    Can you save the entire message to a text file using
    msg.writeTo(new FileOutputStream("msg.txt"));
    Then look for the Content-Disposition header in msg.txt. Most likely you'll
    find that it is incorrectly formatted - as the exception says, there's a comma
    in a place that a semicolon is expected.

  • Getting Error in java mapping: Parsing empty source. Root element expected!

    Hi Experts,
       I am using java mapping for schema validation of input message. I have followed all the standard procedures and implemented the java class in the interface mapping.
    My interface mapping is like this:
    OrderData --->Java Class ---SchemaValidate
                         Mesg Map ---OrderData_to_BAP --->BAPI Msg
    So first I want to validate the schema of the input message. If the input message is invalid then XI should throw an exception. Then I use the actual message mapping to map the input order data to the BAPI input parameters.
    In the java code I am using xerces parser.
    The java code works fine when I run it as a standalone application.
    The interface mapping also works fine if I don't include the java mapping. Ofcourse schema validation does not happen.
    But when I test the interface mapping by including the java mapping then I am getting the error:
    Call method execute of the application Java mapping SchemaValidate
    Java mapping SchemaValidate completed. (execute() of SchemaValidate
    com.sap.aii.utilxi.misc.api.BaseRuntimeException: Parsing an empty source. Root element expected!
    What am I doing wrong? Why it is not getting the root element?
    My Java code is as follows:
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import java.io.*;
    import java.util.Map;
    import javax.xml.parsers.*;
    import org.xml.sax.helpers.*;
    import org.xml.sax.*;
    import org.apache.xerces.jaxp.*;
    Sample mapper for SAP-XI
    @author Gopal
    public class SchemaValidate implements StreamTransformation {
        //Constants when using XML Schema for SAX parsing.
         static final String JAXP_SCHEMA_LANGUAGE =
         "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
         static final String W3C_XML_SCHEMA =
         "http://www.w3.org/2001/XMLSchema";
         static final String JAXP_SCHEMA_SOURCE =
         "http://java.sun.com/xml/jaxp/properties/schemaSource";
    Injection of mapping parameters
    from integration engine
    @param map Map with configuration data
        public void setParameter(Map map) {
    Mapping implementation
    @param inputStream Input data from integration engine
    @param outputStream Output data to integration engine
        public void execute(InputStream inputStream,
                            OutputStream outputStream)
          throws StreamTransformationException {
            try {
                  // obtain an object of class javax.xml.parsers.SAXParser,
                  SAXParserFactory spf = SAXParserFactoryImpl.newInstance();
                  spf.setNamespaceAware(true);
                  spf.setValidating(true);
                  SAXParser sp = spf.newSAXParser();
                  // setup the schema file
                  sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                  sp.setProperty(JAXP_SCHEMA_SOURCE, new File("IOReqMsgSchema.xsd"));
                  //parse the input xml using the given schema
                  sp.parse(inputStream, new ParseErrorHandler());
            catch(SAXException se) {
              se.printStackTrace();
            catch ( Exception e ) {
              throw new StreamTransformationException( e.getMessage() );
    My input message is :
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:OrderCreate_request xmlns:ns0="mynamespace">
       <ORDER>HTEST1234567</ORDER>
       <ORDER_TYPE>z001</ORDER_TYPE>
       <ORDER_NAME>Test Order</ORDER_NAME>
       <CO_AREA>INTC</CO_AREA>
       <CCTR_POSTED>1234567890888888888</CCTR_POSTED>
       <CURRENCY>USD</CURRENCY>
       <PERSON_RESP>12345679</PERSON_RESP>
    </ns0:OrderCreate_request>
    Kindly help! please this is urgent!!!!!!
    Thanks
    Gopal
    Edited by: gopalkrishna baliga on Feb 28, 2008 9:34 AM

    Hi Stefan,
       I did the code changes to return output stream and the java code works perfectly in standalone mode in my PC.
       But when I use the same in the Java mapping with XI then It throws an error "Getting Error in java mapping: Parsing empty source. Root element expected!".
    My XI J2EE server has JDK1.4.3.11.
    Is there any limitation of using SAX parser in XI? If Yes, then which parser should be used for schema validation in XI?
    I have included the XSD file for schema validation along with class files in the .jar file. This jar file is then imported in XI repository. Is the XI engine not able to read the XSD file?
    Do I have to handle reading XSD file differently? Any suggession how?
    Is this parser error due to some security access?
    Kindly help me! I have been struggling with this problem since 2 weeks. I will be greatfull to you if you can help me.
    Thanks
    Gopal

Maybe you are looking for

  • IMessages sending to iPhone without data/wifi

    Hi all, When I text my friend with my iPhone it goes through and says "delivered" however it is sending through as iMessage. My friend however has no data plan. I thought it was when she had wifi but the times I texted, she didn't and it still went t

  • How do you get 206 to ring longer.

    Just bought 206 for my mother but it only rings a few times then goes to answer phone. She hasn't been able to answer one call yet because there's not enough time to get to it. I've looked in the call menu and there's no call divert option so can't d

  • Find Button of JUNavigationBar

    I am using a NavigationBar which is bound to a view and want to use the find mode to search entries in this view which is independent of any other views in my application module. Although the NavigationBar itself is working, it also switches all othe

  • Will bluetooth make reception better?

    I wonder if this is even possible, BUT... is it possible that my new bluetooth headset makes my iPhone reception better??? I have cruddy reception in my house. All over my house it's terrible. BUT, whenever I use the bluetooth in the house, I've noti

  • No form at all... possible?

    Is it possible to have no form open at all in runtime envoronment? The idea is to create an MDI with no such requirement that at-least one form has to be open all the time (similar to say MS word or excel).