tags:

views:

14

answers:

0

Good afternoon, ladies and gentlemen,

I have biult a web application using Hibernate for java. The application works fine on my local machine without SecurityManager, but when it is deployed on the remote server, the following exception is thrown:

Sep 23, 2010 3:07:12 PM org.apache.catalina.core.StandardWrapperValve invoke INFO: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323) at java.security.AccessController.checkPermission(AccessController.java:546) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1512) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:114) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at java.sql.DriverManager.getCallerClass(DriverManager.java:477) at java.sql.DriverManager.getConnection(DriverManager.java:576) at java.sql.DriverManager.getConnection(DriverManager.java:185) at org.apache.jsp.dbtester_jsp._jspService(dbtester_jsp.java:84) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) ....................and so on.....................

the remote server runs SecurityManager which sims to dislike access to sun.jdbc.odbc package. Sun does not recommend direct use of any classes in the "sun." namespace, therefore system administrators state that many users of the same hosting are also using Hibernate with MySQL and do not requere such a permission.

I am using custom connection provider which does as little as:

//during initialisation
Class.forName(driver);

//later on connection request
Connection conn = DriverManager.getConnection(connURL, username, password);
conn.setAutoCommit(true);
return conn;

I am not implementing/using connection pooling as it makes no sense due to short configured connection timeout on the server. The same situation also occured with the default hibernate pooling mechanism, and with c3p0.

my hibernate.cfg.xml:

<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/database_name</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">password</property>

<property name="hibernate.connection.provider_class">snowhouse.UnpooledConnectionProvider</property>


<mapping resource="snowhouse/Staff.hbm.xml"/>
<mapping resource........
</session-factory>
</hibernate-configuration>

am I missing any important configuration, or what else could trigger such exception? is it OK that SessionFactory is not bound to JNDI?