This discussion is archived
1 Reply Latest reply: May 16, 2006 5:28 AM by 807581 RSS

Acess denied when connecting to Oracle through Sun One App Server 7

807581 Newbie
Currently Being Moderated

I�ve deployed my application at Sun One Application Server 8 and I got the following error when I try to access a certain page:

Caused by: access denied (java.lang.Runtim
ePermission getClassLoader)
        at java.lang.SecurityManager.checkPermission(
        at java.lang.ClassLoader.getSystemClassLoader(
        at oracle.jdbc.driver.OracleDriver.<clinit>(
        ... 23 more
The error occurs in the following code:

     protected Connection getConnection() throws SQLException {
          Connection conn = null;
          String MM_oracle_DRIVER = "oracle.jdbc.driver.OracleDriver";
          String MM_oracle_USERNAME = "AGA";
          String MM_oracle_PASSWORD = "AGA";
          String MM_oracle_STRING = "jdbc:oracle:thin:@";
          try {
                              Driver Driverproductos = (Driver)Class.forName(MM_oracle_DRIVER).newInstance();
               conn = DriverManager.getConnection(MM_oracle_STRING,MM_oracle_USERNAME,MM_oracle_PASSWORD);

          catch (SQLException e) {
               throw e;
          } catch (InstantiationException e) {
               // TODO Auto-generated catch block
          } catch (IllegalAccessException e) {
               // TODO Auto-generated catch block
          } catch (ClassNotFoundException e) {
               // TODO Auto-generated catch block
          return conn;
When I try to access the same class above through a test class I made (with a main method), the error does not occur.

Actually the former code used:
InitialContext ic = new InitialContext();
               //     dataSource = (DataSource) ic.lookup("java:comp/env/jdbc/StrutsDemoDS");
but I removed it because it was not finding the datasource.

I must use a datasource, using InitialContext.lookup? I can�t declare a Driver like I'm trying to do?