Acess denied when connecting to Oracle through Sun One App Server 7
Hello,
I磛e 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: java.security.AccessControlException: access denied (java.lang.Runtim
ePermission getClassLoader)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:269)
at java.security.AccessController.checkPermission(AccessController.java:
401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1104)
at oracle.jdbc.driver.OracleDriver.<clinit>(OracleDriver.java:315)
... 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:@10.11.1.4:1521:ora9i";
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
e.printStackTrace();
}catch (IllegalAccessException e){
// TODO Auto-generated catch block
e.printStackTrace();
}catch (ClassNotFoundException e){
// TODO Auto-generated catch block
e.printStackTrace();
}
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磘 declare a Driver like I'm trying to do?

