users@glassfish.java.net

javaMail: Access to default session denied ??

From: Felipe Gaścho <fgaucho_at_gmail.com>
Date: Fri, 25 Sep 2009 19:00:35 +0200

There is an exception when I try to access the JavaMail session:

java.lang.SecurityException: Access to default session denied
        at javax.mail.Session.getDefaultInstance(Session.java:321)


the code:

                                Properties sessionProps = javaMailSession.getProperties();
                                pipedUsername = sessionProps.getProperty("mail.user");
                                pipedPassword = sessionProps.getProperty("mail.smtp.password");

                                Session session = Session.getDefaultInstance(sessionProps,
                                                new Authenticator() {
                                                        public PasswordAuthentication getPasswordAuthentication() {
                                                                return new PasswordAuthentication(
                                                                                pipedUsername, pipedPassword);
                                                        }
                                                });


any idea ?