Results 1 to 4 of 4

Thread: IllegalAccessError on Hibernate3 with Annotation initialization.

  1. #1
    Join Date
    Aug 2005
    Posts
    14

    Default IllegalAccessError on Hibernate3 with Annotation initialization.

    Hi all!
    I'm new on Spring2.
    I have written a Web App using Spring1.2.8 and Hibernate3 with Annotation, and it works fine.
    Now I want to make porting to Spring2.0-m5 but I failed due to an error got during the Hibernate3 initialization process.
    Here after my application-context.xml file:

    Code:
    ...
    	<!-- ========================= DATASOURCES CONFIGURATION ======================== -->
    
    	<bean id="dataSource"
    		class="org.apache.commons.dbcp.BasicDataSource">
    		<property name="driverClassName" value="${database.driver}" />
    		<property name="url" value="${database.url}" />
    		<property name="username" value="${database.username}" />
    		<property name="password" value="${database.password}" />
    	</bean>
    
    	<!-- ========================= HIBERNATE3 CONFIGURATION ======================== -->
    
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 
    		<property name="dataSource">
    			<ref local="dataSource" />
    		</property>
    		<property name="configLocation" value="/WEB-INF/conf/hibernate/hibernate.cfg.xml"/>
    	</bean>
    	
    	<!-- ========================= DAO CONFIGURATION ======================== -->
    
    	<bean id="imageCollectionDAO" name="persistence::imageCollectionDAO"
    		class="my.company.persistence.hibernate.HibernateImageCollectionDAO">
    		<property name="sessionFactory">
    			<ref local="sessionFactory" />
    		</property>
    	</bean>
    ...
    but I took the following exception from Tomcat5:

    Code:
    ...  INFO[ContainerBackgroundProcessor[StandardEngine[Catalina]]](SessionFactoryImpl.java:159) - building session factory
     INFO[ContainerBackgroundProcessor[StandardEngine[Catalina]]](AbstractBeanFactory.java:652) - Destroying singletons in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [dataSource,postgis.dataSource,sessionFactory,postgis.sessionFactory,imageCollectionDAO,layerDAO,originalDbsDAO,labelDAO,pimbatchDAO,webpimbatchService,pimbatchService,boundaryPolygons,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer,webAnnotations,handlerMapping,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping,customEditorConfigurer,xfire.serviceRegistry,xfire.transportManager,xfire,xfire.typeMappingRegistry,xfire.aegisBindingProvider,xfire.serviceFactory,xfire.servletController,xfire.messageServiceFactory,xfire.messageBindingProvider]; root of BeanFactory hierarchy}
    ERROR[ContainerBackgroundProcessor[StandardEngine[Catalina]]](ContextLoader.java:205) - Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/conf/spring/applicationContext-persistence.xml]: Invocation of init method failed; nested exception is java.lang.IllegalAccessError: tried to access method net.sf.ehcache.CacheManager.<init>()V from class org.hibernate.cache.EhCacheProvider
    Caused by:
    java.lang.IllegalAccessError: tried to access method net.sf.ehcache.CacheManager.<init>()V from class org.hibernate.cache.EhCacheProvider
            at org.hibernate.cache.EhCacheProvider.start(EhCacheProvider.java:124)
            at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:180)
            at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1213)
            at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:876)
            at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:802)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:901)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:870)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:393)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:256)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:167)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:253)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:332)
            at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
            at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
            at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:809)
            at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:698)
            at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
            at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1190)
            at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:292)
            at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
            at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1305)
            at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1569)
            at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1578)
            at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1558)
            at java.lang.Thread.run(Thread.java:595)
    ...

    In my WEB-INF/lib I installed hibernate3.jar from Spring's libraries.

    Can you help me?
    I'm using:
    -Spring 2.0m5
    -Hibernate 3.1.3
    -Hibernate Annotations 3.2RC1
    -Tomcat 5.5
    -Sun JVM 1.5.0_07

    Thanks.

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    The latest hibernate uses ehcache 1.2 - you seem to be using an older version (1.1 maybe). Upgrade your ehcache library and report back if you still have problems.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Aug 2005
    Posts
    14

    Default

    Thank you for quickly reply!
    I tried to use ehcache1.2 and still not worked,
    but with ehcache1.2.1RC it worked.
    By the way, I don't like to use a "RC" if it is possible I would like to avoid it.

    Thus now I use the OpenSynphony Cache and it works very well (version 2.3.1).
    The change was easy:
    Code:
    <hibernate-configuration>
    	<session-factory>
    		<property name="cache.provider_class">
    			org.hibernate.cache.OSCacheProvider
    		</property>
    		<property name="hibernate.cglib.use_reflection_optimizer">
    			true
    		</property>
    		<property name="hibernate.dialect">
    			org.hibernate.dialect.InformixDialect
    		</property>
    		<mapping
    			class="com.mycompany.persistence.vo.PimbatchWork" />
    ...
    	</session-factory>
    </hibernate-configuration>

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    The big change, AFAIK, in ehcache 1.2.x is the usage of an instance cache manager per session factory. You could downgrade hibernate to the stable version (3.1.3) which requires ehcache 1.x.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •