Wicket + Spring 3 + Hibernate

2010-04-15 Thread Steven Haines
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.dialectorg.hibernate.dialect.Oracle10gDialect/prop
prop key=hibernate.hbm2ddl.autovalidate/prop
/props
/property
property name=packagesToScan
list
valuecom.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
groupIdorg.apache.wicket/groupId
artifactIdwicket-spring/artifactId
version${wicket.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.context/artifactId
version${spring.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.core/artifactId
version${spring.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.web/artifactId
version${spring.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.web.servlet/artifactId
version${spring.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.beans/artifactId
version${spring.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.oxm/artifactId
version${spring.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.orm/artifactId
version${spring.version}/version
/dependency
dependency
groupIdjavax.servlet/groupId
artifactIdservlet-api/artifactId
version${servlet-api.version}/version
scopeprovided/scope
/dependency
dependency
groupIdorg.hibernate/groupId
artifactIdhibernate-core/artifactId
version3.3.2.GA/version
/dependency
dependency
groupIdjavax.persistence/groupId
artifactIdpersistence-api/artifactId
version1.0/version
/dependency
dependency
groupIdorg.hibernate/groupId
artifactIdhibernate-annotations/artifactId
version3.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: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Wicket + Spring 3 + Hibernate

2010-04-15 Thread Sigmar Muuga
What error? Next time post the stack :)

On Thu, Apr 15, 2010 at 5:47 PM, Steven Haines lyg...@yahoo.com 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.dialectorg.hibernate.dialect.Oracle10gDialect/prop
prop key=hibernate.hbm2ddl.autovalidate/prop
/props
/property
property name=packagesToScan
list
valuecom.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
groupIdorg.apache.wicket/groupId
artifactIdwicket-spring/artifactId
version${wicket.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.context/artifactId
version${spring.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.core/artifactId
version${spring.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.web/artifactId
version${spring.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.web.servlet/artifactId
version${spring.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.beans/artifactId
version${spring.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.oxm/artifactId
version${spring.version}/version
/dependency
dependency
groupIdorg.springframework/groupId
artifactIdorg.springframework.orm/artifactId
version${spring.version}/version
/dependency
dependency
groupIdjavax.servlet/groupId
artifactIdservlet-api/artifactId
version${servlet-api.version}/version
scopeprovided/scope
/dependency
dependency
groupIdorg.hibernate/groupId
artifactIdhibernate-core/artifactId
version3.3.2.GA/version
/dependency
dependency
groupIdjavax.persistence/groupId
artifactIdpersistence-api/artifactId
version1.0/version
/dependency
dependency
groupIdorg.hibernate/groupId
artifactIdhibernate-annotations/artifactId
version3.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: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Wicket + Spring 3 + Hibernate

2010-04-15 Thread Steven Haines
)
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 meedi...@gmail.com
To: users@wicket.apache.org; Steven Haines lyg...@yahoo.com
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 lyg...@yahoo.com 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.dialectorg.hibernate.dialect.Oracle10gDialect/prop
prop key=hibernate.hbm2ddl.autovalidate/prop
/props
/property
property name=packagesToScan
list
valuecom.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
groupIdorg.apache.wicket/groupId
artifactIdwicket-spring/artifactId
version${wicket.version}/version
/dependency
dependency
groupIdorg.springframework/groupId

Re: Wicket + Spring 3 + Hibernate

2010-04-15 Thread Steven Haines
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 lyg...@yahoo.com
To: users@wicket.apache.org
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

Re: Wicket + Spring 3 + Hibernate

2010-04-15 Thread Mauro Ciancio
Take out the 'default-autowire=byName' from your beans.xml
and it will work.

Cheers!

On Thu, Apr 15, 2010 at 12:21 PM, Steven Haines lyg...@yahoo.com wrote:
 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 lyg...@yahoo.com
 To: users@wicket.apache.org
 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