I am using the latest Annotations and EntityManager (Rel. March 29) with Hibernate v. 3.2.2.
I get a java.lang.IllegalAccessError when I use an AnnotatedConfiguration instead of a Configuration which uses hbm.xml files.
This is what I do:
Code:
SessionFactory factory = getByAnnotation();
Session ses = factory.openSession();
ses.close();
if (myLogger.isInfoEnabled()) {
myLogger.info("hibernate SessionFactory added to the Servlet context");
}
...
private SessionFactory getByAnnotation() throws Exception{
System.out.println("Status: Start Configuration");
AnnotationConfiguration config = new AnnotationConfiguration();
config.configure("hibernate.cfg.xml");
System.out.println("Status: Start Creation of SessionFactory");
SessionFactory sf = config.buildSessionFactory();
return sf;
}
This is the stacktrace:
Code:
new sessionFactory
Status: Start Configuration
13.04.2007 14:53:27 org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.0.GA
13.04.2007 14:53:35 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: hibernate.cfg.xml
13.04.2007 14:53:35 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: hibernate.cfg.xml
13.04.2007 14:53:35 org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
Status: Start Creation of SessionFactory
13.04.2007 14:53:50 org.igl.util.HibernateStart contextInitialized
SCHWERWIEGEND: org.igl.util.HibernateStart.contextInitialized(): error in starting the Hibernate SessionFactory due to: tried to access method org.hibernate.cfg.Mappings.<init>(Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/List;Ljava/util/List;Lorg/hibernate/cfg/NamingStrategy;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/List;Ljava/util/Map;Ljava/util/Map;)V from class org.hibernate.cfg.ExtendedMappings
java.lang.IllegalAccessError: tried to access method org.hibernate.cfg.Mappings.<init>(Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/List;Ljava/util/List;Lorg/hibernate/cfg/NamingStrategy;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/List;Ljava/util/Map;Ljava/util/Map;)V from class org.hibernate.cfg.ExtendedMappings
at org.hibernate.cfg.ExtendedMappings.<init>(ExtendedMappings.java:65)
at org.hibernate.cfg.AnnotationConfiguration.createExtendedMappings(AnnotationConfiguration.java:175)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:263)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.igl.util.HibernateStart.getByAnnotation(HibernateStart.java:91)
at org.igl.util.HibernateStart.contextInitialized(HibernateStart.java:50)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4343)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3043)
at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:4658)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1619)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1628)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1628)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1608)
at java.lang.Thread.run(Thread.java:595)
The code runs (of course with changes in the hibernate.cfg.xml) ok when I do:
Code:
SessionFactory factory = getByXML();
Session ses = factory.openSession();
ses.close();
if (myLogger.isInfoEnabled()) {
myLogger.info("hibernate SessionFactory added to the Servlet context");
}
...
private SessionFactory getByXML() throws Exception{
System.out.println("Status: Start Configuration");
Configuration config = new Configuration();
config.configure();
System.out.println("Status: Start Creation of SessionFactory");
SessionFactory sf = config.buildSessionFactory();
return sf;
}
This is the output of the code above:
Code:
new sessionFactory
13.04.2007 14:34:09 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
13.04.2007 14:34:09 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
13.04.2007 14:34:09 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : org/igl/bos/stammdaten.hbm.xml
13.04.2007 14:34:09 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: org.igl.bos.Stammdaten -> igl_mastammdaten
13.04.2007 14:34:09 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : org/igl/bos/nonmemberdata.hbm.xml
13.04.2007 14:34:09 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: org.igl.bos.NonMemberData -> phpbb_users
13.04.2007 14:34:09 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : org/igl/bos/SSO.hbm.xml
13.04.2007 14:34:09 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: org.igl.bos.SSO -> igl_sso
13.04.2007 14:34:09 org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
13.04.2007 14:34:09 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
13.04.2007 14:34:09 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
13.04.2007 14:34:09 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
13.04.2007 14:34:09 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost/igl
13.04.2007 14:34:09 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=****}
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 3.23.58-nt
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.10 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ )
13.04.2007 14:34:09 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLMyISAMDialect
13.04.2007 14:34:09 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
13.04.2007 14:34:09 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
13.04.2007 14:34:09 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
13.04.2007 14:34:09 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
13.04.2007 14:34:09 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
13.04.2007 14:34:09 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
13.04.2007 14:34:09 org.igl.util.HibernateStart contextInitialized
INFO: hibernate SessionFactory added to the Servlet context
The changes from the Hibernate to JPA are made according to Chapter two of the Java Persistence with Hibernate.
I do make sth. fundamentally wrong, but what? Please help, it is urgent!
Thankyou, chk