Checking for mail..... giving SecurityException

Hi everybody,

I'm new to JavaMail API. So I'm trying to work with some sample apps from Sun JavaMail Tutorials. This is the appln I'm working on to read the mails.:

import java.io.*;

import java.util.Properties;

import javax.mail.*;

import javax.mail.internet.*;

public class GetMessageExample {

public static void main (String args[]) throws Exception {

String host = args[0];

String username = args[1];

String password = args[2];

Properties props = new Properties();

Session session = Session.getDefaultInstance(props, null);

Store store = session.getStore("pop3");

store.connect(host, username, password);

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

folder.open(Folder.READ_ONLY);

BufferedReader reader = new BufferedReader (

new InputStreamReader(System.in));

Message message[] = folder.getMessages();

for (int i=0, n=message.length; i<n; i++) {

System.out.println(i + ": " + message.getFrom()[0]

+ "\t" + message.getSubject());

System.out.println("Do you want to read message? [YES to read/QUIT to end]");

String line = reader.readLine();

if ("YES".equals(line)) {

System.out.println(message.getContent());

} else if ("QUIT".equals(line)) {

break;

}

}

folder.close(false);

store.close();

}

}

In command line, I gave mail server's IP address, username and password. But it's giving the error as follows:

Exception in thread "main" java.lang.SecurityException: class "com.sun.mail.util

.SharedByteArrayInputStream"'s signer information does not match signer informat

ion of other classes in the same package

at java.lang.ClassLoader.checkCerts(Unknown Source)

at java.lang.ClassLoader.preDefineClass(Unknown Source)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(Unknown Source)

at java.net.URLClassLoader.defineClass(Unknown Source)

at java.net.URLClassLoader.access$100(Unknown Source)

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClassInternal(Unknown Source)

at com.sun.mail.pop3.Protocol.multilineCommand(Protocol.java:284)

at com.sun.mail.pop3.Protocol.top(Protocol.java:179)

at com.sun.mail.pop3.POP3Message.loadHeaders(POP3Message.java:392)

at com.sun.mail.pop3.POP3Message.getHeader(POP3Message.java:217)

at javax.mail.internet.MimeMessage.getAddressHeader(MimeMessage.java:679

)

at javax.mail.internet.MimeMessage.getFrom(MimeMessage.java:340)

at GetMessageExample.main(GetMessageExample.java:39)

I can't understand why it's coming like this. I wrote one appln to send mail and it's working fine.

Pls give me ur valuable replies.

Thanks and regards,

Saritha

Message was edited by:

sari4hp>

[3304 byte] By [sari4hpa] at [2007-10-3 4:46:48]
# 1
Most likely you have more than one version of JavaMail available toyour application, e.g., in your CLASSPATH. Also check your "jre/lib/ext"directory for copies of mail.jar.
bshannona at 2007-7-14 22:51:12 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...