Hi,

I encountered a problem retrieving mail from James. I have pasted inline
some sample code to help reproduce the problem. I am also pasting inline
the logs from netfile.log in the James/logs directory. It is quite
likely that this problem may have already been fixed.

Here is the problem. I think James (1.2) is unable to deal with deletion
of mail messages over successive sessions. Logs in netfile.log indicate
that there is a problem with a file not being found
(FileNotFoundException). To reproduce the problem, try repeatedly
running the following program against a James server. The first argument
is the mailhost, the second is the user name and the third is a
password.

// Begin program
============
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;

public class JamesTest {

    private String mailHost;
    private String user;
    private String password;
    private Properties prop = new Properties();

    private static final String body = "Test message number: ";

    private int iter;

    public JamesTest(String host, String user, String password) {
 this.mailHost = host;
 this.user = user;
 this.password = password;
 iter = 0;
 prop.put("java.smtp.host", mailHost);
    }

    void sendMail() {
 try {
     Session session = Session.getDefaultInstance(prop, null);
     // Transport transport = session.getTransport("smtp");
     MimeMessage msg = new MimeMessage(session);
     msg.setFrom(new InternetAddress("prasanna@localhost"));
     msg.addRecipient(Message.RecipientType.TO, new
InternetAddress("prasanna@localhost"));
     msg.setContent(body + ++iter, "text/plain");
     Transport.send(msg);
     // transport.close();
     System.out.println("Sent message : " + msg.getContent() +
          " from: " + msg.getFrom()[0] + " To: " +
          msg.getAllRecipients()[0]);
 } catch (Throwable e) {
     e.printStackTrace();
     System.exit(0);
 }
    }

    void receiveMail(boolean delete) {
 try {
     Session session = Session.getDefaultInstance(prop, null);
     Store store = session.getStore("pop3");
     store.connect(mailHost, user, password);

     Folder folder = store.getFolder("INBOX");

     if(folder == null || !folder.exists()) {
  System.out.println("This folder does not exist.");
  return;
     }

     folder.open(Folder.READ_WRITE);

     Message[] msgs = folder.getMessages();
     System.out.println("Received " + msgs.length + " messages for " +
user);
     Message msg = msgs[0];
     System.out.println("From: " + msg.getFrom()[0].toString());
     System.out.println("To: " +
msg.getRecipients(Message.RecipientType.TO)[0]);
     System.out.println("-------------------");
     System.out.println(msg.getContent().toString());

     if(delete) {
  msg.setFlag(Flags.Flag.DELETED, true);
  System.out.println("Deleted.");
     }
     folder.close(true);
     store.close();
 } catch (MessagingException e) {
     e.printStackTrace();
 } catch (Throwable e) {
     e.printStackTrace();
 }
    }

    public static void main(String[] args) throws Throwable {
 JamesTest jt = new JamesTest(args[0], args[1], args[2]);
 jt.sendMail();
 jt.sendMail();

 jt.receiveMail(true);
 jt.receiveMail(true);
    }
}
// End Program
============

This will result in the following exceptions being thrown in the
netfile.log.

// Begin log
=========
2000.11.28 01:39:31 838 (INFO) from POP3: Connection from 127.0.0.1
(127.0.0.1)
2000.11.28 01:39:31 848 (INFO) from POP3: Command recieved: USER
prasanna
2000.11.28 01:39:31 848 (INFO) from POP3: Command recieved: PASS
Nsi/a3uzgEuP2
2000.11.28 01:39:31 889 (ERROR) from POP3: Exception during connection
from 127.0.0.1 (127.0.0.1) : Exception caught while retrieving an
object: java.io.FileNotFoundException:
../var/mail/localinbox/prasanna\4D61696C3937353433363633363837342D35.private.PersistentStore
(The system cannot find the file specified)
2000.11.28 01:39:31 899 (INFO) from POP3: Connection from 127.0.0.1
(127.0.0.1)
2000.11.28 01:39:31 899 (INFO) from POP3: Command recieved: USER
prasanna
2000.11.28 01:39:31 899 (INFO) from POP3: Command recieved: PASS
Nsi/a3uzgEuP2
2000.11.28 01:39:31 919 (ERROR) from POP3: Exception during connection
from 127.0.0.1 (127.0.0.1) : Exception caught while retrieving an
object: java.io.FileNotFoundException:
../var/mail/localinbox/prasanna\4D61696C3937353433363633363837342D35.private.PersistentStore
(The system cannot find the file specified)
// End log
=======

I am running James on a Windows 2000 professional machine.

I would really appreciate any pointers to fix this problem.

Thanks,
Prasanna.




------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives:  <http://www.mail-archive.com/james%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to