Sorry for the spam, I found the root cause of the problem - I guess there is
some kind of circular dependency in Spring/Hibernate that appeared when I
integrated the app with Wicket... I dont full understand, but I changed
application context XML file to wire by name instead of type and the problem
went away:
<beans default-autowire="byName"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd">
I appreciate your responses and I hope that someone can find my couple days of
troubleshooting helpful :)
Thanks
Steve
----- Original Message ----
From: Steven Haines <[email protected]>
To: [email protected]
Sent: Thu, April 15, 2010 11:14:49 AM
Subject: Re: Wicket + Spring 3 + Hibernate
I posted a few lines from the error, but here is the complete stack trace. My
initial searches on this pointed to a circular dependency caused by autowiring,
which may or may not be the case - when I removed the default-autowire
parameter from my beans node then the error changed to state that the bean
needs a sessionFactory (because I removed it.) So note sure if I took a step
forward or back.
If you are interested I created a sample project that produces the error, I can
zip it up and mail it to you (but dont want to spam the whole list with an
attachment...
Thanks
Steve
Stack Trace:
Apr 15, 2010 11:05:11 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of
class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'messageDao' defined in file
[/Users/scadmin/Downloads/apache-tomcat-6.0.20/webapps/wicketspringhibernateexample/WEB-INF/classes/com/informit/dao/HibernateMessageDaoImpl.class]:
Unsatisfied dependency expressed through bean property 'sessionFactory': :
Error creating bean with name 'sessionFactory' defined in class path resource
[applicationContext.xml]: Unsatisfied dependency expressed through bean
property 'eventListeners': : Error creating bean with name 'transactionManager'
defined in class path resource [applicationContext.xml]: Cannot resolve
reference to bean 'sessionFactory' while setting bean property
'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error
creating bean with name 'sessionFactory': FactoryBean which is currently in
creation returned null from getObject; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'transactionManager' defined in class path resource
[applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory'
while setting bean property 'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error
creating bean with name 'sessionFactory': FactoryBean which is currently in
creation returned null from getObject; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'sessionFactory' defined in class path resource
[applicationContext.xml]: Unsatisfied dependency expressed through bean
property 'eventListeners': : Error creating bean with name 'transactionManager'
defined in class path resource [applicationContext.xml]: Cannot resolve
reference to bean 'sessionFactory' while setting bean property
'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error
creating bean with name 'sessionFactory': FactoryBean which is currently in
creation returned null from getObject; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'transactionManager' defined in class path resource
[applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory'
while setting bean property 'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error
creating bean with name 'sessionFactory': FactoryBean which is currently in
creation returned null from getObject
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1150)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1040)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:850)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:724)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:493)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1274)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:296)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:637)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'sessionFactory' defined in class path resource
[applicationContext.xml]: Unsatisfied dependency expressed through bean
property 'eventListeners': : Error creating bean with name 'transactionManager'
defined in class path resource [applicationContext.xml]: Cannot resolve
reference to bean 'sessionFactory' while setting bean property
'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error
creating bean with name 'sessionFactory': FactoryBean which is currently in
creation returned null from getObject; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'transactionManager' defined in class path resource
[applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory'
while setting bean property 'sessionFactory'; nested exception
is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error
creating bean with name 'sessionFactory': FactoryBean which is currently in
creation returned null from getObject
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1150)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1040)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:825)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:767)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:685)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1134)
... 29 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'transactionManager' defined in class path resource
[applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory'
while setting bean property 'sessionFactory'; nested exception is
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error
creating bean with name 'sessionFactory': FactoryBean which is currently in
creation returned null from getObject
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1308)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:825)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:754)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:685)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1134)
... 40 more
Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException:
Error creating bean with name 'sessionFactory': FactoryBean which is currently
in creation returned null from getObject
at
org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:157)
at
org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:109)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1387)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:244)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 53 more
Apr 15, 2010 11:05:11 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
----- Original Message ----
From: Sigmar Muuga <[email protected]>
To: [email protected]; Steven Haines <[email protected]>
Sent: Thu, April 15, 2010 11:09:50 AM
Subject: Re: Wicket + Spring 3 + Hibernate
What error? Next time post the stack :)
On Thu, Apr 15, 2010 at 5:47 PM, Steven Haines <[email protected]> wrote:
> Hi,
>
> I am at a point where I need to upgrade my application from Spring 2.5.6 to
> Spring 3.0.1.RELEASE. I have a working application and when I update Spring,
> I see the following exception on deployment:
>
> Caused by:
> org.springframework.beans.factory.BeanCurrentlyInCreationException: Error
> creating bean with name 'sessionFactory': FactoryBean which is currently in
> creation returned null from getObject
> at
> org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:157)
> at
> org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:109)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1387)
>
>
> I've simplified my Hibernate configuration to:
>
> <bean id="sessionFactory"
> class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
> <property name="dataSource" ref="dataSource" />
> <property name="hibernateProperties">
> <props>
> <prop
> key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
> <prop key="hibernate.hbm2ddl.auto">validate</prop>
> </props>
> </property>
> <property name="packagesToScan">
> <list>
> <value>com.mycompany.model</value>
> </list>
> </property>
> </bean>
>
> Finally, here is the dependency list in Maven for my Spring and Hibernate
> libraries with wicket.version=1.4.7 and spring.version=3.0.1.RELEASE:
> <dependency>
> <groupId>org.apache.wicket</groupId>
> <artifactId>wicket-spring</artifactId>
> <version>${wicket.version}</version>
> </dependency>
> <dependency>
> <groupId>org.springframework</groupId>
> <artifactId>org.springframework.context</artifactId>
> <version>${spring.version}</version>
> </dependency>
> <dependency>
> <groupId>org.springframework</groupId>
> <artifactId>org.springframework.core</artifactId>
> <version>${spring.version}</version>
> </dependency>
> <dependency>
> <groupId>org.springframework</groupId>
> <artifactId>org.springframework.web</artifactId>
> <version>${spring.version}</version>
> </dependency>
> <dependency>
> <groupId>org.springframework</groupId>
> <artifactId>org.springframework.web.servlet</artifactId>
> <version>${spring.version}</version>
> </dependency>
> <dependency>
> <groupId>org.springframework</groupId>
> <artifactId>org.springframework.beans</artifactId>
> <version>${spring.version}</version>
> </dependency>
> <dependency>
> <groupId>org.springframework</groupId>
> <artifactId>org.springframework.oxm</artifactId>
> <version>${spring.version}</version>
> </dependency>
> <dependency>
> <groupId>org.springframework</groupId>
> <artifactId>org.springframework.orm</artifactId>
> <version>${spring.version}</version>
> </dependency>
> <dependency>
> <groupId>javax.servlet</groupId>
> <artifactId>servlet-api</artifactId>
> <version>${servlet-api.version}</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>org.hibernate</groupId>
> <artifactId>hibernate-core</artifactId>
> <version>3.3.2.GA</version>
> </dependency>
> <dependency>
> <groupId>javax.persistence</groupId>
> <artifactId>persistence-api</artifactId>
> <version>1.0</version>
> </dependency>
> <dependency>
> <groupId>org.hibernate</groupId>
> <artifactId>hibernate-annotations</artifactId>
> <version>3.4.0.GA</version>
> </dependency>
>
>
> I have successfully integrated Spring 3 and Hibernate in a RESTful web
> service and I have successfully integrated Wicket 1.4.7 with Spring 2.5.6
> and Hibernate, but I am seeing errors specifically with Wicket and Spring 3
> with Hibernate. Has anyone successfully integrated the three technologies?
>
> Any suggestions?
>
> Thanks!
> Steve
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]