Announcement Announcement Module
Collapse
No announcement yet.
IllegalAccessError when ContextLoader creates sessionFactory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • IllegalAccessError when ContextLoader creates sessionFactory

    I get an IllegalAccessError from the cglib libraries when the ContextLoader attempts to initialize the sessionFactory bean defined in my applicationContext.xml file. I've tried different version of the cglib-xxx.jar with no success. Does anyone have any ideas as to what I could be configuring/doing wrong? Is this an appropriate area in the forum for this post?

    Here is relevant portion of applicationContext.xml:

    Code:
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
      		<property name="driverClassName">
      			<value>com.mysql.jdbc.Driver</value>
    		</property>
    		<property name="url">
    		    <value>jdbc&#58;mysql&#58;//localhost&#58;3306/DEV</value>
    		</property>
    		<property name="username">
    		    <value>developer</value>
    		</property>
    		<property name="password">
    		    <value>developer</value>
    		</property>
    	</bean>
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref bean="dataSource"/>
    		</property>
    		<property name="mappingResources">
    			<list>
    			<value>com/dev/domain/hibernate/User.hbm.xml</value>
    			<value>com/dev/domain/hibernate/UserInfo.hbm.xml</value>
    			</list>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">net.sf.hibernate.dialect.MySQLDialect</prop>
    				<!--<prop key="hibernate.cglib.use_reflection_optimizer">false</prop>-->
    			</props>
    		</property>
    	</bean>
    Here is exception:

    Code:
    ERROR &#91;org.springframework.web.context.ContextLoader&#93; Context initialization failed
    org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'sessionFactory' defined in resource &#91;/WEB-INF/applicationContext.xml&#93; of ServletContext&#58; Initialization of bean failed; nested exception is java.lang.IllegalAccessError&#58; null
    java.lang.IllegalAccessError
    	at net.sf.cglib.core.ClassEmitter.setTarget&#40;ClassEmitter.java&#58;47&#41;
    	at net.sf.cglib.core.ClassEmitter.<init>&#40;ClassEmitter.java&#58;39&#41;
    	at net.sf.cglib.core.KeyFactory$Generator.generateClass&#40;KeyFactory.java&#58;165&#41;
    	at net.sf.cglib.core.DefaultGeneratorStrategy.generate&#40;DefaultGeneratorStrategy.java&#58;25&#41;
    	at net.sf.cglib.core.AbstractClassGenerator.create&#40;AbstractClassGenerator.java&#58;215&#41;
    	at net.sf.cglib.core.KeyFactory$Generator.create&#40;KeyFactory.java&#58;145&#41;
    	at net.sf.cglib.core.KeyFactory.create&#40;KeyFactory.java&#58;117&#41;
    	at net.sf.cglib.core.KeyFactory.create&#40;KeyFactory.java&#58;108&#41;
    	at net.sf.cglib.core.KeyFactory.create&#40;KeyFactory.java&#58;104&#41;
    	at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>&#40;SessionFactoryImpl.java&#58;235&#41;
    	at net.sf.hibernate.cfg.Configuration.buildSessionFactory&#40;Configuration.java&#58;768&#41;
    	at org.springframework.orm.hibernate.LocalSessionFactoryBean.newSessionFactory&#40;LocalSessionFactoryBean.java&#58;436&#41;
    	at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet&#40;LocalSessionFactoryBean.java&#58;374&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods&#40;AbstractAutowireCapableBeanFactory.java&#58;948&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;284&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;204&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;199&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;136&#41;
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;203&#41;
    	at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;279&#41;
    	at org.springframework.web.context.support.XmlWebApplicationContext.refresh&#40;XmlWebApplicationContext.java&#58;131&#41;
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext&#40;ContextLoader.java&#58;156&#41;
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext&#40;ContextLoader.java&#58;97&#41;
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized&#40;ContextLoaderListener.java&#58;48&#41;
    	at org.apache.catalina.core.StandardContext.listenerStart&#40;StandardContext.java&#58;3805&#41;
    	at org.apache.catalina.core.StandardContext.start&#40;StandardContext.java&#58;4321&#41;
    	at org.apache.catalina.core.ContainerBase.addChildInternal&#40;ContainerBase.java&#58;823&#41;
    	at org.apache.catalina.core.ContainerBase.addChild&#40;ContainerBase.java&#58;807&#41;
    	at org.apache.catalina.core.StandardHost.addChild&#40;StandardHost.java&#58;595&#41;
    	at org.apache.catalina.core.StandardHostDeployer.install&#40;StandardHostDeployer.java&#58;277&#41;
    	at org.apache.catalina.core.StandardHost.install&#40;StandardHost.java&#58;832&#41;
    	at org.apache.catalina.startup.HostConfig.deployDirectories&#40;HostConfig.java&#58;683&#41;
    	at org.apache.catalina.startup.HostConfig.deployApps&#40;HostConfig.java&#58;432&#41;
    	at org.apache.catalina.startup.HostConfig.start&#40;HostConfig.java&#58;964&#41;
    	at org.apache.catalina.startup.HostConfig.lifecycleEvent&#40;HostConfig.java&#58;349&#41;
    	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent&#40;LifecycleSupport.java&#58;119&#41;
    	at org.apache.catalina.core.ContainerBase.start&#40;ContainerBase.java&#58;1091&#41;
    	at org.apache.catalina.core.StandardHost.start&#40;StandardHost.java&#58;789&#41;
    	at org.apache.catalina.core.ContainerBase.start&#40;ContainerBase.java&#58;1083&#41;
    	at org.apache.catalina.core.StandardEngine.start&#40;StandardEngine.java&#58;478&#41;
    	at org.apache.catalina.core.StandardService.start&#40;StandardService.java&#58;476&#41;
    	at org.apache.catalina.core.StandardServer.start&#40;StandardServer.java&#58;2298&#41;
    	at org.apache.catalina.startup.Catalina.start&#40;Catalina.java&#58;556&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;NativeMethodAccessorImpl.java&#58;39&#41;
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
    	at java.lang.reflect.Method.invoke&#40;Method.java&#58;582&#41;
    	at org.apache.catalina.startup.Bootstrap.start&#40;Bootstrap.java&#58;284&#41;
    	at org.apache.catalina.startup.Bootstrap.main&#40;Bootstrap.java&#58;422&#41;
    Aug 16, 2004 10&#58;46&#58;26 PM org.apache.catalina.core.StandardContext start
    SEVERE&#58; Error listenerStart
    Dave

  • #2
    I think you first need to clarify whether this issue involves Spring or is purely a Hibernate issue. Can you read the config with Hibernate, without Spring, to isolate the Hibernate and Spring config?

    Rgds
    Rod

    Comment


    • #3
      I ended up solving the problem by using cglib-full-2.0.jar, so it is not a spring issue. Thanks for the advice.

      Dave

      Comment

      Working...
      X