access denied (java.util.P


EJB programming & troubleshooting: access denied (java.util.P

  1. Hello,

    I've built a very simple class file that pushed an e-mail out to a desired recepient.

    Here is the class file:

    package myBeans.src;

    import java.beans.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;

    public class mailBean extends Object implements Serializable {
        public static final String PROP_SAMPLE_PROPERTY = "sampleProperty";
        private String sampleProperty;
        private PropertyChangeSupport propertySupport;
        private String host;
        private String to;
        private String from;
        private String subject;
        private String message;
        private Properties props;
        private Session session;
        private MimeMessage mimeMess;
        public mailBean() {
            propertySupport = new PropertyChangeSupport(this);
            //Get system properties
              props = System.getProperties();
            //Get session
              session = Session.getDefaultInstance(props, null);
        public String getMessageHost() {
            return host;
        public String getMessageTo() {
            return to;
        public String getMessageFrom() {
            return from;
        public String getMessageMessage() {
            return message;
        public String getMessageSubject() {
            return subject;
        public String getSampleProperty() {
            return sampleProperty;
        public void setMessageHost(String h) {
   = h;
            props.put("", h);
            // Define message
            mimeMess = new MimeMessage(session);
        public void setMessageTo(String t) {
   = t;
            try {
              mimeMess.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
            } catch (AddressException e) {
            } catch (MessagingException e) {
        public void setMessageFrom(String f) {
            this.from = f;
            try {
             mimeMess.setFrom(new InternetAddress(from));
            } catch (AddressException e) {
            } catch (MessagingException e) {
        public void setMessageMessage(String m) {
            this.message = m;
              mimeMess.setContent(message, "text/html");
            } catch (MessagingException e) {
        public void setMessageSubject(String s) {
            subject = s;
            try {
            } catch (MessagingException e) {
        public void sendMessage() {
            try {
            } catch (MessagingException e) {
        public void setSampleProperty(String value) {
            String oldValue = sampleProperty;
            sampleProperty = value;
            propertySupport.firePropertyChange(PROP_SAMPLE_PROPERTY, oldValue, sampleProperty);
        public void addPropertyChangeListener(PropertyChangeListener listener) {
        public void removePropertyChangeListener(PropertyChangeListener listener) {
        public static void main(String args[]) {
            mailBean mb = new mailBean();
            mb.setMessageHost("<smtp server>");
            mb.setMessageFrom("<from e-mail address>");
            mb.setMessageTo("<to e-mail address>");
            mb.setMessageSubject("A message test.");
            mb.setMessageMessage("<H1>Test Message</H1> This is a test message.");
            System.out.println("Message sent...");

    I comment out the "main" method, before placing it in my WEB-INF/Classes directory. Now, after compiling this file, I'm able to run it in DOS and receive the test e-mail created in the main method.

    However, once I comment out the main method and simply "instantiate" the bean from my JSP, I get that security error in the subject line.

    The only thing I do is instantiate it. Here's the JSP file:

    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>

    <jsp:useBean id="mailBean" class="myBeans.src.mailBean" scope="page" >

    <head><title>JSP Page</title></head>
    <h1>Contact Page</h1>

    I verified that the properties on my class file is read/write within the myBeans/src directory under WEB-INF/classes

    What can be causing this error? Did I forget something in my class file?
  2. Anyone out there that might know about this " access denied (java.util.PropertyPermission * read,write)" error?
  3. FYI to anyone out there who may be experiencing this on a server that they are not "hosting/managin" themselves, I discovered that my Web hosting company only supports Servlets and JSP.

    Given this, I took out references to "PropertyChangeSupport" and "java.beans.*", and my code (servlet) worked, no longer giving me that security error.