Hello,
I am trying to use Hibernate 2.1.4 in a standalone app. I am creating the session from loading in a class.
Code:
private HibernateUtil() {
System.out.println("HibernateUtil Constructor");
try {
cfg = new Configuration();
cfg.setProperty(Environment.DIALECT, dbType);
cfg.setProperty(Environment.DRIVER, jdbc_driver);
cfg.setProperty(Environment.URL, url);
cfg.setProperty(Environment.USER, userName);
cfg.setProperty(Environment.PASS, password);
//cfg.setProperty(Environment.TRANSACTION_STRATEGY, transType);
cfg.setProperty(Environment.USE_REFLECTION_OPTIMIZER, "true");
//cfg.setProperty(Environment.CACHE_PROVIDER, "net.sf.ehcache.hibernate.Provider");
//cfg.setProperty(Environment.USE_GET_GENERATED_KEYS, "false");
cfg.addDirectory(new File("/sh/hibernate/"));
sf = cfg.buildSessionFactory();
System.out.println("sf = " + sf.toString());
}
catch(MappingException me){
System.out.println("mapping exception caught: " + me);
}
catch (Exception ex) {
System.out.println("HibernateUtil caught: " + ex);
}
}
and i receive the following error when i try to run the app
Code:
15:57:45,152 INFO Binder:229 - Mapping class: sh.hibernate.ShKey -> SH_KEY
15:57:45,261 INFO Configuration:613 - processing one-to-many association mappings
15:57:45,261 INFO Configuration:622 - processing one-to-one association property references
15:57:45,261 INFO Configuration:647 - processing foreign key constraints
15:57:45,277 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.Oracle9Dialect
15:57:45,293 INFO SettingsFactory:62 - Use outer join fetching: true
15:57:45,293 INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
15:57:45,293 INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
15:57:45,308 INFO DriverManagerConnectionProvider:77 - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@localhost:1521:D036
15:57:45,308 INFO DriverManagerConnectionProvider:78 - connection properties: {user=foo, password=bar}
15:57:45,324 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
15:57:46,168 INFO SettingsFactory:102 - Use scrollable result sets: true
15:57:46,183 INFO SettingsFactory:105 - Use JDBC3 getGeneratedKeys(): false
15:57:46,183 INFO SettingsFactory:108 - Optimize cache for minimal puts: false
15:57:46,183 INFO SettingsFactory:117 - Query language substitutions: {}
15:57:46,183 INFO SettingsFactory:128 - cache provider: net.sf.ehcache.hibernate.Provider
15:57:46,199 INFO Configuration:1093 - instantiating and configuring caches
java.lang.IllegalAccessError
at net.sf.cglib.core.ClassEmitter.setTarget(ClassEmitter.java:85)
at net.sf.cglib.core.ClassEmitter.<init>(ClassEmitter.java:77)
at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:197)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:63)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:192)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:177)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:149)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:142)
at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:235)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:768)
at sh.util.HibernateUtil.<init>(HibernateUtil.java:72)
at sh.util.HibernateUtil.<clinit>(HibernateUtil.java:31)
I haven't tried using Hibernate in a stand-alone app before. Why isn't this loading? What is trying to Illegally access something?
---Jason