You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Lee <DL...@irf.com> on 2004/11/09 07:09:33 UTC

How to fix the security error like this for tomcat5.5.4 -security

when tc security turned on then errors, if no security, it works fine, tried everything, still has errors
 
Thanks for anyone who can help!!! greatly appreciated
 
David Lee
 
1. Errors:
 
access: access allowed (java.util.PropertyPermission line.separator read)
Nov 8, 2004 9:55:25 PM org.apache.naming.NamingContext lookup
WARNING: Unexpected exception resolving reference
java.security.AccessControlException: access denied (java.util.PropertyPermission javax.mail.Session.Factory read)
 at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
 at java.security.AccessController.checkPermission(AccessController.java:427)
 at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
 at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1285)
 at java.lang.System.getProperty(System.java:661)
 at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:117)
 at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:792)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:139)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:780)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
 at javaxml2.UpdateItemServlet.doPost(Unknown Source)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

2. catalina.policy:
 
grant codeBase "file:${catalina.home}/webapps/javaxml2/WEB-INF/classes/UpdateItemServlet.class" {
        permission java.net.SocketPermission "localhost:1521","connect,resolve";
   permission java.util.PropertyPermission "javax.mail.Session.Factory","read";
   permission java.net.SocketPermission "localhost:25","connect,resolve";
};
 
3. context.xml
 
<Resource name="mail/Session" auth="Container"
              type="javax.mail.Session" mail.smtp.host="localhost" />
              
    
    
    <Resource name="jdbc/EmployeeDB" auth="Container"
        type="javax.sql.DataSource" username="scott" password="tiger"
                    driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@localhost:1521:dev"
                maxActive="8" maxIdle="4"/>
 
4. web.xml
 
<resource-ref>
      <description>Resource reference to a factory for javax.mail.Session instances that may be used for sending electronic mail messages, preconfigured to connect to the appropriate SMTP server.
      </description>
      <res-ref-name>
        mail/Session
      </res-ref-name>
      <res-type>
        javax.mail.Session
      </res-type>
      <res-auth>
        Container
      </res-auth>
    </resource-ref>
<resource-ref>
      <description>
        Resource reference to a factory for java.sql.Connection
        instances that may be used for talking to a particular
        database that is configured in the server.xml file.
      </description>
      <res-ref-name>
        jdbc/EmployeeDB
      </res-ref-name>
      <res-type>
        javax.sql.DataSource
      </res-type>
      <res-auth>
        Container
      </res-auth>
    </resource-ref>